private void StartOver()
        {
            EnteredNumbers.Clear();
            _attemptNumber = 1;

            UserNumber    = new UserNumber(1, 2, 3, 4);
            _randomNumber = new RandomNumber();
            OnAllPropertyChanged();
        }
    public override void OnDrag(Vector2 pos)
    {
        InvokeOnCursorPositionChanged(Util.PixelToCanvas(pos));

        var cellOrNull = NearestGridCell(pos);

        if (cellOrNull == null)
        {
            return;
        }

        var cell = (int)cellOrNull;

        if (!EnteredNumbers.Contains(cell))
        {
            EnteredNumbers.Add(cell);
            InvokeOnEnteredNumbersChanged();
        }
    }
        private void EnterNumber()
        {
            EnteredNumbers.Add(new EnteredNumber(_randomNumber, UserNumber)
            {
                AttemptNumber = _attemptNumber
            });

            if (_randomNumber.Value == UserNumber.Value)
            {
                MessageBoxResult Result = MessageBox.Show("Вы выиграли. Загаданное число : "
                                                          + _randomNumber.Value +
                                                          "\n Начать игру заново?", "Победа!", MessageBoxButton.YesNo);
                if (Result == MessageBoxResult.Yes)
                {
                    StartOver();
                }
                else if (Result == MessageBoxResult.No)
                {
                    Application.Current.Shutdown();
                }
            }

            if (_attemptNumber == 7)
            {
                MessageBoxResult Result = MessageBox.Show("Вы проиграли. Загаданное число : "
                                                          + _randomNumber.Value +
                                                          "\n Начать игру заново?", "Проигрыш.", MessageBoxButton.YesNo);
                if (Result == MessageBoxResult.Yes)
                {
                    StartOver();
                }
                else if (Result == MessageBoxResult.No)
                {
                    Application.Current.Shutdown();
                }
            }

            _attemptNumber++;
        }
 // FIXME TODO eventually auto clear on finish rather than this
 public override void OnBeginDrag()
 {
     EnteredNumbers.Clear();
 }
    void Update()
    {
        if (!Enabled)
        {
            return;
        }


        LoggingClass.AppendToLog(
            LoggingClass.VICON,
            localCoordThing.posn.x, localCoordThing.posn.y, localCoordThing.posn.z,
            null, null);

        //
        // Calculate cursor position
        //
        var viconPos3D        = localCoordThing.posn;
        var viconPos2D        = new Vector2(viconPos3D.x, viconPos3D.y);
        var depthOffsetScalar = (viconPos3D.z - Pattern3DSharedData.minScreenZ) / Pattern3DSharedData.spacingZ;
        var depthOffsetVector = depthOffsetScalar * Pattern3DSharedData.spacingProjDepth * new Vector2(1, -1);
        var viconPosProj      = viconPos2D + depthOffsetVector;

        // FIXME TODO need new event for cursor size/color
        //textThing.text = pk.ToString();

        InvokeOnCursorPositionChanged(Util.PixelToCanvas(viconPosProj));

        // 0.5 offset to account for fact that depth offset marks
        // *boundary* of depths.
        var   depthOffsetRounded = (int)(depthOffsetScalar + 0.5f);
        Depth depth;

        switch (depthOffsetRounded)
        {
        case 0: depth = Depth.Close; break;

        case 1: depth = Depth.Middle; break;

        case 2: depth = Depth.Far; break;

        default: depth = Depth.Inactive; break;
        }

        InvokeOnCursorDepthChanged(depth);

        //
        // Calculate pin
        //
        var cellOrNull = NearestGridCell3D(localCoordThing.posn);

        if (cellOrNull == null)
        {
            return;
        }

        var gc = (int)cellOrNull;

        if (!EnteredNumbers.Contains(gc))
        {
            EnteredNumbers.Add(gc);
            InvokeOnEnteredNumbersChanged();
        }
    }
Beispiel #6
0
 public override void OnButtonPress(string text)
 {
     EnteredNumbers.Add(int.Parse(text));
     InvokeOnEnteredNumbersChanged();
 }
 protected void InvokeOnEnteredNumbersChanged()
 {
     OnEnteredNumbersChanged?.Invoke(EnteredNumbers.ToArray());
 }
 public void ResetEnteredNumbers()
 {
     EnteredNumbers.Clear();
 }