Example #1
0
 public void SetTanks(Tank tank, Action callback)
 {
     mTank   = tank;
     mTurret = mTank.GetComponentInChildren <TankTurret>();
     StopAllCoroutines();
     StartCoroutine(GoAndLookAt(mTurret.tankView.transform.position, mTurret.tankView.transform.rotation, callback));
 }
Example #2
0
    // Unity Start Method
    void Start()
    {
        if (turretTransform == null)
        {
            turretTransform = transform.FindChild("Turret");
            if (turretTransform == null)
            {
                Debug.LogError("Tank@Start. Cannot find child game object named Turret.");
            }
        }

        if (turretCannon == null)
        {
            turretCannon = turretTransform.FindChild("Gun");
            if (turretCannon == null)
            {
                Debug.LogError("Tank@Start. Cannot find child game object named Gun.");
            }
        }

        hull = new TankHull(this, transform);
        hull.Start();

        turret = new TankTurret(this, turretTransform, turretCannon);
        turret.Start();

        if (Application.isPlaying)
        {
            explosionManager = PoolManager.Instance.GetItemPoolManager("ExplosionManager");

            flameManager = PoolManager.Instance.GetItemPoolManager("FlameManager");

            detonationManager = PoolManager.Instance.GetItemPoolManager("DetonationManager");
        }
    }
Example #3
0
 public void ResetCamera(Vector3 position, Quaternion rotation, Action callback)
 {
     mTank   = null;
     mTurret = null;
     StopAllCoroutines();
     StartCoroutine(GoAndLookAt(position, rotation, callback));
 }
Example #4
0
    private void Awake()
    {
        m_tankMovement = GetComponent <TankMovement>();
        m_tankTurret   = GetComponent <TankTurret>();
        m_cannon       = GetComponent <CannonWeapon>();

        m_currentHp = m_maxHp;
    }
Example #5
0
 void Awake()
 {
     EnemyManager.Instance.RegisterEnemy(this);
     mTurret       = GetComponentInChildren <TankTurret>();
     mRb           = GetComponent <Rigidbody>();
     mPathMarker   = GetComponent <TankPathMarker>();
     mTankAnimator = GetComponent <Animator>();
     mMovingPath   = new NavMeshPath();
 }
    public void DefineTurret(TankTurret turret)
    {
        //Sprite do canhão
        sprtRendTurret.sprite = turret._TowerSprite;

        //O projétil do canhão
        shoot = turret._bullet;

        //Velocidade de tiro
        _fireRate = TankSettings.tankInfo[_playerNumber].turret._fireRate;

        //Velocidade de rotação
        _rotationSpeed = TankSettings.tankInfo[_playerNumber].turret._turnSpeed;

        //Dano do canhão
        _damage = TankSettings.tankInfo[_playerNumber].turret._damage;
    }
Example #7
0
    public static void RemoveTurret(TankTurret tank)
    {
        if (!instance)
        {
            return;
        }

        if (instance.turrets.Count > 0)
        {
            instance.turrets.Remove(tank);
        }

        if (instance.turrets.Count < 1)
        {
            instance.gameObject.SetActive(false);
        }
    }
Example #8
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="nextWeapon">If true - next weapon, if false - previous weapon</param>
    public void ChangeTurret(bool nextWeapon)
    {
        int turretCounter = 0;
        int nextTurret    = 0;

        TankTurret prevTankTurret = turretKeeper.GetComponentInChildren <TankTurret>();

        for (int i = 0; i < turrets.Length; i++)
        {
            if (turrets[i].id == prevTankTurret.id)
            {
                turretCounter = i;
            }
        }

        Destroy(prevTankTurret.gameObject);

        if (nextWeapon)
        {
            if (turretCounter == turrets.Length - 1)
            {
                nextTurret = 0;
            }
            else
            {
                nextTurret = turretCounter + 1;
            }
        }
        else
        {
            if (turretCounter == 0)
            {
                nextTurret = turrets.Length - 1;
            }
            else
            {
                nextTurret = turretCounter - 1;
            }
        }

        Instantiate(turrets[nextTurret], turretKeeper.transform);
    }
Example #9
0
 public static void AddNewTankTurret(TankTurret tank)
 {
     instance.turrets.Add(tank);
 }
Example #10
0
 public void SetOwner(GameObject o, TankTurret t)
 {
     owner     = o;
     ownerComp = t;
 }
 public static void MakeTankSpecial(TankTurret tank)
 {
     instance.tankBtn.SetActive(true);
     TankSpecial.AddNewTankTurret(tank);
 }
Example #12
0
    public void Shoot()
    {
        TankTurret turret = turretKeeper.GetComponentInChildren <TankTurret>();

        turret.Shoot();
    }