コード例 #1
0
ファイル: Hero.cs プロジェクト: tyrgin/net-courses
 private void OnInputReceived(object sender, IGameEventArgs eventArgs)
 {
     if (eventArgs.ReceivedCommand.Key == System.ConsoleKey.LeftArrow)
     {
         if (PosX != 1)
         {
             PosX--;
         }
     }
     if (eventArgs.ReceivedCommand.Key == System.ConsoleKey.RightArrow)
     {
         if (PosX != Board.SizeX - 2)
         {
             PosX++;
         }
     }
     if (eventArgs.ReceivedCommand.Key == System.ConsoleKey.UpArrow)
     {
         if (PosY != 1)
         {
             PosY--;
         }
     }
     if (eventArgs.ReceivedCommand.Key == System.ConsoleKey.DownArrow)
     {
         if (PosY != Board.SizeY - 2)
         {
             PosY++;
         }
     }
 }
コード例 #2
0
 public Registry()
 {
     this.Board            = new Board();
     this.Hero             = new Hero();
     this.Drawing          = new Drawing();
     this.UserInteraction  = new UserInteraction();
     this.GetGameEventArgs = new GameEventArgs();
 }
コード例 #3
0
        private void OnInputReceived(object sender, IGameEventArgs eventArgs)
        {
            switch (eventArgs.ReceivedCommand.Key)
            {
            case System.ConsoleKey.LeftArrow:
                if (PosX != 1)
                {
                    PosX--;
                }
                break;

            case System.ConsoleKey.RightArrow:
                if (PosX != Board.SizeX - 2)
                {
                    PosX++;
                }
                break;

            case System.ConsoleKey.UpArrow:
                if (PosY != 1)
                {
                    PosY--;
                }
                break;

            case System.ConsoleKey.DownArrow:
                if (PosY != Board.SizeY - 2)
                {
                    PosY++;
                }
                break;

            default:
                break;
            }
        }
コード例 #4
0
 private void OnInputReceived(object sender, IGameEventArgs eventArgs)
 {
     DrawAll();
 }