#Can I upgrade turret more than 1 step in tower defense game?

1 messages · Page 1 of 1 (latest)

rough moss
#

void BuildTurret (OperatorBlueprint blueprint)
{
if (PlayerStats.Money < blueprint.cost)
{
Debug.Log ("Not enough money to build that!");
return;
}

    PlayerStats.Money -= blueprint.cost;

    GameObject _turrent = (GameObject)Instantiate(blueprint.Prefab, GetBuildPosition(), Quaternion.identity);
    turrent = _turrent;

    turrentBlueprint = blueprint;

    Debug.Log ("turrent build! Money left : " + PlayerStats.Money);
}

public void UpgradeOperator ()
{
if (PlayerStats.Money < turrentBlueprint.upgradeCost)
{
Debug.Log ("Not enough money to upgrade that!");
return;
}

    PlayerStats.Money -= turrentBlueprint.upgradeCost;

    //Get rid of the old Operator
    Destroy(turrent);
    //Buiding the new one
    GameObject _turrent = (GameObject)Instantiate(turrentBlueprint.upgradePrefab, GetBuildPosition(), Quaternion.identity);
    turrent = _turrent;

    isUpgraded = true;

    Debug.Log ("Turrent upgraded!");
}
#

this is my code that i watch form brackeys clip and i have a questio about how to upgrade more than 1 step

stray wigeonBOT
#

Use codeblocks to send code in a message!

To make a codeblock, surround your code with ```
To use C# syntax highlighting add cs after the three back ticks.

For example:
```cs
Console.WriteLine("Hello World");
```

Produces:

Console.WriteLine("Hello World");

To send lengthy code, paste it into https://paste.myst.rs/ and send the link of the paste into chat.