public void DestroyTank(TankController tank) { if (tank != playerTank) { GameEventsManager.Instance.InvokeEnemyKilledEvent(); } StartCoroutine(RespawnTankAfterDelay(tank)); }
public TankController CreatePlayer() { Transform randomTransform = TankSpawnPositionManager.Instance.GetEmptySpawnPosition(); TankController tankControl = Instantiate(playerTank, randomTransform.position, Quaternion.identity); createdTanks.Add(tankControl); return(tankControl); }
public void ResetTank(TankController tank) { tank.gameObject.SetActive(true); Transform randomTransform = TankSpawnPositionManager.Instance.GetEmptySpawnPosition(); tank.transform.position = randomTransform.position; tank.transform.eulerAngles = randomTransform.eulerAngles; tank.ResetTankValues(); }
public IEnumerator RespawnTankAfterDelay(TankController tank) { Debug.Log("Resetting"); tank.gameObject.SetActive(false); yield return(new WaitForSeconds(5f)); Debug.Log("Resetting tsnk"); ResetTank(tank); }
private void Start() { if (target != null) { return; } TankController tank = GetComponentInParent <TankController>(); target = tank.transform; }
//I really should've used a State or Observer Design pattern ... this is a f*****g mess, but it's too late now, sorry :( private void OnCollisionEnter(Collision collision) { if (!collision.gameObject.CompareTag("Player") || _colliding) { return; } if (state == TankState.BLOCK) { _rb.constraints = RigidbodyConstraints.FreezeAll; agent.AddReward(.7f * GetNormalizedSpecial()); return; } _colliding = true; TankController other = collision.gameObject.GetComponent <TankController>(); float otherDot = other.ForwardDot(transform.position); if (Mathf.Abs(ForwardDot(other.transform.position)) < Mathf.Abs(otherDot)) { if (Mathf.Abs(otherDot) >= .5f) { Vector3 impulseForce = -collision.impulse * 1.5f; switch (other.state) { case TankState.BLOCK: StartCoroutine(CollisionStateHandler()); impulseForce *= 3f; if (other.agent) { other.agent.AddReward(.5f); } break; case TankState.BOOST: StartCoroutine(CollisionStateHandler()); SpecialCounter += MAX_SPECIAL * .3f; if (state != TankState.BOOST) { impulseForce *= 1.5f; } break; } _rb.AddForce(impulseForce, ForceMode.Impulse); } } else { if (!TooCloseFlag) { numCollisions++; var position = collision.transform.position; agent.TackleReward(position); lastCollisionPos = position; _lastColTime = Time.time; } } }
void Start() { tc = GetComponent <TankController>(); cam = GetComponentInChildren <CameraTracker>(); }
public void AddTank(TankController tank) { createdTanks.Add(tank); }