private void InitLogic() { for (var i = 0; i < 3; i++) { this.buttons[i] = new LogicalButton(i, Constants.ButtonColors[rnd.Range(0, 9)], Constants.WordStrings[rnd.Range(0, 9)]); } //// Debuging purposes //this.buttons[0] = new LogicalButton(0, ButtonColor.Orange, Constants.ColorString); //this.buttons[1] = new LogicalButton(1, ButtonColor.Grey, Constants.LogicString); //this.buttons[2] = new LogicalButton(2, ButtonColor.Grey, Constants.LogicString); //this.gateOperator = LogicalGateOperatorFactory.Create(Constants.XorOperatorString); //this.stage = 3; this.pressCount = 0; this.gateOperator = LogicalGateOperatorFactory.Create(Constants.GateStrings[rnd.Range(0, 6)]); this.helper = new LogicalButtonsHelper(this.buttons, this.gateOperator); this.solution = this.helper.SolveOrder(this.stage); OperatorTxt.text = this.gateOperator.Name; Btn1Text.text = buttons[0].Label; Btn2Text.text = buttons[1].Label; Btn3Text.text = buttons[2].Label; Btn1Renderer.sharedMaterial = materials[Constants.ButtonColors.IndexOf(buttons[0].Color)]; Btn2Renderer.sharedMaterial = materials[Constants.ButtonColors.IndexOf(buttons[1].Color)]; Btn3Renderer.sharedMaterial = materials[Constants.ButtonColors.IndexOf(buttons[2].Color)]; Debug.LogFormat("[Logical Buttons #{0}] STAGE: {1}", this._moduleId, this.stage); this.DebugMessage(); ColorBlindIndicatorTop.text = buttons[0].Color.ToString(); ColorBlindIndicatorLeft.text = buttons[1].Color.ToString(); ColorBlindIndicatorRight.text = buttons[2].Color.ToString(); }
private static ILogicalGateOperator ChangeLogicalGateOperator(ILogicalGateOperator currentOperator) { var newOperator = LogicalGateOperatorFactory.Create(Constants.GateStrings[rnd.Range(0, 6)]); while (currentOperator.Name == newOperator.Name) { newOperator = LogicalGateOperatorFactory.Create(Constants.GateStrings[rnd.Range(0, 6)]); } return(newOperator); }
private void InitButtons() { Btn1.OnInteract += delegate { Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, Btn1.transform); Btn1.AddInteractionPunch(.1f); Btn1.GetComponentInParent <Animator>().Play("ButtonPress"); if (this.isSolved) { return(false); } if (!this.HasSolution) { this.HandleButtonPressWithNoSolution(this.buttons[0]); } else { this.CheckSolution(this.buttons[0]); } return(false); }; Btn2.OnInteract += delegate { Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, Btn1.transform); Btn2.AddInteractionPunch(.1f); Btn2.GetComponentInParent <Animator>().Play("ButtonPress"); if (this.isSolved) { return(false); } if (!this.HasSolution) { this.HandleButtonPressWithNoSolution(this.buttons[1]); } else { this.CheckSolution(this.buttons[1]); } return(false); }; Btn3.OnInteract += delegate { Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, Btn1.transform); Btn3.AddInteractionPunch(.1f); Btn3.GetComponentInParent <Animator>().Play("ButtonPress"); if (this.isSolved) { return(false); } if (!this.HasSolution) { this.HandleButtonPressWithNoSolution(this.buttons[2]); } else { this.CheckSolution(this.buttons[2]); } return(false); }; Btn1.OnInteractEnded += delegate { Btn1.GetComponentInParent <Animator>().Play("ButtonRelease"); Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.BigButtonPress, Btn1.transform); }; Btn2.OnInteractEnded += delegate { Btn2.GetComponentInParent <Animator>().Play("ButtonRelease"); Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.BigButtonPress, Btn2.transform); }; Btn3.OnInteractEnded += delegate { Btn3.GetComponentInParent <Animator>().Play("ButtonRelease"); Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.BigButtonPress, Btn3.transform); }; ScreenBtn.OnInteract += delegate { if (this.isSolved) { Btn1.AddInteractionPunch(); Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, Btn1.transform); return(false); } ScreenBtn.AddInteractionPunch(.5f); Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, ScreenBtn.transform); if (this.HasSolution) { Debug.LogFormat("[Logical Buttons #{0}] Pressed the operator screen while had solution. Strike!", this._moduleId); Module.HandleStrike(); this.InitLogic(); } else { this.gateOperator = ChangeLogicalGateOperator(this.gateOperator); this.helper = new LogicalButtonsHelper(this.buttons, this.gateOperator); this.solution = this.helper.SolveOrder(this.stage); OperatorTxt.text = this.gateOperator.Name; Debug.LogFormat("[Logical Buttons #{0}] Pressing operator button, new answer is:", _moduleId); this.DebugMessage(); } return(false); }; }
public LogicalButtonsHelper(LogicalButton[] buttons, ILogicalGateOperator gateOperator) { this.buttons = buttons; this.gateOperator = gateOperator; }