public void moveShips() { getShips(); foreach (GameObject currentShip in ships) { SpaceMover currentSpaceMover = currentShip.GetComponent <SpaceMover> (); currentSpaceMover.applyManuver(currentSpaceMover.manuver); currentSpaceMover.MoveShip(); currentSpaceMover.ActionPoints = 1; currentSpaceMover.manuver = currentSpaceMover.CreateOrderOfAction(0, 0); Debug.Log(currentSpaceMover.manuver); } for (int i = 0; i < ships.Count - 1; i++) { for (int j = i + 1; j < ships.Count; j++) { if (ships[i] != null && ships[j] != null) { if (ships [i].GetComponent <SpaceMover> ().getCell() == ships [j].GetComponent <SpaceMover> ().getCell()) { ships [i].GetComponent <SpaceMover>().TakeDamage(ships [i].GetComponent <SpaceMover>(), 1); ships [j].GetComponent <SpaceMover>().TakeDamage(ships [j].GetComponent <SpaceMover>(), 1); } } } } getShips(); }
/// <summary> /// Method is called when unit is deselected. /// </summary> public virtual void OnUnitDeselected() { SetState(new UnitStateMarkedAsFriendly(this)); if (UnitDeselected != null) { UnitDeselected.Invoke(this, new EventArgs()); } SpaceMover mover = this.GetComponent <SpaceMover>(); if (mover != null) { mover.turnManager.inUse = null; } }
public void advanceTurnState() { inUse = null; inertiaLine.SetPosition(1, inertiaLine.GetPosition(0)); if (turnState >= 3) { turnState = 0; } else { turnState++; } switch (turnState) { case 0: getShips(); MusicPlayer.instance.PlayAttackSound(); eventLog.AddEvent("Player 1 Maneuver Turn"); resetActionPoints(); // resolve attacks(override DealDamage, store damage as string, resolve damage function), reset action points ApplyDamageToShips(); GameObject.Find("Button").GetComponentInChildren <UnityEngine.UI.Text>().text = "End Player 1 Movement Turn"; break; case 1: eventLog.AddEvent("Player 2 Maneuver Turn"); GameObject.Find("Button").GetComponentInChildren <UnityEngine.UI.Text>().text = "End Player 2 Movement Turn"; break; case 2: MusicPlayer.instance.PlayMovementSound(); eventLog.AddEvent("Player 1 Attack Turn"); moveShips(); // resolve movements, set action points GameObject.Find("Button").GetComponentInChildren <UnityEngine.UI.Text>().text = "End Player 1 Attack Turn"; break; case 3: eventLog.AddEvent("Player 2 Attack Turn"); GameObject.Find("Button").GetComponentInChildren <UnityEngine.UI.Text>().text = "End Player 2 Attack Turn"; break; } }