/* * When the attack phase first starts, find all the units on the battlefield and add them to a dictionary. * Reset the movement points for all the units on the field for the new attack */ public void StartRound() { if (!roundStarted) { unitsOnField = new Dictionary <string, float>(); //find all units on the battlefield List <GameObject> units = new List <GameObject>(GameObject.FindGameObjectsWithTag("Unit")); //player units var aiUnits = GameObject.FindGameObjectsWithTag("AIUnit"); foreach (var aiUnit in aiUnits) { units.Add(aiUnit); } if (units != null) { foreach (var unit in units) { Unit unitScript = unit.GetComponent <Unit>(); unitsOnField.Add(unitScript.ID, unit.GetComponent <Unit>().Initiative); RightClickNavigation navScript = unit.GetComponent <RightClickNavigation>(); if (navScript != null) { unitScript.MovementLeft = unitScript.MaxDistance; } } } else { Debug.Log("No characters with tag 'Unit' were found in scene!"); } roundStarted = true; } GetHighestInitiative(); }
// Use this for initialization void Start() { //get info about the unit i'm attached to unitScript = GetComponentInParent <Unit>(); navScript = GetComponentInParent <RightClickNavigation>(); }