Пример #1
0
        public void OnPress(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.W:

                player.dirY = -player.velocity;

                Wpressed        = true;
                player.isMoving = true;
                player.setAnimationConfiguration(0);


                break;

            case Keys.S:

                player.dirY = player.velocity;

                Spressed        = true;
                player.isMoving = true;
                player.setAnimationConfiguration(0);


                break;

            case Keys.A:

                Apressed    = true;
                player.dirX = -player.velocity;

                player.flip     = -1;
                player.isMoving = true;
                player.setAnimationConfiguration(0);

                break;

            case Keys.D:


                Dpressed    = true;
                player.dirX = player.velocity;

                player.flip     = 1;
                player.isMoving = true;
                player.setAnimationConfiguration(0);


                break;


            //hit
            case Keys.E:


                player.hitPressed = true;

                if (enemies[newBossIndex].enemyDead)
                {
                    player.isMoving = false;
                    player.setAnimationConfiguration(0);
                    msg msg = new msg();
                    msg.Show();
                }
                break;

            case Keys.Q:

                Qpressed(player, weapons);
                break;

            case Keys.F:
                WeaponCollide(player, weapons);
                break;

            case Keys.X:
                Xpressed = true;
                //if (!Chest.isOpened)
                //{
                //    chestOpen(Chest);
                //    double distance = GetDistance(player.posX, player.posY, Chest.posX, Chest.posY);

                //    if (distance < 20)
                //        Chest.setAnimation(1);
                //    Chest.isOpened = true;
                //}

                break;

            case Keys.Space:
                break;

            case Keys.Escape:
                string            message = "all progress is not saved, are you sure?";
                string            title   = "Close Game";
                MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                DialogResult      result  = MessageBox.Show(message, title, buttons);
                if (result == DialogResult.Yes)
                {
                    this.Hide();
                    weapons.Clear();
                    enemies.Clear();
                    timer1.Stop();
                    timer2.Stop();
                    timer3.Stop();
                    timer4.Stop();
                    player.hitPressed = false;
                    player.id         = 0;
                    player.Freehands  = true;
                    FormMenu fm = new FormMenu();
                    fm.label1.Text = nicknameRemember;
                    if (checkBox1.Checked == false)
                    {
                        fm.check_sound.Checked = false;
                    }
                    else
                    {
                        fm.check_sound.Checked = true;
                    }
                    axWindowsMediaPlayer1.Ctlcontrols.stop();
                    axWindowsMediaPlayer2.Ctlcontrols.stop();
                    axWindowsMediaPlayer3.Ctlcontrols.stop();

                    fm.ShowDialog();

                    escapePressed = true;
                    this.Close();
                    this.Dispose();
                }
                else
                {
                }
                break;
            }
        }