Game Development Reference
In-Depth Information
40 //------------------------------------------------
41 //Handle patrol state
42
public void Patrol()
43 {
44 //Hide default and attack sprites
45 foreach(SpriteRenderer SR in AttackSprites)
46 SR.enabled=false;
47
48
//Hide default sprite
49 DefaultSprite.enabled = false;
50
51
//Entered patrol state
52 SendMessage ("StopSpriteAnimation", ((int)ENEMY_STATE.PATROL),
SendMessageOptions.DontRequireReceiver);
53 SendMessage ("StopSpriteAnimation", ((int)ENEMY_STATE.ATTACK),
SendMessageOptions.DontRequireReceiver);
54 SendMessage("PlaySpriteAnimation", ((int)ENEMY_STATE.PATROL),
SendMessageOptions.DontRequireReceiver);
55 }
56 //------------------------------------------------
57 }
58 //------------------------------------------------
Now the
Enemy_Drone
integrates with the pathfinding functionality coded into its base, at least for the
Patrol state
. Take it for a test run and see the Enemy run along, his legs in motion (also see Figure
7-16
).
Figure 7-16.
Enemy in motion!