コード例 #1
0
ファイル: Controller.cs プロジェクト: CapCalamity/ConsoleGame
        public Controller()
        {
            MainThread = new Thread(new ParameterizedThreadStart(this.GameLoop));
            Drawables = new List<IDrawable>();

            Player = new Player();
            Player.SetPosition(1, 1);
            Drawables.Add(Player);

            ConsoleController = new ConsoleController(this);
            ConsoleController.InitializeConsole();
            ConsoleController.InputRead += ConsoleController_InputRead;
        }
コード例 #2
0
ファイル: Controller.cs プロジェクト: CapCalamity/ConsoleGame
 void ConsoleController_InputRead(ConsoleController sender, InputEventArgs args)
 {
     switch (args.KeyInfo.Key)
     {
         case ConsoleKey.A:
             Player.Move(MoveDirection.Left);
             break;
         case ConsoleKey.D:
             Player.Move(MoveDirection.Right);
             break;
         case ConsoleKey.S:
             Player.Move(MoveDirection.Down);
             break;
         case ConsoleKey.W:
             Player.Move(MoveDirection.Up);
             break;
         case ConsoleKey.UpArrow:
             Drawables.Add(Player.Shoot(MoveDirection.Up));
             break;
         case ConsoleKey.RightArrow:
             Drawables.Add(Player.Shoot(MoveDirection.Right));
             break;
         case ConsoleKey.DownArrow:
             Drawables.Add(Player.Shoot(MoveDirection.Down));
             break;
         case ConsoleKey.LeftArrow:
             Drawables.Add(Player.Shoot(MoveDirection.Left));
             break;
         case ConsoleKey.N:
             Drawables.Add(new Spider());
             break;
         default: break;
     }
 }