Example #1
0
    public void Initialize()
    {
        Debug.Log("INITIALIZE CITY");
        _quantiteFrag  = 600;
        _pv            = ConstantesManager.CITY_PV_MAX;
        _pvMax         = ConstantesManager.CITY_PV_MAX;
        _enumStateCity = Enum_StateCity.Fighting;

        _listTurret [0].transform.localPosition = ConstantesManager.TURRET_1_LOCAL_POSITION;
        _listTurret [1].transform.localPosition = ConstantesManager.TURRET_2_LOCAL_POSITION;
        _listTurret [2].transform.localPosition = ConstantesManager.TURRET_3_LOCAL_POSITION;
        _listTurret [3].transform.localPosition = ConstantesManager.TURRET_4_LOCAL_POSITION;

        _listTurret [0]._enumIdTurret = Enum_IdTurret.Turret1;
        _listTurret [1]._enumIdTurret = Enum_IdTurret.Turret2;
        _listTurret [2]._enumIdTurret = Enum_IdTurret.Turret3;
        _listTurret [3]._enumIdTurret = Enum_IdTurret.Turret4;

        ConstantesManager.IS_TURRET_INITIALIZE = true;

        _truck.Initialize();
        for (int i = 0; i < _nombreTurret; i++)
        {
            _listTurret[i].Initialize();
        }
    }
Example #2
0
 private void CheckDefeateCondition()
 {
     if (_pv <= 0)
     {
         _enumStateCity = Enum_StateCity.Destroy;
     }
 }
Example #3
0
    public void getHit(int degat)
    {
        int degatRest = degat;

        for (int i = 0; i < _listTurret.Count; i++)
        {
            if (_listTurret[i]._pv > 0 && _listTurret[i]._enumCurrentTurretType != Enum_TurretType.None)
            {
                Debug.Log("turret i" + i + " turret count" + _listTurret.Count);
                _listTurret[i].getHit(degat / _nombreTurret);
                float sub = degat / _nombreTurret;
                if (sub % 10 >= 0.5)
                {
                    sub = sub + 1;
                }
                degatRest -= (int)sub;
                //Debug.Log ("Rest : " + degatRest);
            }
        }
        if (degatRest < degat / _nombreTurret)
        {
            degatRest = 0;
        }

        _pv -= degatRest;
        if (_pv <= 0)
        {
            _pv            = 0;
            _enumStateCity = Enum_StateCity.Destroy;
        }
        //Debug.Log ("City take Damage -" + degat);
        SubLifeLabel(degatRest);
    }
Example #4
0
 public void StartShoot()
 {
     _enumStateCity = Enum_StateCity.Fighting;
     _lock          = false;
     for (int i = 0; i < _listTurret.Count; i++)
     {
         _listTurret[i].StartShoot();
     }
 }
Example #5
0
    void Start()
    {
        _quantiteFrag        = 600;
        _timeMinInShootState = ConstantesManager.TIME_MIN_IN_SHOOT_STATE;


        GameObject truck = (GameObject)Instantiate(_truckPrefab, this.transform.position, Quaternion.identity);

        _truck = truck.GetComponent <Truck> ();
        _truck.transform.parent = this.transform;
        _listTurret             = new List <Turret>();

        for (int i = 0; i < _nombreTurret; i++)
        {
            GameObject turret = (GameObject)Instantiate(_prefabTurret, this.transform.position, Quaternion.identity);
            turret.name            += i;
            turret.transform.parent = this.transform;
            _listTurret.Add(turret.GetComponent <Turret>());
        }


        _quantiteFrag  = 600;
        _pv            = ConstantesManager.CITY_PV_MAX;
        _pvMax         = ConstantesManager.CITY_PV_MAX;
        _enumStateCity = Enum_StateCity.Fighting;

        _listTurret [0].transform.localPosition = ConstantesManager.TURRET_1_LOCAL_POSITION;
        _listTurret [1].transform.localPosition = ConstantesManager.TURRET_2_LOCAL_POSITION;
        _listTurret [2].transform.localPosition = ConstantesManager.TURRET_3_LOCAL_POSITION;
        _listTurret [3].transform.localPosition = ConstantesManager.TURRET_4_LOCAL_POSITION;

        _listTurret [0]._enumIdTurret = Enum_IdTurret.Turret1;
        _listTurret [1]._enumIdTurret = Enum_IdTurret.Turret2;
        _listTurret [2]._enumIdTurret = Enum_IdTurret.Turret3;
        _listTurret [3]._enumIdTurret = Enum_IdTurret.Turret4;

        _listTurret[3].Upgrade();

        ConstantesManager.IS_TURRET_INITIALIZE = true;
    }
Example #6
0
    public void CheckVictoryCondition()
    {
        if (_enumStateCity == Enum_StateCity.Destroy)
        {
            return;
        }

        int numberTurretWithNoTarget = 0;

        foreach (Turret tur in _listTurret)
        {
            if (tur.getTarget() == null)             //_enumTurretAim == Enum_TurretAim.NoEnnemiFound){
            {
                numberTurretWithNoTarget++;
            }
        }


        if (numberTurretWithNoTarget >= _nombreTurret)
        {
            _enumStateCity = Enum_StateCity.Winning;
            //Debug.Log ("City REPERE WIN");
        }        /*else{
                  *     int _nombreNull = 0;
                  *     foreach (Turret tur in _listTurret) {
                  *             if( tur.getTarget() == null){
                  *                     _nombreNull++;
                  *             }
                  *     }
                  *
                  *     if(_nombreNull >= _nombreTurret){
                  *             _enumStateCity = Enum_StateCity.Winning;
                  *     }
                  *
                  * }*/
    }