-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdignityAction.js
More file actions
69 lines (55 loc) · 1.82 KB
/
Copy pathdignityAction.js
File metadata and controls
69 lines (55 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function DignityAction() {
DignityObject.call(this);
this.createObj = null;
this.createObjPos = null;
this.destroyObj = new DignityAIBase;
this.destroyLevel = 0;
this.upgradeObj = null;
this.upgradeObjPropName = "";
this.upgradeObjIncVal = 0;
this.upgradeObjNewVal = 0;
this.moveObj = new DignityAIBase;
this.moveFollowObj = null;
this.senseObj = new DignityAIBase;
this.senseRadius = 0;
this.senseTriggerTime = 0;
this.customActionObj = null;
this.customActionName = "";
this.ammo = 0;
this.fireSpeed = 0;
this.maxTurnAngle = 0;
};
DignityAction.prototype = Object.create(DignityObject.prototype);
DignityAction.prototype.constructor = DignityAction;
DignityAction.prototype.create = function () {
var _createdObject = this.createObj.clone();
this.createObj.setPosition(this.createObjPos);
};
DignityAction.prototype.destroy= function () {
this.destroyObj.life -= this.destroyLevel;
};
DignityAction.prototype.upgrade= function () {
if(this.upgradeObj.hasOwnProperty(this.upgradeObjPropName)) {
if(this.upgradeObjIncVal > 0) {
this.upgradeObj[this.upgradeObjPropName] += this.upgradeObjIncVal;
} else if(this.upgradeObjNewVal > 0) {
this.upgradeObj[this.upgradeObjPropName] = this.upgradeObjNewVal;
}
}
};
DignityAction.prototype.move= function () {
if(this.moveObj != null) {
this.moveObj.moveStart = true;
this.moveObj.moveEnd = false;
}
};
DignityAction.prototype.sense= function () {
if(this.senseObj != null) {
this.senseObj.senseRadius = this.senseRadius;
this.senseObj.senseStart = true;
this.senseObj.senseEnd = false;
}
};
DignityAction.prototype.custom = function() {
this.customActionObj[this.customActionName]();
};