Esempio n. 1
0
    //Spawneo de la torreta en una determinada base
    public void SpawnTurret(BaseTurret _base)
    {
        if (towers.Count > 0 && towers[0])
        {
            int goldTurret = 0;

            for (byte i = 0; i < properties.units.Length; ++i)
            {
                if (properties.units[i].name == "Turret")
                {
                    goldTurret = properties.units[i].cost;
                    break;
                }
            }

            //Revisa si puede permitirselo antes de spawnearlo
            if (CheckGold(goldTurret))
            {
                _base.SetTaken(true);

                GameObject turretTemp = (GameObject)Instantiate(turret, _base.gameObject.transform.position, Quaternion.identity);
                turretTemp.GetComponent <Turret>().ownPlayer = this;
                turretTemp.GetComponent <Turret>().Generate(team, "Turret");
                turretTemp.GetComponent <Turret>().SetBase(_base.gameObject.transform.GetComponent <BaseTurret>());
                gold -= turretTemp.GetComponent <Turret>().GetCost();

                playerUnits.Add(turretTemp.GetComponent <Unit>());
            }
        }
    }
 //Se llama cuando la Torreta muere
 protected override void Death()
 {
     baseTurret.SetTaken(false);
     isDead = true;
     base.Death();
 }