Graphics Reference
In-Depth Information
aControl.SetAIState( AIStates.AIState.chasing_target );
// we also need to add this enemy to the radar, so we will
// tell game controller about it and
// some code in game controller will do this for us
GameController_LBS.Instance.AddEnemyToRadar( myTransform );
}
As all of the games have different custom game controller scripts, it is not possible for all of
the player scripts to try to call their game controllers in the same way. Instead, some functions
need to be designed to talk to a specific game controller. The enemy needs to tell the game con-
troller when it is destroyed by calling its EnemyDestroyed() or BossDestroyed() function when
the enemy is set to a boss. When an enemy is destroyed, it also needs to tell the game controller
to remove its transform from the list of transforms that are being tracked by the radar:
// game controller specifics (overridden for our laser blast
// survival game controller)
// ----------------------------------------------------------------
public override void TellGCEnemyDestroyed()
{
// tell the game controller we have been destroyed
GameController_LBS.Instance.EnemyDestroyed( myTransform.
position, pointsValue, tempINT );
// remove this enemy from the radar
GameController_LBS.Instance.RemoveEnemyFromRadar
( myTransform );
}
public override void TellGCBossDestroyed()
{
// tell the game controller we have been destroyed (and that
// we are a boss!)
GameController_LBS.Instance.BossDestroyed();
// remove this enemy from the radar
GameController_LBS.Instance.RemoveEnemyFromRadar
( myTransform );
}
}
11. 8 Wave Spawning and Control
Here is the Wave_Spawner.cs script in full:
using UnityEngine;
using System.Collections;
public class Wave_Spawner : MonoBehavior
{
public bool randomSpawning;
public float timeBeforeFirstSpawn=1f;
public GameObject[] spawnObjectPrefabs;
Search WWH ::




Custom Search