Esempio n. 1
0
 public void DestroyTank(TankController tank)
 {
     if (tank != playerTank)
     {
         GameEventsManager.Instance.InvokeEnemyKilledEvent();
     }
     StartCoroutine(RespawnTankAfterDelay(tank));
 }
Esempio n. 2
0
        public TankController CreatePlayer()
        {
            Transform      randomTransform = TankSpawnPositionManager.Instance.GetEmptySpawnPosition();
            TankController tankControl     = Instantiate(playerTank, randomTransform.position, Quaternion.identity);

            createdTanks.Add(tankControl);
            return(tankControl);
        }
Esempio n. 3
0
        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();
        }
Esempio n. 4
0
        public IEnumerator RespawnTankAfterDelay(TankController tank)
        {
            Debug.Log("Resetting");
            tank.gameObject.SetActive(false);
            yield return(new WaitForSeconds(5f));

            Debug.Log("Resetting tsnk");
            ResetTank(tank);
        }
Esempio n. 5
0
        private void Start()
        {
            if (target != null)
            {
                return;
            }
            TankController tank = GetComponentInParent <TankController>();

            target = tank.transform;
        }
Esempio n. 6
0
        //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;
                }
            }
        }
Esempio n. 7
0
 void Start()
 {
     tc  = GetComponent <TankController>();
     cam = GetComponentInChildren <CameraTracker>();
 }
Esempio n. 8
0
 public void AddTank(TankController tank)
 {
     createdTanks.Add(tank);
 }