Exemple #1
0
 public void Reset()
 {
     FirstNumber     = null;
     SecondNumber    = null;
     OperationButton = null;
     Result          = null;
 }
Exemple #2
0
        partial void OnButtonPressDivide()
        {
            OperationButton button = new OperationButton {
                Operation = Calculator.Operation.Divide, Button = btnDivide
            };

            OnButtonPress(button);
        }
Exemple #3
0
        partial void OnButtonPressMultiply()
        {
            OperationButton button = new OperationButton {
                Operation = Calculator.Operation.Multiply, Button = btnMultiply
            };

            OnButtonPress(button);
        }
Exemple #4
0
        partial void OnButtonPressSubtract()
        {
            OperationButton button = new OperationButton {
                Operation = Calculator.Operation.Subtract, Button = btnSubtract
            };

            OnButtonPress(button);
        }
Exemple #5
0
        partial void OnButtonPressAdd()
        {
            OperationButton button = new OperationButton {
                Operation = Calculator.Operation.Add, Button = btnAdd
            };

            OnButtonPress(button);
        }
Exemple #6
0
    private void SetInputOperation(OperationButton operationButton)
    {
        if (!string.IsNullOrEmpty(_inputValue.Result))
        {
            _inputValue.FirstNumber  = _inputValue.Result;
            _inputValue.SecondNumber = null;
            _inputValue.Result       = null;
        }

        if (!string.IsNullOrEmpty(_inputValue.FirstNumber))
        {
            _inputValue.OperationButton = operationButton;
        }

        DrawValue();
    }
    // Start is called before the first frame update
    void Start()
    {
        playingField = GameObject.Find("Plane");

        /*if(playingField != null)
         * {
         *  Debug.Log("we found a playingfield");
         * }
         * else
         * {
         *  Debug.Log("no playingfield found!");
         * }*/
        additionButtonScript       = GameObject.Find("Addition").GetComponent <OperationButton>();
        multiplicationButtonScript = GameObject.Find("Multiplication").GetComponent <OperationButton>();
        allOperationButtons.Add(additionButtonScript);
        allOperationButtons.Add(multiplicationButtonScript);
        this.curOperator = additionButtonScript;
        // make a mask for the raycast so that it doesn't hit the playfield
        //  layermasks are confusing. Check this out: https://answers.unity.com/questions/8715/how-do-i-use-layermasks.html
        // this absolute LAD helped so much https://answers.unity.com/questions/1164722/raycast-ignore-layers-except.html

        /*
         * Debug.Log("defaultMask set to: " + defaultMask);
         * Debug.Log("PFMask set to: " + PFMask);
         */
        levelManager = levelManagerObject.GetComponent <LevelManager>();

        /*
         * if (levelManager != null)
         * {
         *  Debug.Log("levelManager assigned");
         * }
         */
        levelManager.setAdditionButton(additionButtonScript.gameObject);
        levelManager.setMultiplicationButton(multiplicationButtonScript.gameObject);
        levelManager.LoadLevel(0);
        levelManager.LoadLevel(StaticDataTracker.curLevel);
        isMouseDragging = false;
        foreach (OperationButton button in allOperationButtons)
        {
            button.UpdateDisplay();
        }
        levelDisplayText.GetComponent <LevelTextDisplay>().UpdateDisplay();
    }
Exemple #8
0
        // ****************************************
        // *** operation button press (+, -, * , /)
        // ****************************************
        private void OnButtonPress(OperationButton button)
        {
            WKInterfaceDevice.CurrentDevice.PlayHaptic(WKHapticType.Click);
            calculator.Function = Calculator.Function.None;

            try
            {
                calculator.Operation = button.Operation;

                if (calculator.Operand1 != null)
                {
                    calculator.Operand2 = Convert.ToDouble(CalculatorText);
                    calculator.Calculate();
                    calculator.Operand1 = calculator.TotalSum;
                }
                else
                {
                    var isNumeric = double.TryParse(CalculatorText, out double number);
                    if (isNumeric)
                    {
                        calculator.Operand1 = number;
                        CalculatorText      = string.Empty;
                    }
                }
            }
            catch (Exception)
            {
                WriteTextToScreen("Operation Error");
            }
            finally
            {
                SetButtonColors();
                //button.Button.SetBackgroundColor(button.PressedColor);
                button.Button.SetBackgroundColor(UIColor.Gray);
            }
        }
 public void OnOperationButtonPress(OperationButton operation)
 {
     this.curOperator = operation;
     //Debug.Log("The operation is now: " + curOperator.myName);
 }