Esempio n. 1
0
    /// <summary>
    /// Callback for "showUpgradeDialog" event. Generates content for the upgrade confirmation
    /// dialog and enables it.
    /// </summary>
    /// <param name="type"></param>
    public void ShowUpgradeDialog(ETowerType type)
    {
        currentType = type;
        DialogConfig config = new DialogConfig();

        int    cost = currentType.GetCost();
        string messageString;

        if (cost > GameState.CurrentCash)
        {
            messageString = "You don't have enough cash. Required: " + cost + ". You have $" + GameState.CurrentCash;

            // As both buttons won't do anything special in this case, you could leave the callback
            config.OK = new DialogButton(
                interactable: false,
                text: "Upgrade"
                );
            config.Cancel = new DialogButton(
                text: "Cancel"
                );
        }
        else
        {
            messageString = "Upgrade to " + type.GetString() + "will cost $" + cost + ". You have $" + GameState.CurrentCash;
            config.OK     = new DialogButton(
                onClick: OnOKClick,
                text: "Upgrade"
                );
            config.Cancel = new DialogButton(
                onClick: OnCancelClick,
                text: "Cancel"
                );
        }

        config.Message = messageString;
        dialogSystem.Show(config);
    }
Esempio n. 2
0
 /// <summary>
 /// Passed an a callback for the OK button on the upgrade dialog.
 /// </summary>
 public void OnOKClick()
 {
     GameState.CurrentCash -= currentType.GetCost();
     createTower.Invoke(currentType);
 }