partial void ButtonRestart_TouchUpInside(UIButton sender) { LabelWinner.Text = ""; //ButtonOne.TitleLabel.Text = ""; ButtonOne.Enabled = true; ButtonOne.SetTitle("", UIControlState.Normal); string btnOne = ButtonOne.Title(UIControlState.Normal); // ButtonTwo.TitleLabel.Text = ""; ButtonTwo.Enabled = true; ButtonTwo.SetTitle("", UIControlState.Normal); string btnTwo = ButtonTwo.Title(UIControlState.Normal); // ButtonTwo.SetTitle("", UIControlState.Normal); // ButtonThree.TitleLabel.Text = ""; ButtonThree.Enabled = true; ButtonThree.SetTitle("", UIControlState.Normal); string btnThree = ButtonThree.Title(UIControlState.Normal); // ButtonThree.SetTitle("", UIControlState.Normal); // ButtonFour.TitleLabel.Text = ""; ButtonFour.Enabled = true; ButtonFour.SetTitle("", UIControlState.Normal); string btnFour = ButtonFour.Title(UIControlState.Normal); // ButtonFour.SetTitle("", UIControlState.Normal); // ButtonFive.TitleLabel.Text = ""; ButtonFive.SetTitle("", UIControlState.Normal); ButtonFive.Enabled = true; string btnFive = ButtonFive.Title(UIControlState.Normal); // ButtonSix.TitleLabel.Text = ""; ButtonSix.Enabled = true; ButtonSix.SetTitle("", UIControlState.Normal); string btnSix = ButtonSix.Title(UIControlState.Normal); // ButtonSeven.TitleLabel.Text = ""; ButtonSeven.Enabled = true; ButtonSeven.SetTitle("", UIControlState.Normal); string btnSeven = ButtonSeven.Title(UIControlState.Normal); // ButtonEight.TitleLabel.Text = ""; ButtonEight.Enabled = true; ButtonEight.SetTitle("", UIControlState.Normal); string btnEight = ButtonEight.Title(UIControlState.Normal); // ButtonNine.TitleLabel.Text = ""; ButtonNine.Enabled = true; ButtonNine.SetTitle("", UIControlState.Normal); string btnNine = ButtonNine.Title(UIControlState.Normal); counter = 0; }
// This is the main function called every time the story changes. It does a few things: // Destroys all the old content and choices. // Continues over all the lines of text, then displays all the choices. If there are no choices, the story is finished! void RefreshView() { // Remove all the UI on screen //RemoveChildren(); // Read all the content until we can't continue any more while (story.canContinue) { // Continue gets the next line of the story string text = story.Continue(); // This removes any white space from the text. text = text.Trim(); // Display the text on screen! CreateContentView(text); } // Display all the choices, if there are any! if (story.currentChoices.Count > 0) { if (story.currentChoices.Count == 1) { Choice choice = story.currentChoices[0]; Button button = CreateChoiceView(choice.text.Trim(), 1); // Tell the button what to do when we press it button.onClick.AddListener(delegate { OnClickChoiceButton(choice); }); } else if (story.currentChoices.Count == 2) { for (int i = 0; i < story.currentChoices.Count; i++) { Choice choice = story.currentChoices[i]; Button button = CreateChoiceView(choice.text.Trim(), 2); // Tell the button what to do when we press it button.onClick.AddListener(delegate { OnClickChoiceButton(choice); }); } } } // If we've read all the content and there's no choices, the story is finished! else { ButtonTwo.SetActive(false); ButtonOne.gameObject.SetActive(true); Button button = CreateChoiceView("Exit", 1); // Tell the button what to do when we press it button.onClick.AddListener(delegate { TextLogObj.SetActive(false); }); } }
public override void ViewDidLoad() { base.ViewDidLoad(); ButtonOne.SetTitle("", UIControlState.Normal); ButtonTwo.SetTitle("", UIControlState.Normal); ButtonThree.SetTitle("", UIControlState.Normal); ButtonFour.SetTitle("", UIControlState.Normal); ButtonFive.SetTitle("", UIControlState.Normal); ButtonSix.SetTitle("", UIControlState.Normal); ButtonSeven.SetTitle("", UIControlState.Normal); ButtonEight.SetTitle("", UIControlState.Normal); ButtonNine.SetTitle("", UIControlState.Normal); LabelWinner.Text = ""; // Perform any additional setup after loading the view, typically from a nib. }
// Creates a button showing the choice text Button CreateChoiceView(string text, int choices) { if (choices == 1) { ButtonTwo.SetActive(false); ButtonOne.gameObject.SetActive(true); // Gets the text from the button prefab Button choice = ButtonOne.GetComponentInChildren <Button>(); // Make the button expand to fit the text // HorizontalLayoutGroup layoutGroup = ButtonOne.GetComponent<HorizontalLayoutGroup>(); //layoutGroup.childForceExpandHeight = false; return(ButtonOne); } else if (choices == 2) { ButtonOne.gameObject.SetActive(false); ButtonTwo.SetActive(true); Button[] choice = ButtonTwo.GetComponentsInChildren <Button>(); Debug.Log(choice[0] + " " + choice[1]); // Gets the text from the button prefab for (int i = 0; i < 2; i++) { Transform buttonChild = choice[i].gameObject.transform.GetChild(0); TextMeshProUGUI choiceText = buttonChild.GetComponent <TextMeshProUGUI>(); choiceText.text = text; // Make the button expand to fit the text //HorizontalLayoutGroup layoutGroup = choice[i].GetComponent<HorizontalLayoutGroup>(); //layoutGroup.childForceExpandHeight = false; return(choice[i]); } } return(null); }
partial void ButtonTwo_TouchUpInside(UIButton sender) { if (counter == 0) { ButtonTwo.SetTitle("X", UIControlState.Normal); ButtonTwo.SetTitleColor(UIColor.Black, UIControlState.Normal); LabelTurn.Text = "Turn X"; counter++; } else if (counter == 1) { ButtonTwo.SetTitle("O", UIControlState.Normal); ButtonTwo.SetTitleColor(UIColor.Black, UIControlState.Normal); LabelTurn.Text = "Turn O"; counter--; } ButtonTwo.Enabled = false; checkit(); }
public void UpdateUi() { TextQuestion.text = oobject.text; imagecontaner.sprite = oobject.Bckground; if (oobject.Answers.Length > 0) { ButtonOne.SetActive(true); TextAnswerOne.text = oobject.Answers[0].TitelForAnswer; if (oobject.Answers.Length == 2) { ButtonTwo.SetActive(true); TextAnswerTwo.text = oobject.Answers[1].TitelForAnswer; } else { ButtonTwo.SetActive(false); } } else { ButtonOne.SetActive(false); ButtonTwo.SetActive(false); } }
void ReleaseDesignerOutlets() { if (ViewLabel != null) { ViewLabel.Dispose(); ViewLabel = null; } if (ButtonZero != null) { ButtonZero.Dispose(); ButtonZero = null; } if (ButtonOne != null) { ButtonOne.Dispose(); ButtonOne = null; } if (ButtonTwo != null) { ButtonTwo.Dispose(); ButtonTwo = null; } if (ButtonThree != null) { ButtonThree.Dispose(); ButtonThree = null; } if (ButtonFour != null) { ButtonFour.Dispose(); ButtonFour = null; } if (ButtonFive != null) { ButtonFive.Dispose(); ButtonFive = null; } if (ButtonSix != null) { ButtonSix.Dispose(); ButtonSix = null; } if (ButtonSeven != null) { ButtonSeven.Dispose(); ButtonSeven = null; } if (ButtonEight != null) { ButtonEight.Dispose(); ButtonEight = null; } if (ButtonNine != null) { ButtonNine.Dispose(); ButtonNine = null; } if (ButtonPlus != null) { ButtonPlus.Dispose(); ButtonPlus = null; } if (ButtonMinus != null) { ButtonMinus.Dispose(); ButtonMinus = null; } if (ButtonMultiply != null) { ButtonMultiply.Dispose(); ButtonMultiply = null; } if (ButtonDivide != null) { ButtonDivide.Dispose(); ButtonDivide = null; } if (ButtonEquals != null) { ButtonEquals.Dispose(); ButtonEquals = null; } if (ButtonClear != null) { ButtonClear.Dispose(); ButtonClear = null; } }
void ReleaseDesignerOutlets() { if (ButtonEight != null) { ButtonEight.Dispose(); ButtonEight = null; } if (ButtonFive != null) { ButtonFive.Dispose(); ButtonFive = null; } if (ButtonFour != null) { ButtonFour.Dispose(); ButtonFour = null; } if (ButtonNine != null) { ButtonNine.Dispose(); ButtonNine = null; } if (ButtonOne != null) { ButtonOne.Dispose(); ButtonOne = null; } if (ButtonRestart != null) { ButtonRestart.Dispose(); ButtonRestart = null; } if (ButtonSeven != null) { ButtonSeven.Dispose(); ButtonSeven = null; } if (ButtonSix != null) { ButtonSix.Dispose(); ButtonSix = null; } if (ButtonThree != null) { ButtonThree.Dispose(); ButtonThree = null; } if (ButtonTwo != null) { ButtonTwo.Dispose(); ButtonTwo = null; } if (LabelTurn != null) { LabelTurn.Dispose(); LabelTurn = null; } if (LabelWinner != null) { LabelWinner.Dispose(); LabelWinner = null; } }
public void checkit() { //Check if tie if (!ButtonOne.Title(UIControlState.Normal).Equals("") && !ButtonTwo.Title(UIControlState.Normal).Equals("") && !ButtonThree.Title(UIControlState.Normal).Equals("") && !ButtonFour.Title(UIControlState.Normal).Equals("") && !ButtonFive.Title(UIControlState.Normal).Equals("") && !ButtonSix.Title(UIControlState.Normal).Equals("") && !ButtonSeven.Title(UIControlState.Normal).Equals("") && !ButtonEight.Title(UIControlState.Normal).Equals("") && !ButtonNine.Title(UIControlState.Normal).Equals("")) { LabelWinner.Text = "Tie"; } //Check diagonal for X if (!ButtonOne.Title(UIControlState.Normal).Equals("") || !ButtonFive.Title(UIControlState.Normal).Equals("") || !ButtonNine.Title(UIControlState.Normal).Equals("")) { if (ButtonOne.Title(UIControlState.Normal).Equals("X") && ButtonFive.Title(UIControlState.Normal).Equals("X") && ButtonNine.Title(UIControlState.Normal).Equals("X")) { LabelWinner.Text = "Player X wins"; ButtonOne.Enabled = false; ButtonTwo.Enabled = false; ButtonThree.Enabled = false; ButtonFour.Enabled = false; ButtonFive.Enabled = false; ButtonSix.Enabled = false; ButtonSeven.Enabled = false; ButtonEight.Enabled = false; ButtonNine.Enabled = false; } } if (!ButtonThree.Title(UIControlState.Normal).Equals("") || !ButtonFive.Title(UIControlState.Normal).Equals("") || !ButtonSeven.Title(UIControlState.Normal).Equals("")) { if (ButtonThree.Title(UIControlState.Normal).Equals("X") && ButtonFive.Title(UIControlState.Normal).Equals("X") && ButtonSeven.Title(UIControlState.Normal).Equals("X")) { LabelWinner.Text = "Player X wins"; ButtonOne.Enabled = false; ButtonTwo.Enabled = false; ButtonThree.Enabled = false; ButtonFour.Enabled = false; ButtonFive.Enabled = false; ButtonSix.Enabled = false; ButtonSeven.Enabled = false; ButtonEight.Enabled = false; ButtonNine.Enabled = false; } } //Check rows for X if (!ButtonOne.Title(UIControlState.Normal).Equals("") || !ButtonTwo.Title(UIControlState.Normal).Equals("") || !ButtonThree.Title(UIControlState.Normal).Equals("")) { if (ButtonOne.Title(UIControlState.Normal).Equals("X") && ButtonTwo.Title(UIControlState.Normal).Equals("X") && ButtonThree.Title(UIControlState.Normal).Equals("X")) { LabelWinner.Text = "Player X wins"; ButtonOne.Enabled = false; ButtonTwo.Enabled = false; ButtonThree.Enabled = false; ButtonFour.Enabled = false; ButtonFive.Enabled = false; ButtonSix.Enabled = false; ButtonSeven.Enabled = false; ButtonEight.Enabled = false; ButtonNine.Enabled = false; } } if (!ButtonFour.Title(UIControlState.Normal).Equals("") || !ButtonFive.Title(UIControlState.Normal).Equals("") || !ButtonSix.Title(UIControlState.Normal).Equals("")) { if (ButtonFour.Title(UIControlState.Normal).Equals("X") && ButtonFive.Title(UIControlState.Normal).Equals("X") && ButtonSix.Title(UIControlState.Normal).Equals("X")) { LabelWinner.Text = "Player X wins"; ButtonOne.Enabled = false; ButtonTwo.Enabled = false; ButtonThree.Enabled = false; ButtonFour.Enabled = false; ButtonFive.Enabled = false; ButtonSix.Enabled = false; ButtonSeven.Enabled = false; ButtonEight.Enabled = false; ButtonNine.Enabled = false; } } if (!ButtonSeven.Title(UIControlState.Normal).Equals("") || !ButtonEight.Title(UIControlState.Normal).Equals("") || !ButtonNine.Title(UIControlState.Normal).Equals("")) { if (ButtonSeven.Title(UIControlState.Normal).Equals("X") && ButtonEight.Title(UIControlState.Normal).Equals("X") && ButtonNine.Title(UIControlState.Normal).Equals("X")) { LabelWinner.Text = "Player X wins"; ButtonOne.Enabled = false; ButtonTwo.Enabled = false; ButtonThree.Enabled = false; ButtonFour.Enabled = false; ButtonFive.Enabled = false; ButtonSix.Enabled = false; ButtonSeven.Enabled = false; ButtonEight.Enabled = false; ButtonNine.Enabled = false; } } //Check columns for X if (!ButtonOne.Title(UIControlState.Normal).Equals("") || !ButtonFour.Title(UIControlState.Normal).Equals("") || !ButtonSeven.Title(UIControlState.Normal).Equals("")) { if (ButtonOne.Title(UIControlState.Normal).Equals("X") && ButtonFour.Title(UIControlState.Normal).Equals("X") && ButtonSeven.Title(UIControlState.Normal).Equals("X")) { LabelWinner.Text = "Player X wins"; ButtonOne.Enabled = false; ButtonTwo.Enabled = false; ButtonThree.Enabled = false; ButtonFour.Enabled = false; ButtonFive.Enabled = false; ButtonSix.Enabled = false; ButtonSeven.Enabled = false; ButtonEight.Enabled = false; ButtonNine.Enabled = false; } } if (!ButtonTwo.Title(UIControlState.Normal).Equals("") || !ButtonFive.Title(UIControlState.Normal).Equals("") || !ButtonEight.Title(UIControlState.Normal).Equals("")) { if (ButtonTwo.Title(UIControlState.Normal).Equals("X") && ButtonFive.Title(UIControlState.Normal).Equals("X") && ButtonEight.Title(UIControlState.Normal).Equals("X")) { LabelWinner.Text = "Player X wins"; ButtonOne.Enabled = false; ButtonTwo.Enabled = false; ButtonThree.Enabled = false; ButtonFour.Enabled = false; ButtonFive.Enabled = false; ButtonSix.Enabled = false; ButtonSeven.Enabled = false; ButtonEight.Enabled = false; ButtonNine.Enabled = false; } } if (!ButtonThree.Title(UIControlState.Normal).Equals("") || !ButtonSix.Title(UIControlState.Normal).Equals("") || !ButtonNine.Title(UIControlState.Normal).Equals("")) { if (ButtonThree.Title(UIControlState.Normal).Equals("X") && ButtonSix.Title(UIControlState.Normal).Equals("X") && ButtonNine.Title(UIControlState.Normal).Equals("X")) { LabelWinner.Text = "Player X wins"; ButtonOne.Enabled = false; ButtonTwo.Enabled = false; ButtonThree.Enabled = false; ButtonFour.Enabled = false; ButtonFive.Enabled = false; ButtonSix.Enabled = false; ButtonSeven.Enabled = false; ButtonEight.Enabled = false; ButtonNine.Enabled = false; } } //Check diagonal for O if (!ButtonOne.Title(UIControlState.Normal).Equals("") || !ButtonFive.Title(UIControlState.Normal).Equals("") || !ButtonNine.Title(UIControlState.Normal).Equals("")) { if (ButtonOne.Title(UIControlState.Normal).Equals("O") && ButtonFive.Title(UIControlState.Normal).Equals("O") && ButtonNine.Title(UIControlState.Normal).Equals("O")) { LabelWinner.Text = "Player O wins"; ButtonOne.Enabled = false; ButtonTwo.Enabled = false; ButtonThree.Enabled = false; ButtonFour.Enabled = false; ButtonFive.Enabled = false; ButtonSix.Enabled = false; ButtonSeven.Enabled = false; ButtonEight.Enabled = false; ButtonNine.Enabled = false; } } if (!ButtonThree.Title(UIControlState.Normal).Equals("") || !ButtonFive.Title(UIControlState.Normal).Equals("") || !ButtonSeven.Title(UIControlState.Normal).Equals("")) { if (ButtonThree.Title(UIControlState.Normal).Equals("O") && ButtonFive.Title(UIControlState.Normal).Equals("O") && ButtonSeven.Title(UIControlState.Normal).Equals("O")) { LabelWinner.Text = "Player O wins"; ButtonOne.Enabled = false; ButtonTwo.Enabled = false; ButtonThree.Enabled = false; ButtonFour.Enabled = false; ButtonFive.Enabled = false; ButtonSix.Enabled = false; ButtonSeven.Enabled = false; ButtonEight.Enabled = false; ButtonNine.Enabled = false; } } //Check rows for O if (!ButtonOne.Title(UIControlState.Normal).Equals("") || !ButtonTwo.Title(UIControlState.Normal).Equals("") || !ButtonThree.Title(UIControlState.Normal).Equals("")) { if (ButtonOne.Title(UIControlState.Normal).Equals("O") && ButtonTwo.Title(UIControlState.Normal).Equals("O") && ButtonThree.Title(UIControlState.Normal).Equals("O")) { LabelWinner.Text = "Player O wins"; ButtonOne.Enabled = false; ButtonTwo.Enabled = false; ButtonThree.Enabled = false; ButtonFour.Enabled = false; ButtonFive.Enabled = false; ButtonSix.Enabled = false; ButtonSeven.Enabled = false; ButtonEight.Enabled = false; ButtonNine.Enabled = false; } } if (!ButtonFour.Title(UIControlState.Normal).Equals("") || !ButtonFive.Title(UIControlState.Normal).Equals("") || !ButtonSix.Title(UIControlState.Normal).Equals("")) { if (ButtonFour.Title(UIControlState.Normal).Equals("O") && ButtonFive.Title(UIControlState.Normal).Equals("O") && ButtonSix.Title(UIControlState.Normal).Equals("O")) { LabelWinner.Text = "Player O wins"; ButtonOne.Enabled = false; ButtonTwo.Enabled = false; ButtonThree.Enabled = false; ButtonFour.Enabled = false; ButtonFive.Enabled = false; ButtonSix.Enabled = false; ButtonSeven.Enabled = false; ButtonEight.Enabled = false; ButtonNine.Enabled = false; } } if (!ButtonSeven.Title(UIControlState.Normal).Equals("") || !ButtonEight.Title(UIControlState.Normal).Equals("") || !ButtonNine.Title(UIControlState.Normal).Equals("")) { if (ButtonSeven.Title(UIControlState.Normal).Equals("O") && ButtonEight.Title(UIControlState.Normal).Equals("O") && ButtonNine.Title(UIControlState.Normal).Equals("O")) { LabelWinner.Text = "Player O wins"; ButtonOne.Enabled = false; ButtonTwo.Enabled = false; ButtonThree.Enabled = false; ButtonFour.Enabled = false; ButtonFive.Enabled = false; ButtonSix.Enabled = false; ButtonSeven.Enabled = false; ButtonEight.Enabled = false; ButtonNine.Enabled = false; } } //Check columns for O if (!ButtonOne.Title(UIControlState.Normal).Equals("") || !ButtonFour.Title(UIControlState.Normal).Equals("") || !ButtonSeven.Title(UIControlState.Normal).Equals("")) { if (ButtonOne.Title(UIControlState.Normal).Equals("O") && ButtonFour.Title(UIControlState.Normal).Equals("O") && ButtonSeven.Title(UIControlState.Normal).Equals("O")) { LabelWinner.Text = "Player O wins"; ButtonOne.Enabled = false; ButtonTwo.Enabled = false; ButtonThree.Enabled = false; ButtonFour.Enabled = false; ButtonFive.Enabled = false; ButtonSix.Enabled = false; ButtonSeven.Enabled = false; ButtonEight.Enabled = false; ButtonNine.Enabled = false; } } if (!ButtonTwo.Title(UIControlState.Normal).Equals("") || !ButtonFive.Title(UIControlState.Normal).Equals("") || !ButtonEight.Title(UIControlState.Normal).Equals("")) { if (ButtonTwo.Title(UIControlState.Normal).Equals("O") && ButtonFive.Title(UIControlState.Normal).Equals("O") && ButtonEight.Title(UIControlState.Normal).Equals("O")) { LabelWinner.Text = "Player O wins"; ButtonOne.Enabled = false; ButtonTwo.Enabled = false; ButtonThree.Enabled = false; ButtonFour.Enabled = false; ButtonFive.Enabled = false; ButtonSix.Enabled = false; ButtonSeven.Enabled = false; ButtonEight.Enabled = false; ButtonNine.Enabled = false; } } if (!ButtonThree.Title(UIControlState.Normal).Equals("") || !ButtonSix.Title(UIControlState.Normal).Equals("") || !ButtonNine.Title(UIControlState.Normal).Equals("")) { if (ButtonThree.Title(UIControlState.Normal).Equals("O") && ButtonSix.Title(UIControlState.Normal).Equals("O") && ButtonNine.Title(UIControlState.Normal).Equals("O")) { LabelWinner.Text = "Player O wins"; ButtonOne.Enabled = false; ButtonTwo.Enabled = false; ButtonThree.Enabled = false; ButtonFour.Enabled = false; ButtonFive.Enabled = false; ButtonSix.Enabled = false; ButtonSeven.Enabled = false; ButtonEight.Enabled = false; ButtonNine.Enabled = false; } } }