Game Development Reference
In-Depth Information
09 //The current state of enemy
10 public EnemyState ActiveState = EnemyState.CHASE;
11
12 // Use this for initialization
13 void Start () {
14 }
15
16 // Update is called once per frame
17 void Update ()
18 {
19 //Check the ActiveState variable
20 switch(ActiveState)
21 {
22 case EnemyState.FIGHT:
23 {
24 //Perform fight code here
25 Debug.Log ("Entered fight state");
26 }
27 break;
28
29
30 case EnemyState.FLEE:
31 case EnemyState.HIDE:
32 {
33 //Flee and hide performs the same behaviour
34 Debug.Log ("Entered flee or hide state");
35 }
36 break;
37
38 default:
39 {
40 //Default case when all other states fail
41 //This is used for the chase state
42 Debug.Log ("Entered chase state");
43 }
44 break;
45 }
46 }
47 }
 
Search WWH ::




Custom Search