예제 #1
0
        public void GameUserInput(Game.GameUserInput direction)
        {
            byte directionCommand = 0;
            switch (direction)
            {
                case Game.GameUserInput.Right:
                    directionCommand = 0;
                    if (CurrentGame.Name == "Snake" && CurrentGameUserInput == Game.GameUserInput.Left)
                    {
                        return;
                    }
                    CurrentGameUserInput = Game.GameUserInput.Right;
                    break;
                case Game.GameUserInput.Up:
                    directionCommand = 1;
                    if (CurrentGame.Name == "Snake" && CurrentGameUserInput == Game.GameUserInput.Down)
                    {
                        return;
                    }
                    CurrentGameUserInput = Game.GameUserInput.Up;
                    break;
                case Game.GameUserInput.Left:
                    directionCommand = 2;
                    if (CurrentGame.Name == "Snake" && CurrentGameUserInput == Game.GameUserInput.Right)
                    {
                        return;
                    }
                    CurrentGameUserInput = Game.GameUserInput.Left;
                    break;
                case Game.GameUserInput.Down:
                    directionCommand = 3;
                    if (CurrentGame.Name == "Snake" && CurrentGameUserInput == Game.GameUserInput.Up)
                    {
                        return;
                    }
                    CurrentGameUserInput = Game.GameUserInput.Down;
                    break;
                case Game.GameUserInput.Action:
                    directionCommand = 4;
                    if (CurrentGame.Name == "Snake")
                    {
                        return;
                    }
                    CurrentGameUserInput = Game.GameUserInput.Action;
                    break;

            }
            Btc.SendCommand(Command.ArduinoCommand(CommandName.MoveDirection, new List<string>() { directionCommand.ToString() }));
        }
예제 #2
0
        /*private static void OnFinishedFileTask(object sender, PortableLibrary1.TestModule.FileTaskEventArgs e)
        {
            
        }*/

        public void StartGame(Game g)
        {
            if (g != null)
            {
                ModiIsPlaying = true;
                CurrentGameUserInput = Game.GameUserInput.Right;
                CurrentGame = g;
                Btc.SendCommand(Command.ArduinoCommand(g.CommandName));
            }
        }