BlueGit

blue-star speeltuin

Files

speeltuin / src / chaoBehaviour / emote.js

emote.js

emotes
timfa Tim · pushed by timfa · 4 years ago
ce78c635 History
emote.js 1.5 KiB Download Raw
1class BehaviourEmote extends ChaoBehaviour
2{
3 pickedAnimation = "";
4
5 startBehaviour ()
6 {
7 let potentialMoods = [];
8
9 if (Chao.Instance.mood.hungry > 0.4)
10 potentialMoods.push("hungry");
11
12 if (Chao.Instance.mood.happy > 0.6 && Chao.Instance.mood.angry < 0.3 && Chao.Instance.mood.sad < 0.3)
13 {
14 potentialMoods.push("cheer");
15 potentialMoods.push("wave");
16 potentialMoods.push("happy");
17 }
18 else
19 {
20 if (Chao.Instance.mood.angry > 0.5 || Chao.Instance.mood.sad > 0.5)
21 {
22 if (Chao.Instance.mood.angry > Chao.Instance.mood.sad)
23 {
24 potentialMoods.push("standDownAngry");
25 potentialMoods.push("tantrum");
26 }
27 else
28 {
29 potentialMoods.push("standDownSad");
30 potentialMoods.push("cry");
31 }
32 }
33 else
34 {
35 if (Chao.Instance.mood.curious > 0.4)
36 {
37 potentialMoods.push("think");
38 potentialMoods.push("think2");
39 potentialMoods.push("eureka");
40 }
41 }
42 }
43
44 this.pickedAnimation = potentialMoods.random();
45 Chao.Instance.renderer.setAnimation(this.pickedAnimation);
46 }
47
48 update (deltaTime)
49 {
50 if (Chao.Instance.renderer.currentAnimationName != this.pickedAnimation)
51 this.endBehaviour();
52 }
53}