/// <summary> /// Callback for "showMoveDialog" event. Generates content for the move confirmation /// dialog and enables it. /// </summary> /// <param name="type"></param> public void ShowMoveDialog(ETowerType type) { currentType = type; DialogConfig config = new DialogConfig(); int cost = currentType.GetMoveCost(); 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: "Move" ); config.Cancel = new DialogButton( onClick: OnCancelClickMove, text: "Cancel" ); } else { messageString = "Moving " + type.GetString() + " will cost $" + cost + ". You have $" + GameState.CurrentCash; config.OK = new DialogButton( onClick: OnOKClickMove, text: "Move" ); config.Cancel = new DialogButton( onClick: OnCancelClickMove, text: "Cancel" ); } config.Message = messageString; dialogSystem.Show(config); }
/// <summary> /// Passed as a callback for the OK button on the move dialog. /// </summary> public void OnOKClickMove() { GameState.CurrentCash -= currentType.GetMoveCost(); moveTransaction.Invoke(true); }