/// <summary> /// When the user interface input signal. /// </summary> /// <param name="aUIInputType">A user interface input type.</param> private void _onUIInputChangedSignal (UIInputVO aUIInputVO) { //WE CARE ONLY ABOUT INPUT 'ENTER' (NOT 'EXIT' OR 'STAY') if (aUIInputVO.uiInputEventType == UIInputEventType.DownEnter) { //Debug.Log("MED.uichanged: " + aUIInputVO.keyCode + " , " + UIInputEventType.DownEnter); //1. SOUND ONLY if (aUIInputVO.keyCode == KeyCode.KeypadEnter) { soundPlaySignal.Dispatch (new SoundPlayVO (SoundType.GAME_OVER_WIN)); } else { soundPlaySignal.Dispatch (new SoundPlayVO (SoundType.BUTTON_CLICK)); } //2. ACTIONS ONLY switch (aUIInputVO.keyCode){ //************************************ // // OPERANDS // //************************************ case KeyCode.Alpha0: case KeyCode.Alpha1: case KeyCode.Alpha2: case KeyCode.Alpha3: case KeyCode.Alpha4: case KeyCode.Alpha5: case KeyCode.Alpha6: case KeyCode.Alpha7: case KeyCode.Alpha8: case KeyCode.Alpha9: enterInstructionSignal.Dispatch ( new OperandInstruction(aUIInputVO.keyCode)); break; //************************************ // // OPERATOR // //************************************ case KeyCode.KeypadMultiply: case KeyCode.KeypadDivide: case KeyCode.KeypadPlus: case KeyCode.KeypadMinus: case KeyCode.KeypadPeriod: enterInstructionSignal.Dispatch ( new DecimalOperatorInstruction (aUIInputVO.keyCode)); break; case KeyCode.KeypadEnter: enterInstructionSignal.Dispatch ( new EnterOperatorInstruction (aUIInputVO.keyCode)); break; case KeyCode.L: enterInstructionSignal.Dispatch ( new LogOperatorInstruction (aUIInputVO.keyCode)); break; case KeyCode.Delete: enterInstructionSignal.Dispatch ( new ClearOperatorInstruction (aUIInputVO.keyCode)); break; //************************************ // // SPECIAL // //************************************ case KeyCode.R: gameResetSignal.Dispatch (); break; case KeyCode.M: //TOOGLE BASED ON CURRENT VALUE if (iScientificCalculatorModel.calculatorMode == CalculatorMode.LinearEquations) { calculatorModelChangeSignal.Dispatch (CalculatorMode.Scientific); } else { calculatorModelChangeSignal.Dispatch (CalculatorMode.LinearEquations); } break; default: //NOTHING break; } } }
// PUBLIC STATIC // PRIVATE /// <summary> /// Do update user interface input. /// /// NOTE: We get DownEnter and DownExit /// /// NOTE: We interpolate and SOMETIMES send DownStay using _doProcessDownStayEvents /// /// /// </summary> /// <param name="aKeyCode">A key code.</param> /// <param name="aUIInputEventType">A user interface input event type.</param> protected void _doUpdateUIInput (KeyCode aKeyCode, UIInputEventType aUIInputEventType ) { //CHECK OLD DATA UIInputVO newToSendUIInputVO = new UIInputVO (aKeyCode, aUIInputEventType); //STORE *ONLY* MOST RECENT PER KEYCODE _lastInputVOByKeycode_dictionary[newToSendUIInputVO.keyCode] = (newToSendUIInputVO); //ALWAYS SEND uiInputChangedSignal.Dispatch (newToSendUIInputVO); }