Beispiel #1
0
    public Tower Upgrade()
    {
        if (upgradePrefab != null)
        {
            GameObject upgradedTower = Instantiate(upgradePrefab);
            Tower      newTower      = upgradedTower.GetComponent <Tower>();

            newTower.firstPointPlaced   = firstPointPlaced;
            newTower.secondPointPlaced  = secondPointPlaced;
            newTower.toFirstPoint       = toFirstPoint;
            newTower.travelPoints       = travelPoints;
            newTower.timer              = timer;
            newTower.isPlaced           = isPlaced;
            newTower.canTravel          = canTravel;
            newTower.transform.rotation = transform.rotation;
            newTower.transform.position = transform.position;

            Shooter newShooter = upgradedTower.GetComponent <Shooter>();
            newShooter.CloneData(GetComponent <Shooter>());
            Destroy(gameObject);
            return(newTower);
        }
        return(null);
    }