public void PassTurn() { activeUnits.Remove(activatedUnit); if (activatedUnit != null) { activatedUnit.movementLeft = 0; } activatedUnit = null; targetCircle.SetActive(false); targetCross.SetActive(false); confirmButton.gameObject.SetActive(false); chargeButton.gameObject.SetActive(false); if (activeUnits.Count <= 0) { activeUnits = new List <NetTBSUnit> (allActiveUnits); } foreach (NetTBSUnit u in allActiveUnits) { u.gameObject.GetComponent <Renderer> ().material = deactiveColor; } foreach (NetTBSUnit u in activeUnits) { u.gameObject.GetComponent <Renderer> ().material = activeColor; u.chargedDuringAction = false; u.movementLeft = u.movementMax; u.destroyOldChargeArrows(); if (!u.gameObject.activeInHierarchy) { activeUnits.Remove(u); } } }
IEnumerator chargePusher(Vector3 newPos) { RaycastHit hit; Vector3 chargDir = transform.position - newPos; while (moving) { Debug.DrawRay(transform.position, -chargDir.normalized * 1f, Color.blue); if (Physics.Raycast(transform.position, -chargDir.normalized, out hit, 1f)) { if (hit.collider.tag == "Player") { NetTBSUnit tmpUnit = hit.collider.GetComponent <NetTBSUnit> (); if (tmpUnit.whoOwnsMe() != whoOwnsMe()) { hit.collider.GetComponent <NetTBSUnit> ().Pushed(newPos, chargDir); } } else if (hit.collider.tag == "Pushable") { hit.collider.GetComponent <Pushable> ().Pushed(newPos, chargDir); } } yield return(null); } }
void UnitSelection(RaycastHit hit) { currentlySelectedUnit = hit.collider.gameObject.GetComponent <NetTBSUnit>(); //Set our current unit to the attempted selection if (currentlySelectedUnit.SelectUnit(playerNumber)) { Debug.Log("Select this unit " + hit.collider.name.ToString()); } else { Debug.Log("Unable to Select this unit " + hit.collider.name.ToString()); currentlySelectedUnit = null; } }
public void RemoveDeadUnit(NetTBSUnit deadUnit) { allActiveUnits.Remove(deadUnit); activeUnits.Remove(deadUnit); checkIfWeLost(); }
public void setChargeButton(NetTBSUnit caller, bool enabled) { chargeButton.gameObject.SetActive(enabled); chargeButton.onClick.RemoveAllListeners(); chargeButton.onClick.AddListener(caller.displayChargeOptions); }
public void setConfirmButton(NetTBSUnit caller, bool enabled) { confirmButton.gameObject.SetActive(enabled); confirmButton.onClick.RemoveAllListeners(); confirmButton.onClick.AddListener(caller.MoveUnitToConfirmedMovement); }