Esempio n. 1
0
        private void GamePlay_KeyDown(object sender, KeyEventArgs e)
        {
            actionstatusLabel.Text = "";

            if (e.KeyCode == Keys.W)
            {
                actionStatus("move up", ge.movePlayer(Character.Movement.Up), "");
            }
            else if (e.KeyCode == Keys.S)
            {
                actionStatus("move down", ge.movePlayer(Character.Movement.Down), "");
            }
            else if (e.KeyCode == Keys.A)
            {
                actionStatus("move left", ge.movePlayer(Character.Movement.Left), "");
            }
            else if (e.KeyCode == Keys.D)
            {
                actionStatus("move right", ge.movePlayer(Character.Movement.Right), "");
            }
            else if (e.KeyCode == Keys.Space)
            {
                actionStatus("no move", ge.remainStill(), "");
            }
            else if (e.KeyCode == Keys.Up)
            {
                String  response = ge.attackEnemy(ge.GetMap().getHero(), Character.Movement.Up, null);
                Boolean success  = false;
                if (response[0] == '1')
                {
                    success = true;
                }
                actionStatus("attack up", success, response.Substring(1));
            }
            else if (e.KeyCode == Keys.Down)
            {
                String  response = ge.attackEnemy(ge.GetMap().getHero(), Character.Movement.Down, null);
                Boolean success  = false;
                if (response[0] == '1')
                {
                    success = true;
                }
                actionStatus("attack down", success, response.Substring(1));
            }
            else if (e.KeyCode == Keys.Left)
            {
                String  response = ge.attackEnemy(ge.GetMap().getHero(), Character.Movement.Left, null);
                Boolean success  = false;
                if (response[0] == '1')
                {
                    success = true;
                }
                actionStatus("attack left", success, response.Substring(1));
            }
            else if (e.KeyCode == Keys.Right)
            {
                String  response = ge.attackEnemy(ge.GetMap().getHero(), Character.Movement.Right, null);
                Boolean success  = false;
                if (response[0] == '1')
                {
                    success = true;
                }
                actionStatus("attack right", success, response.Substring(1));
            }
            else if (e.KeyCode == Keys.Escape)       // save and exit
            {
                ge.saveGame();

                caller.Show();
                this.Dispose();
            }
            else if (e.KeyCode == Keys.Enter)       // save only
            {
                if (ge.saveGame())
                {
                    actionstatusLabel.ForeColor = Color.Orange;
                    actionstatusLabel.Text      = "Save successful!";
                }
                else
                {
                    actionstatusLabel.ForeColor = Color.Red;
                    actionstatusLabel.Text      = "Unable to save.";
                }
            }
        }
Esempio n. 2
0
        private void GamePlay_KeyDown(object sender, KeyEventArgs e)
        {
            actionstatusLabel.Text = "";

            if (e.KeyCode == Keys.W)
            {
                actionStatus("move up", ge.movePlayer(Character.Movement.Up), "");
            }
            else if (e.KeyCode == Keys.S)
            {
                actionStatus("move down", ge.movePlayer(Character.Movement.Down), "");
            }
            else if (e.KeyCode == Keys.A)
            {
                actionStatus("move left", ge.movePlayer(Character.Movement.Left), "");
            }
            else if (e.KeyCode == Keys.D)
            {
                actionStatus("move right", ge.movePlayer(Character.Movement.Right), "");
            }
            else if (e.KeyCode == Keys.Space)
            {
                actionStatus("no move", ge.remainStill(), "");
            }
            else if (e.KeyCode == Keys.Up)
            {
                String  response = ge.attackEnemy(Character.Movement.Up);
                Boolean success  = false;
                if (response[0] == '1')
                {
                    success = true;
                }
                actionStatus("attack up", success, response.Substring(1));
            }
            else if (e.KeyCode == Keys.Down)
            {
                String  response = ge.attackEnemy(Character.Movement.Down);
                Boolean success  = false;
                if (response[0] == '1')
                {
                    success = true;
                }
                actionStatus("attack down", success, response.Substring(1));
            }
            else if (e.KeyCode == Keys.Left)
            {
                String  response = ge.attackEnemy(Character.Movement.Left);
                Boolean success  = false;
                if (response[0] == '1')
                {
                    success = true;
                }
                actionStatus("attack left", success, response.Substring(1));
            }
            else if (e.KeyCode == Keys.Right)
            {
                String  response = ge.attackEnemy(Character.Movement.Right);
                Boolean success  = false;
                if (response[0] == '1')
                {
                    success = true;
                }
                actionStatus("attack right", success, response.Substring(1));
            }
            else if (e.KeyCode == Keys.Escape)
            {
                caller.Show();
                this.Dispose();
            }
        }
Esempio n. 3
0
        private void GamePlay_KeyDown(object sender, KeyEventArgs e)
        {
            actionstatusLabel.Text = "";

            if (e.KeyCode == Keys.W)
            {
                actionStatus("move up", ge.movePlayer(Character.Movement.Up), "");
            }
            else if (e.KeyCode == Keys.S)
            {
                actionStatus("move down", ge.movePlayer(Character.Movement.Down), "");
            }
            else if (e.KeyCode == Keys.A)
            {
                if (direction == Character.Movement.None)
                {
                    actionStatus("move left", ge.movePlayer(Character.Movement.Left), "");
                }
                else
                {
                    String  response = ge.attackEnemy(ge.GetMap().getHero(), direction, 1, null);
                    Boolean success  = false;
                    if (response[0] == '1')
                    {
                        success = true;
                    }
                    actionStatus("attack " + dir_text, success, response.Substring(1));

                    action_complete = true;
                    direction       = Character.Movement.None;
                }
            }
            else if (e.KeyCode == Keys.D)
            {
                if (direction == Character.Movement.None)
                {
                    actionStatus("move right", ge.movePlayer(Character.Movement.Right), "");
                }
                else
                {
                    String  response = ge.attackEnemy(ge.GetMap().getHero(), direction, 2, null);
                    Boolean success  = false;
                    if (response[0] == '1')
                    {
                        success = true;
                    }
                    actionStatus("attack " + dir_text, success, response.Substring(1));

                    action_complete = true;
                    direction       = Character.Movement.None;
                }
            }
            else if (e.KeyCode == Keys.Space)
            {
                actionStatus("no move", ge.remainStill(), "");
            }
            else if (e.KeyCode == Keys.Up)
            {
                this.action_complete = false;
                this.dir_text        = "up";
                this.direction       = Character.Movement.Up;

                /*
                 * String response = ge.attackEnemy(ge.GetMap().getHero(), Character.Movement.Up,null);
                 * Boolean success = false;
                 * if (response[0] == '1')
                 * {
                 *  success = true;
                 * }
                 * actionStatus("attack up",success,response.Substring(1));
                 */
            }
            else if (e.KeyCode == Keys.Down)
            {
                this.action_complete = false;
                this.dir_text        = "down";
                this.direction       = Character.Movement.Down;

                /*
                 * String response = ge.attackEnemy(ge.GetMap().getHero(), Character.Movement.Down,null);
                 * Boolean success = false;
                 * if (response[0] == '1')
                 * {
                 *  success = true;
                 * }
                 * actionStatus("attack down", success, response.Substring(1));
                 */
            }
            else if (e.KeyCode == Keys.Left)
            {
                this.action_complete = false;
                this.dir_text        = "left";
                this.direction       = Character.Movement.Left;

                /*
                 * String response = ge.attackEnemy(ge.GetMap().getHero(), Character.Movement.Left,null);
                 * Boolean success = false;
                 * if (response[0] == '1')
                 * {
                 *  success = true;
                 * }
                 * actionStatus("attack left", success, response.Substring(1));
                 */
            }
            else if (e.KeyCode == Keys.Right)
            {
                this.action_complete = false;
                this.dir_text        = "right";
                this.direction       = Character.Movement.Right;

                /*
                 * String response = ge.attackEnemy(ge.GetMap().getHero(),Character.Movement.Right,null);
                 * Boolean success = false;
                 * if (response[0] == '1')
                 * {
                 *  success = true;
                 * }
                 * actionStatus("attack right", success, response.Substring(1));
                 */
            }
            else if (e.KeyCode == Keys.L)
            {
                if (ge.GetMap().getHero().isDead())
                {
                    if (si != null)
                    {
                        si.Dispose();
                    }

                    caller.resetAfterDeath();
                    this.Dispose();
                }
            }
            else if (e.KeyCode == Keys.Escape)       // save and exit
            {
                ge.saveGame();

                caller.Show();
                this.Dispose();
            }
            else if (e.KeyCode == Keys.Enter)       // save only
            {
                if (ge.saveGame())
                {
                    actionstatusLabel.ForeColor = Color.Orange;
                    actionstatusLabel.Text      = "Save successful!";
                }
                else
                {
                    actionstatusLabel.ForeColor = Color.Red;
                    actionstatusLabel.Text      = "Unable to save.";
                }
            }
            else if (e.KeyCode == Keys.P)
            {
                if (si == null)
                {
                    si = new ShopInterface(ge.getShop());
                    si.setCaller(this);
                    si.Show();
                }
            }
        }