Game Development Reference
In-Depth Information
{
selectionCircle =
(GameObject)GameObject.Instantiate(battleManager.selectionCircle);
selectionCircle.transform.parent = transform;
selectionCircle.transform.localPosition =
Vector3.zero;
StartCoroutine("SpinObject", selectionCircle);
battleManager.SelectEnemy(this, EnemyProfile.Name);
}
}
}
Here, we store what the current state of the selected Goblin is (if we click on the same one
twice, unselect it); make sure there are no other Goblins selected (you may want to change
this behavior if you have weapons that can target more than one enemy). If it is a new se-
lection, perform the following steps:
1. Create a clone of the SelectionCircle prefab.
2. Set its transform and position local to the selected Goblin.
3. Start SelectionCircle , spinning with its coroutine.
4. Tell the BattleManager game object that we have selected a target to destroy.
Note
The new functions don't exist on the BattleManager script yet, so we will return to
those shortly.
Like with CommandButtons , we need a final function to clear the selection state of this
enemy if required, so add the ClearSelection method to the EnemyController
script, as follows:
public void ClearSelection()
{
if (selected)
{
selected = false;
if (selectionCircle != null)
DestroyObject(selectionCircle);
StopCoroutine("SpinObject");
Search WWH ::




Custom Search