Ejemplo n.º 1
0
        private void ThrowGrenade(string direct)
        {
            Grenade gr = new Grenade();

            gr.Direction1  = direct;
            gr.GrenadeLeft = playerPB.Left + (playerPB.Width / 2);
            gr.GrenadeTop  = playerPB.Top + (playerPB.Width / 2);
            gr.MkGrenade(this);
        }
Ejemplo n.º 2
0
        private void keyisdown(object sender, KeyEventArgs e)
        {
            if (gameOver)
            {
                return;
            }


            if (e.KeyCode == Keys.Left)
            {
                goleft         = true;
                facing         = "left";
                playerPB.Image = Properties.Resources.left;
            }

            if (e.KeyCode == Keys.Right)
            {
                goright        = true;
                facing         = "right";
                playerPB.Image = Properties.Resources.right;
            }

            if (e.KeyCode == Keys.Up)
            {
                goup           = true;
                facing         = "up";
                playerPB.Image = Properties.Resources.up;
            }

            if (e.KeyCode == Keys.Down)
            {
                godown         = true;
                facing         = "down";
                playerPB.Image = Properties.Resources.down;
            }

            if (e.KeyCode == Keys.G && grenade > 0)
            {
                grenade--;
                Grenade gr = new Grenade();
                ThrowGrenade(facing);
                boom = true;
                if (facing == "left")
                {
                    Left = playerPB.Left - 200;
                    Top  = playerPB.Top;
                    time = Left / 20;
                }
                if (facing == "right")
                {
                    Left = playerPB.Left + 200;
                    Top  = playerPB.Top;
                    time = Left / 20;
                }
                if (facing == "down")
                {
                    Top  = playerPB.Top + 200;
                    Left = playerPB.Left;
                    time = Top / 20;
                }
                if (facing == "up")
                {
                    Top  = playerPB.Top - 200;
                    Left = playerPB.Left;
                    time = Top / 20;
                }
            }
            if (ammo == 0 && e.KeyCode == Keys.Space)
            {
                backgroundWorker3.RunWorkerAsync();
            }

            if (e.KeyCode == Keys.Space && ammo <= 30 && ammo != 0 && !shotgun)
            {
                backgroundWorker1.RunWorkerAsync();
            }
        }