chao behaviour start
The contents of this binary file are not shown.
The contents of this binary file are not shown.
@@ -0,0 +1,18 @@
1
class ChaoBehaviour
2
{
3
constructor()
4
{
5
Chao.Instance.registerBehaviour(this);
6
}
7
8
startBehaviour()
9
{
10
//override this to allow the Chao to start this behaviour
11
}
12
13
endBehaviour()
14
{
15
//make sure to call this so the Chao knows it can queue up another thing.
16
Chao.Instance.behaviourCompleted();
17
}
18
}
@@ -0,0 +1,18 @@1
class ChaoBehaviour2
{3
constructor()4
{5
Chao.Instance.registerBehaviour(this);6
}7
8
startBehaviour()9
{10
//override this to allow the Chao to start this behaviour11
}12
13
endBehaviour()14
{15
//make sure to call this so the Chao knows it can queue up another thing.16
Chao.Instance.behaviourCompleted();17
}18
}@@ -1,12 +1,36 @@
1
1
class Chao extends GameObject
2
2
{
3
3
speed = 40;
4
scenePadding = 50;
5
targetDestination = null;
6
busyWithBehaviour = false;
7
8
minTimeBetweenBehaviour = 3; //in seconds
9
maxTimeBetweenbehaviour = 10; // in seconds
10
behaviourTimer = 10;
11
12
behaviourList = [];
13
14
static Instance;
4
15
5
16
constructor(x, y, sprite, layer)
6
17
{
7
18
super(x, y, sprite, layer);
8
19
this.wasHeld = {}
9
20
this.collider.enabled = true;
21
Chao.Instance = this;
22
}
23
24
registerBehaviour(behaviour)
25
{
26
this.behaviourList.push(behaviour);
27
}
28
29
behaviourCompleted()
30
{
31
this.busyWithBehaviour = false;
32
}
33
10
34
addedToScene()
11
35
{
12
36
this.renderer.sprite = this.scene.game.chaoImages.random();
@@ -1,12 +1,36 @@1
class Chao extends GameObject1
class Chao extends GameObject2
{2
{3
speed = 40;3
speed = 40;4
scenePadding = 50;5
targetDestination = null;6
busyWithBehaviour = false;7
8
minTimeBetweenBehaviour = 3; //in seconds9
maxTimeBetweenbehaviour = 10; // in seconds10
behaviourTimer = 10;11
12
behaviourList = [];13
14
static Instance;4
15
5
constructor(x, y, sprite, layer)16
constructor(x, y, sprite, layer)6
{17
{7
super(x, y, sprite, layer);18
super(x, y, sprite, layer);8
this.wasHeld = {}19
this.wasHeld = {}9
this.collider.enabled = true;20
this.collider.enabled = true;21
Chao.Instance = this;22
}23
24
registerBehaviour(behaviour)25
{26
this.behaviourList.push(behaviour);27
}28
29
behaviourCompleted()30
{31
this.busyWithBehaviour = false;32
}33
10
addedToScene()34
addedToScene()11
{35
{12
this.renderer.sprite = this.scene.game.chaoImages.random();36
this.renderer.sprite = this.scene.game.chaoImages.random();