private void Awake() { PieceSprites = new Dictionary <Piece.PieceType, Sprite>(); squareLookup = new List <List <List <Image> > >(); GameObject[] boards = GameObject.FindGameObjectsWithTag("Board"); //initialize space structure with nulls squareLookup = new List <List <List <Image> > >(); for (int i = 0; i < game.gameBoard.numberLevels; i++) { squareLookup.Add(new List <List <Image> >()); for (int j = 0; j < game.gameBoard.GridTemplate.rows; j++) { squareLookup[i].Add(new List <Image>()); for (int k = 0; k < game.gameBoard.GridTemplate.cols; k++) { squareLookup[i][j].Add(null); } } } //iterate through potentially unordered game objects and add to the space structure foreach (GameObject board in boards) { int boardNumber = Int32.Parse(board.name.Substring(board.name.Length - 1)); Image[] images = board.GetComponentsInChildren <Image>(); foreach (Image img in images) { if (img.name.Substring(0, 7) == "Square_") { int squareNumber = Int32.Parse(img.name.Substring(img.name.Length - 1)); int rowNumber = Int32.Parse(img.rectTransform.parent.name.Substring(img.rectTransform.parent.name.Length - 1)); squareLookup[boardNumber][rowNumber][squareNumber] = img; SquareButton sb = img.gameObject.AddComponent <SquareButton>(); sb.level = boardNumber; sb.row = rowNumber; sb.col = squareNumber; Button b = img.GetComponent <Button>(); Navigation n = b.navigation; n.mode = Navigation.Mode.None; b.navigation = n; b.onClick.AddListener(() => SquareClickEvent(boardNumber, rowNumber, squareNumber)); } } } }
public void SquareButton_Test() { var squareButtonModule = new SquareButton(); Assert.AreEqual("Just press it.", squareButtonModule.Command(bomb, "square button yellow elevate"), "Error Test #1", null); squareButtonModule = new SquareButton(); Assert.AreEqual("Hold the button. What is the LED color?", squareButtonModule.Command(bomb, "square button blue detonate"), "Error Test #4", null); Assert.AreEqual("Release when the seconds add up to three or thirteen.", squareButtonModule.Command(bomb, "square button led orange"), "Error Test #7", null); }
public Button CreateItemControl(IGroupContentItem item, int column, int row) { var itemControl = new SquareButton(item.Background) { Content = item.Title, Height = 42, MinWidth = 170, FontSize = 14, Margin = new Thickness(2), HorizontalAlignment = HorizontalAlignment.Stretch, Foreground = new SolidColorBrush { Color = item.Foreground.ToMediaColor() } }; itemControl.Click += delegate { if (_entity.IsSub && !item.IsFinal) { return; } _entity.SelectedItem = item; var binding = _entity.GetBindingExpression(GroupContentGrid.SelectedItemProperty); if (binding != null) { binding.UpdateSource(); } }; Grid.SetColumn(itemControl, column); Grid.SetRow(itemControl, row); return(itemControl); }
public void HandleInputs() { GameObject.Find("Prompt").GetComponent <Text>().text = ""; //perform action linked to x button if (ControllerPluginWrapper.GetButtonDown(0, 0)) { if ((XButton.getCommand() != "DoNothing") && (XButton.getCommand() != "Jump") && (XButton.getCommand() != "UndoButton") && (XButton.getCommand() != "RemapButton")) { inputs.Push(XButton); } cooldown = maxCD; XButton.Execute(player, inputs.Peek()); if (XButton.getCommand() == "UndoButton") { inputs.Pop(); } else if (XButton.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to circle button else if (ControllerPluginWrapper.GetButtonDown(0, 1)) { if ((CircleButton.getCommand() != "DoNothing") && (CircleButton.getCommand() != "Jump") && (CircleButton.getCommand() != "UndoButton") && (CircleButton.getCommand() != "RemapButton")) { inputs.Push(CircleButton); } cooldown = maxCD; CircleButton.Execute(player, inputs.Peek()); if (CircleButton.getCommand() == "UndoButton") { inputs.Pop(); } else if (CircleButton.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to square button else if (ControllerPluginWrapper.GetButtonDown(0, 2)) { if ((SquareButton.getCommand() != "DoNothing") && (SquareButton.getCommand() != "Jump") && (SquareButton.getCommand() != "UndoButton") && (SquareButton.getCommand() != "RemapButton")) { inputs.Push(SquareButton); } cooldown = maxCD; SquareButton.Execute(player, inputs.Peek()); if (SquareButton.getCommand() == "UndoButton") { inputs.Pop(); } else if (SquareButton.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to triangle button else if (ControllerPluginWrapper.GetButtonDown(0, 3)) { if ((TriangleButton.getCommand() != "DoNothing") && (TriangleButton.getCommand() != "Jump") && (TriangleButton.getCommand() != "UndoButton") && (TriangleButton.getCommand() != "RemapButton")) { inputs.Push(TriangleButton); } cooldown = maxCD; TriangleButton.Execute(player, inputs.Peek()); if (TriangleButton.getCommand() == "UndoButton") { inputs.Pop(); } else if (TriangleButton.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to up on directional pad else if (ControllerPluginWrapper.GetButtonDown(0, 4)) { if ((DPadUp.getCommand() != "DoNothing") && (DPadUp.getCommand() != "Jump") && (DPadUp.getCommand() != "UndoButton") && (DPadUp.getCommand() != "RemapButton")) { inputs.Push(DPadUp); } cooldown = maxCD; DPadUp.Execute(player, inputs.Peek()); if (DPadUp.getCommand() == "UndoButton") { inputs.Pop(); } else if (DPadUp.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to down on directional pad else if (ControllerPluginWrapper.GetButtonDown(0, 5)) { if ((DPadDown.getCommand() != "DoNothing") && (DPadDown.getCommand() != "Jump") && (DPadDown.getCommand() != "UndoButton") && (DPadDown.getCommand() != "RemapButton")) { inputs.Push(DPadDown); } cooldown = maxCD; DPadDown.Execute(player, inputs.Peek()); if (DPadDown.getCommand() == "UndoButton") { inputs.Pop(); } else if (DPadDown.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to left on directional pad else if (ControllerPluginWrapper.GetButtonDown(0, 6)) { if ((DPadLeft.getCommand() != "DoNothing") && (DPadLeft.getCommand() != "Jump") && (DPadLeft.getCommand() != "UndoButton") && (DPadLeft.getCommand() != "RemapButton")) { inputs.Push(DPadLeft); } cooldown = maxCD; DPadLeft.Execute(player, inputs.Peek()); if (DPadLeft.getCommand() == "UndoButton") { inputs.Pop(); } else if (DPadLeft.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to right on directional pad else if (ControllerPluginWrapper.GetButtonDown(0, 7)) { if ((DPadRight.getCommand() != "DoNothing") && (DPadRight.getCommand() != "Jump") && (DPadRight.getCommand() != "UndoButton") && (DPadRight.getCommand() != "RemapButton")) { inputs.Push(DPadRight); } cooldown = maxCD; DPadRight.Execute(player, inputs.Peek()); if (DPadRight.getCommand() == "UndoButton") { inputs.Pop(); } else if (DPadRight.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to left bumper else if (ControllerPluginWrapper.GetButtonDown(0, 8)) { if ((L1.getCommand() != "DoNothing") && (L1.getCommand() != "Jump") && (L1.getCommand() != "UndoButton") && (L1.getCommand() != "RemapButton")) { inputs.Push(L1); } cooldown = maxCD; L1.Execute(player, inputs.Peek()); if (L1.getCommand() == "UndoButton") { inputs.Pop(); } else if (L1.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to right bumper else if (ControllerPluginWrapper.GetButtonDown(0, 9)) { if ((R1.getCommand() != "DoNothing") && (R1.getCommand() != "Jump") && (R1.getCommand() != "UndoButton") && (R1.getCommand() != "RemapButton")) { inputs.Push(R1); } cooldown = maxCD; R1.Execute(player, inputs.Peek()); if (R1.getCommand() == "UndoButton") { inputs.Pop(); } else if (R1.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to left stick pressed else if (ControllerPluginWrapper.GetButtonDown(0, 10)) { if ((LStickPress.getCommand() != "DoNothing") && (LStickPress.getCommand() != "Jump") && (LStickPress.getCommand() != "UndoButton") && (LStickPress.getCommand() != "RemapButton")) { inputs.Push(LStickPress); } cooldown = maxCD; LStickPress.Execute(player, inputs.Peek()); if (LStickPress.getCommand() == "UndoButton") { inputs.Pop(); } else if (LStickPress.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to right stick pressed else if (ControllerPluginWrapper.GetButtonDown(0, 11)) { if ((RStickPress.getCommand() != "DoNothing") && (RStickPress.getCommand() != "Jump") && (RStickPress.getCommand() != "UndoButton") && (RStickPress.getCommand() != "RemapButton")) { inputs.Push(RStickPress); } cooldown = maxCD; RStickPress.Execute(player, inputs.Peek()); if (RStickPress.getCommand() == "UndoButton") { inputs.Pop(); } else if (RStickPress.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to start button else if (ControllerPluginWrapper.GetButtonDown(0, 12)) { if ((Pause.getCommand() != "DoNothing") && (Pause.getCommand() != "Jump") && (Pause.getCommand() != "UndoButton") && (Pause.getCommand() != "RemapButton")) { inputs.Push(Pause); } cooldown = maxCD; Pause.Execute(player, inputs.Peek()); if (Pause.getCommand() == "UndoButton") { inputs.Pop(); } else if (Pause.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to back button else if (ControllerPluginWrapper.GetButtonDown(0, 13)) { if ((Select.getCommand() != "DoNothing") && (Select.getCommand() != "Jump") && (Select.getCommand() != "UndoButton") && (Select.getCommand() != "RemapButton")) { inputs.Push(Select); } cooldown = maxCD; Select.Execute(player, inputs.Peek()); if (Select.getCommand() == "UndoButton") { inputs.Pop(); } else if (Select.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to right trigger else if (ControllerPluginWrapper.RightTrigger(0) > 0.1f) { if ((RightTrigger.getCommand() != "DoNothing") && (RightTrigger.getCommand() != "Jump") && (RightTrigger.getCommand() != "UndoButton") && (RightTrigger.getCommand() != "RemapButton")) { inputs.Push(RightTrigger); } cooldown = maxCD; RightTrigger.Execute(player, inputs.Peek()); if (RightTrigger.getCommand() == "UndoButton") { inputs.Pop(); } else if (RightTrigger.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to left trigger else if (ControllerPluginWrapper.LeftTrigger(0) > 0.1f) { if ((LeftTrigger.getCommand() != "DoNothing") && (LeftTrigger.getCommand() != "Jump") && (LeftTrigger.getCommand() != "UndoButton") && (LeftTrigger.getCommand() != "RemapButton")) { inputs.Push(LeftTrigger); } cooldown = maxCD; LeftTrigger.Execute(player, inputs.Peek()); if (LeftTrigger.getCommand() == "UndoButton") { inputs.Pop(); } else if (LeftTrigger.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } }