static IEnumerator MoveFollowers() { moving = true; target = otherlist[0]; for (int n = 1; n < otherlist.Count; ++n) { MoveMaster.SetTarget(otherlist[n]); moveTo = otherlist[n].CurrentHex; moves = otherlist[n].MoveSpeed; openSpaces = MapMaster.CellsWithinArea(moveTo, moves); //finds nearby hexcells distance = Vector3.Distance(target.CurrentHex.transform.position, otherlist[n].CurrentHex.transform.position); //distance between current hex and target hex. for (int i = 1; i < openSpaces.Count; ++i) //loops through the rest of the cells { if (openSpaces[i].Unit == null && distance > Vector3.Distance(target.CurrentHex.transform.position, openSpaces[i].transform.position)) { moveTo = openSpaces[i]; distance = Vector3.Distance(target.CurrentHex.transform.position, openSpaces[i].transform.position); } } yield return(new WaitForSeconds(.2f)); MoveMaster.EvaluateTile(moveTo); //Actually moves unit } Debug.Log("1"); moving = false; }
public static IEnumerator Move() { GameBrain.ChangeAcceptInput(false); yield return(new WaitForSeconds(1.0f)); HexCell moveTo; for (int i = 0; i < ai_units.Count; ++i) { if (ai_units[i] != null) { HexCell unit_cell = ai_units[i].CurrentHex; MoveMaster.SetTarget(ai_units[i]); moveTo = MapMaster.Map[ai_units[i].CurrentHex.R - 2, ai_units[i].CurrentHex.Q]; MoveMaster.EvaluateTile(moveTo); //Actually moves unit } } yield return(new WaitForSeconds(.75f)); while (MoveMaster.movingUnits != 0) { yield return(null); } yield return(GameBrain.ChangeTurn()); //GameBrain.ChangeAcceptInput(true); }
static IEnumerator MoveCannonFollowers() { moving = true; for (int i = 0; i < otherlist.Count; ++i) // loops through squad list to find everything else { if (otherlist[i].gameObject.tag != "cannon") { MoveMaster.SetTarget(otherlist[i]); target = otherlist[i]; moveTo = MapMaster.Map[target.CurrentHex.R - 2, target.CurrentHex.Q]; MoveMaster.EvaluateTile(moveTo); //Actually moves unit yield return(new WaitForSeconds(.2f)); } } Debug.Log("2"); moving = false; }
static void MoveCannon() { Debug.Log("Move Cannons"); HexCell moveTo; List <Unit> inRangeTargets = new List <Unit>(); for (int i = 0; i < otherlist.Count; ++i) //searches squad list for the cannon. { if (otherlist[i].gameObject.tag == "cannon") { Debug.Log("Found Cannon"); if (GameBrain.turnNum < 4) { otherlist[i].Moved = false; otherlist[i].MoveSpeed = 2; } HexCell cannonCell = otherlist[i].CurrentHex; List <HexCell> inRangeCells = MapMaster.CellsWithinArea(cannonCell, 11); //Gets all HexCells within "range" of the current cannon for (int j = 0; j < inRangeCells.Count; ++j) { //If the cell has an enemy unit on it that is not a cannon it is added to the list if (inRangeCells[j].Unit != null && inRangeCells[j].Unit.Player != PlayerMaster.CurrentTurn && inRangeCells[j].Unit.gameObject.tag != "Cannon") { inRangeTargets.Add(inRangeCells[j].Unit); } } //if(inRangeTargets.Count < 0) // { MoveMaster.SetTarget(otherlist[i]); target = otherlist[i]; moveTo = MapMaster.Map[target.CurrentHex.R - 2, target.CurrentHex.Q]; MoveMaster.EvaluateTile(moveTo); //Actually moves unit // } } } }
static void MoveLeadSoldier() { MoveMaster.SetTarget(otherlist[0]); //Which unit it's about to move //moveTo is hexcell unit is trying to move to. Starts as the cell the Unit is already on moveTo = otherlist[0].CurrentHex; moves = otherlist[0].MoveSpeed; openSpaces = MapMaster.CellsWithinArea(moveTo, moves); //finds nearby hexcells distance = Vector3.Distance(target.CurrentHex.transform.position, otherlist[0].CurrentHex.transform.position); //distance between current hex and target hex. for (int i = 1; i < openSpaces.Count; ++i) //loops through the rest of the cells { if (openSpaces[i].Unit == null && distance > Vector3.Distance(target.CurrentHex.transform.position, openSpaces[i].transform.position)) { moveTo = openSpaces[i]; distance = Vector3.Distance(target.CurrentHex.transform.position, openSpaces[i].transform.position); } } openSpaces.Clear(); MoveMaster.EvaluateTile(moveTo); //Actually moves unit }