Ejemplo n.º 1
0
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            //移动
            if (e.KeyCode == Keys.W)
            {
                game.Move(Direction.Up, random);
                UpdateCharacters();
            }
            if (e.KeyCode == Keys.A)
            {
                game.Move(Direction.Left, random);
                UpdateCharacters();
            }
            if (e.KeyCode == Keys.D)
            {
                game.Move(Direction.Right, random);
                UpdateCharacters();
            }
            if (e.KeyCode == Keys.S)
            {
                game.Move(Direction.Down, random);
                UpdateCharacters();
            }

            //攻击
            if (e.KeyCode == Keys.I)
            {
                game.Attack(Direction.Up, random);
                UpdateCharacters();
            }
            if (e.KeyCode == Keys.J)
            {
                game.Attack(Direction.Left, random);
                UpdateCharacters();
            }
            if (e.KeyCode == Keys.K)
            {
                game.Attack(Direction.Down, random);
                UpdateCharacters();
            }
            if (e.KeyCode == Keys.L)
            {
                game.Attack(Direction.Right, random);
                UpdateCharacters();
            }
        }