Example #1
0
    public void BuildTurret()
    {
        TurretStats turretToBuild = turretManager.turretToBuild;

        turretStats = turretToBuild;

        if (!turretManager.CanBuild)
        {
            return;
        }


        if (PlayerManager.money < turretToBuild.cost) // Checks if you have no money left.
        {
            turretManager.HandleNotEnoughMoney();
            return;
        }

        turretManager.HandleTurretPurchased(turretToBuild);

        PlayerManager.money -= turretToBuild.cost;
        GameObject turret          = Instantiate(turretToBuild.turretPrefab, GetBuildPosition(), Quaternion.identity);
        Turret     turretComponent = turret.GetComponent <Turret>();

        turretComponent.SetNode(this);
        this.turret = turret;
        turretManager.HidePlacePath();

        TurretSelection.singleton.HideUiObject();
        ShopManager.singleton.TurretPlaced();
    }