Esempio n. 1
0
 private void UpdateMirrorsLayout()
 {
     foreach (MirrorView mirrorView in _mirrors)
     {
         Mirror mirror = (Mirror)mirrorView.DataContext;
         mirrorView.Margin =
             new Thickness(mirror.Position.Row * BlackboxConfig.BoxWidth,
                           mirror.Position.Column * BlackboxConfig.BoxHeight, 0, 0);
     }
 }
Esempio n. 2
0
 private void CreateMirrors()
 {
     for (int i = 0; i < _model.Mirrors.Count; i++)
     {
         Mirror     mirror     = _model.Mirrors[i];
         MirrorView mirrorView = new MirrorView();
         mirrorView.HorizontalAlignment = HorizontalAlignment.Left;
         mirrorView.VerticalAlignment   = VerticalAlignment.Top;
         mirrorView.Width  = BlackboxConfig.BoxWidth;
         mirrorView.Height = BlackboxConfig.BoxHeight;
         mirrorView.Margin =
             new Thickness(mirror.Position.Row * BlackboxConfig.BoxWidth,
                           mirror.Position.Column * BlackboxConfig.BoxHeight, 0, 0);
         mirrorView.DataContext = mirror;
         Binding binding = new Binding();
         binding.Source = mirror;
         binding.Path   = new PropertyPath("Guessed");
         binding.Mode   = BindingMode.OneWay;
         mirrorView.SetBinding(MirrorView.StateValueProperty, binding);
         this._mirrors.Add(mirrorView);
         this.LayoutRoot.Children.Add(mirrorView);
     }
 }
Esempio n. 3
0
        public void DoGuess()
        {
            _layoutGuess = false;

            int mirrorNumber        = App.Settings.MirrorNumber;
            int guessedMirrorNumber = 0;

            for (int i = 1; i < BlackboxConfig.GameBoardRow - 1; i++)
            {
                for (int j = 1; j < BlackboxConfig.GameBoardColumn - 1; j++)
                {
                    Box box = _boxes[i, j];

                    if (App.Settings.GuessType == GuessType.AllAtTime)
                    {
                        if (box.State == BlackBox.GuessingState)
                        {
                            Mirror mirror = Mirror(i, j);
                            if (mirror != null)
                            {
                                _layoutGuess   = true;
                                mirror.Guessed = true;
                                box.State      = BlackBox.GuessedState;
                                UpdateState(ModelState.GuessSuccess);
                            }
                            else
                            {
                                _layoutGuess = false;
                                box.State    = BlackBox.GuessFailedState;
                                UpdateState(ModelState.GuessFailed);
                            }
                            //break;
                        }

                        if (box.State == BlackBox.GuessedState)
                        {
                            ++guessedMirrorNumber;
                            if (guessedMirrorNumber == App.Settings.MirrorNumber)
                            {
                                _layoutGuess = true;
                                UpdateState(ModelState.GameOver);
                            }
                        }
                    }
                    else // all at once
                    {
                        if (box.State == BlackBox.GuessingState)
                        {
                            if (Mirror(i, j) != null)
                            {
                                --mirrorNumber;
                            }
                        }
                    }
                }
            }

            if (App.Settings.GuessType == GuessType.AllAtOnce)
            {
                if (mirrorNumber == 0)
                {
                    foreach (Mirror mirror in _mirrorList)
                    {
                        mirror.Guessed = true;
                    }

                    UpdateState(ModelState.GameOver);
                }
                else
                {
                    int guessedNum = App.Settings.MirrorNumber - mirrorNumber;
                    UpdateState(ModelState.GuessFailed, guessedNum.ToString());

                    //RemoveAllGuess();
                }
            }
        }