Esempio n. 1
0
        public PlayingFieldViewModel()
        {
            CreatingCells();
            IdentifyNeighbours();

            playGameCommand    = new PlayGameCommand(PlayGame);
            pauseGameCommand   = new PauseGameCommand(PauseGame);
            restartGameCommand = new RestartGameCommand(RestartGame);
        }
Esempio n. 2
0
        private void Minefield_GameEnded(object sender, Minefield.GameEndedEventArgs e)
        {
            MessageBoxResult result;

            if (e.IsWon)
            {
                result = dialogService.Show(Loc.MainWindow_Message_GameWon_Text, Loc.MainWindow_Message_GameWon_Title, MessageBoxButton.YesNo, MessageBoxImage.Exclamation);
            }
            else
            {
                result = dialogService.Show(Loc.MainWindow_Message_GameLost_Text, Loc.MainWindow_Message_GameLost_Title, MessageBoxButton.YesNo, MessageBoxImage.Hand);
            }

            if (result == MessageBoxResult.No)
            {
                ExitApplicationCommand.Execute(null);
            }
            else if (result == MessageBoxResult.Yes)
            {
                RestartGameCommand.Execute(null);
            }
        }
    // Update is called once per frame
    void Update()
    {
        foreach (var item in keyMap.OnReleasedKeyMap)
        {
            if (Input.GetKeyUp(item.Key))
            {
                Debug.Log(string.Format("onReleasedKeyMap Key Released {0}", item.Value.ToString()));
                //Command command = null;
            }
        }

        foreach (var item in keyMap.OnKeyDownMap)
        {
            if (Input.GetKey(item.Key))
            {
                Command command = null;
                switch (item.Value)
                {
                case "OnlyAim":
                    command = new OnlyAimCommand();
                    break;
                }
                if (command != null)
                {
                    if (command is ICommand)
                    {
                        Commands.Push((ICommand)command);
                    }
                    command.Execute(MoveCommandTarget);
                }
            }

            if (Input.GetKeyDown(item.Key))
            {
                Command command = null;
                switch (item.Value)
                {
                case "Moving":
                    command = new MovingCommand();
                    break;

                case "CastArcaneBolt":
                    command = new ArcaneBoltCommand();
                    break;

                case "CastFireBolt":
                    command = new FireBoltCommand();
                    break;

                case "CastIceBolt":
                    command = new IceBoltCommand();
                    break;

                case "RestartGame":
                    command = new RestartGameCommand();
                    break;

                case "ExitGame":
                    command = new ExitGameCommand();
                    break;
                }
                if (command != null)
                {
                    if (command is ICommand)
                    {
                        Commands.Push((ICommand)command);
                    }
                    command.Execute(MoveCommandTarget);
                }
            }
        }
    }