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") { TBSUnit tmpUnit = hit.collider.GetComponent <TBSUnit> (); //if (tmpUnit.whoOwnsMe () != whoOwnsMe ()) { //No one can own me hit.collider.GetComponent <TBSUnit> ().Pushed(newPos, chargDir); //} } else if (hit.collider.tag == "Pushable") { hit.collider.GetComponent <Pushable> ().Pushed(newPos, chargDir); } } yield return(null); } }
public void setChargeButton(TBSUnit caller, bool enabled) { if (chargeButton != null) { chargeButton.gameObject.SetActive(enabled); chargeButton.onClick.RemoveAllListeners(); chargeButton.onClick.AddListener(caller.displayActionGUIHelpers); } }
void UnitSelection(RaycastHit hit) { currentlySelectedUnit = hit.collider.gameObject.GetComponent <TBSUnit>(); //Set our current unit to the attempted selection if (currentlySelectedUnit.SelectUnit()) { } else { Debug.Log("Unable to Select this unit " + hit.collider.name.ToString()); currentlySelectedUnit = null; } }
public void PassTurn() { //activeUnits.Remove (activatedUnit); if (activatedUnit != null) { activatedUnit.movementLeft = 0; } activatedUnit = null; targetCircle.SetActive(false); targetCross.SetActive(false); confirmButton.gameObject.SetActive(false); if (chargeButton != null) { chargeButton.gameObject.SetActive(false); } if (activeUnits.Count <= 0) { activeUnits = new List <TBSUnit> (allActiveUnits); } foreach (TBSUnit u in allActiveUnits) { u.gameObject.GetComponent <Renderer> ().material = deactiveColor; } foreach (TBSUnit 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; if (unitAttached != null) { unitAttached.moving = true; while (unitAttached.moving) { Debug.DrawRay(transform.position, -chargDir.normalized * 10f, Color.blue); if (Physics.Raycast(transform.position, -chargDir.normalized, out hit, 1f)) { if (hit.collider.tag == "Player") { TBSUnit tmpUnit = hit.collider.GetComponent <TBSUnit>(); if (tmpUnit.whoOwnsMe() != ownerInt) { tmpUnit.Pushed(newPos, chargDir); } } else if (hit.collider.tag == "aiPlayer") { AIUnit tmpAIUnit = hit.collider.GetComponent <AIUnit>(); if (tmpAIUnit.whoOwnsMe() != ownerInt) { tmpAIUnit.Pushed(newPos, chargDir); } } else if (hit.collider.tag == "Pushable") { hit.collider.GetComponent <Pushable>().Pushed(newPos, chargDir); } } yield return(null); //Check next frame but wait until then } yield return(null); } else { AIUnit unitTmp = gameObject.GetComponent <AIUnit>(); unitTmp.moving = true; while (unitTmp.moving) { Debug.DrawRay(transform.position, -chargDir.normalized * 1f, Color.black); if (Physics.Raycast(transform.position, -chargDir.normalized, out hit, 1f)) { //Debug.Log(hit.collider.name); if (hit.collider.tag == "Player") { TBSUnit tmpUnit = hit.collider.GetComponent <TBSUnit>(); if (tmpUnit.whoOwnsMe() != ownerInt) { hit.collider.GetComponent <TBSUnit>().Pushed(newPos, chargDir); } } else if (hit.collider.tag == "Pushable") { hit.collider.GetComponent <Pushable>().Pushed(newPos, chargDir); } } yield return(null); //Check next frame but wait until then } yield return(null); } }
public void RemoveDeadUnit(TBSUnit deadUnit) { allActiveUnits.Remove(deadUnit); activeUnits.Remove(deadUnit); checkIfWeLost(); }
public void setConfirmButton(TBSUnit caller, bool enabled) { confirmButton.gameObject.SetActive(enabled); confirmButton.onClick.RemoveAllListeners(); confirmButton.onClick.AddListener(caller.MoveUnitToConfirmedMovement); }
void Start() { m_Player = gameObject.GetComponentInParent <PlayerInfo> (); m_grid = GameObject.FindObjectOfType <Grid> (); //This is slow and should be stored in the playerInfo for reference unitAttached = gameObject.GetComponent <TBSUnit>(); }