示例#1
0
        public frmFight(Player first, Player second, frmMenu mainForm)
        {
            InitializeComponent();

            MainForm = mainForm;

            

            

            prbarPlayerOne = new PPPProgressBar(755, 46, 461, 56);
            prbarPlayerTwo = new PPPProgressBar(49, 46, 461, 56);


            soundPunch = new SoundPlayer("punch.wav");

            playerOneIsRight = true;

            // za da go prepoznae file-ot  EyeOfTheTiger.wav
            //
            // EyeOfTheTiger.wav vo properties Copy to Output directory: copy if newer!!!
            //if(frmOptions.musicOn)
            //    soundPlayer = new SoundPlayer("EyeOfTheTiger.wav");

            bmBackground = new PPPBitmap(new Bitmap("CombatGameBackground.gif"), "CombatGameBackground.gif");

            playerOne = first;
            playerOne.X = this.Right - playerOne.Width - 200;
            playerOne.Y = Player.StandPosition - playerOne.Height;
           
            playerOne.DirectionPlayer = Direction.LEFT;
            
            
            playerTwo = second;

            playerTwo.X = this.Left + playerTwo.Width + 200; 
            playerTwo.Y = Player.StandPosition - playerOne.Height;
           
            playerTwo.DirectionPlayer = Direction.RIGHT;
           


            this.lblPlayerOneName.Text = playerOne.Name;
            this.lblPlayerTwoName.Text = playerTwo.Name;
            //if(soundPlayer != null)
            //    soundPlayer.Play();
            timer = new Timer();
            timer.Interval = INTERVAL;
            timer.Tick += new EventHandler(timer_Tick);
            timer.Start();
            update();
            this.DoubleBuffered = true;


          
            Invalidate();
        }
示例#2
0
 //Changes statePerson and attacks opponent
 public bool Attack(Player opponent)
 {
     this.statePerson = State.ATTACK;
     return IsSuccessfulAttack(opponent);
 }
示例#3
0
 //Changes statePerson and attacks opponent
 public bool AttackLeg(Player opponent)
 {
     this.statePerson = State.ATTACKLEG;
     if (Math.Abs(this.X - opponent.X) > 2*Width/3)
     {
         this.Move(this.DirectionPlayer);
     }
     return IsSuccessfulAttack(opponent);
 }
示例#4
0
 //Checks if the opponent was hurt
 public bool IsSuccessfulAttack(Player opponent)
 {
     if (this.DirectionPlayer == Direction.LEFT)
     {
         if (this.X-Width/2 < opponent.X+Width/3 && this.X-Width/2 > opponent.X-Width/3 && Math.Abs(this.Y-opponent.Y)<Height/4)
         {
             if (opponent.statePerson != State.DEFENSE && opponent.statePerson != State.KNEEL)
             {
                 return true;
             }
         }
     }
     else if (this.DirectionPlayer == Direction.RIGHT)
     {
         if (this.X + Width / 2 > opponent.X - Width / 3 && this.X + Width / 2 < opponent.X+Width/3 && Math.Abs(this.Y - opponent.Y) < Height / 4) 
         {
             if (opponent.statePerson != State.DEFENSE && opponent.statePerson != State.KNEEL)
             {
                 return true;
             }
         }
     }
     return false;
 }
示例#5
0
        public void RightMagicAttack (Player player, Magic magic)
        {

            if (((magic.X + magic.Width / 2) > (player.X - player.Width/2 + 50)) && (magic.X - magic.Width/2 <= player.X - player.Width/2))
            {
                if (!player.AvoidMagicAttack())
                {

                    if ((player.Y + player.Height / 2) >= (magic.Y - magic.Height / 2))
                    {
                        player.DecreaseHealth(magic.Power);

                        if (playerOneMagic == magic)
                        {
                            playerOneMagic = null;
                        }
                        else
                        {
                            playerTwoMagic = null;
                        }
                       
                    }



                    
                }

               
            }
        }
示例#6
0
        public void LeftMagicAttack (Player player, Magic magic)
        {


            if (((magic.X - magic.Width / 2) < (player.X + player.Width / 2)) && magic.X + Width / 2 >= player.X + player.Width / 2)
            {
                if (!player.AvoidMagicAttack())
                {

                    if (player.Y + player.Height / 2 >= (magic.Y - magic.Height / 2))
                    {
                        player.DecreaseHealth(magic.Power);
                        if (playerOneMagic == magic)
                        {
                            playerOneMagic = null;
                        }
                        else
                        {
                            playerTwoMagic = null;
                        }
                        
                    }
                }

               
            }
        }
示例#7
0
        Image imgPlayerTwo = Image.FromFile("imgPlayerTwo.png"); // da se azurira

        

        public frmPickPlayer(frmMenu menu)
        {
            InitializeComponent();
            MainMenu = menu;
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            bmBackground = new PPPBitmap(new Bitmap("CombatGameBackground.gif"), "CombatGameBackground.gif");
            numPlayers = 4;

            pb1.Image = Image.FromFile("imgVikiPeeva.jpg");
            pb2.Image = Image.FromFile("imgPetrovPetre.jpg");
            pb3.Image = Image.FromFile("imgIgorPetrovski.jpg");
            pb4.Image = Image.FromFile("imgDavidHorny.jpg");

       
            firstDone = false;
            secDone = false;




            takenPb = new bool[numPlayers];
            players = new Player[numPlayers];
            magicTricks = new Magic[3];
            pb = new PictureBox[numPlayers][];
            pb[0] = new PictureBox[2];
            pb[1] = new PictureBox[2];
            pb[2] = new PictureBox[2];
            pb[3] = new PictureBox[2];

            

            pb[0][0] = pb1; pb[0][1] = pb1Parent;
            pb[1][0] = pb2; pb[1][1] = pb2Parent;
            pb[2][0] = pb3; pb[2][1] = pb3Parent;
            pb[3][0] = pb4; pb[3][1] = pb4Parent;
            

            takenPb[0] = takenPb[1] = true;
            
            currPosFirst = 0;
            currPosSec = 1;

            for (int i = 2; i < numPlayers; i++)
            {
                takenPb[i] = false;
            }

            magicTricks[0] = new Magic("Fire", 10, Image.FromFile("imgFireMagicTrans.png"), Image.FromFile("imgFireMagicTrans.png"),30);
            magicTricks[1] = new Magic("Hurricane", 10, Image.FromFile("imgHurrucainVerticalTrans.png"), Image.FromFile("imgHurrucainVerticalTrans.png"), 30);
            magicTricks[2] = new Magic("Lightning", 10, Image.FromFile("imgLightningMagicTrans.png"), Image.FromFile("imgLightningMagicTrans.png"), 30);
           
            

            players[0] = new Player("Viki","Zestoka",magicTricks[0],magicTricks[1],magicTricks[2]);
            players[1] = new Player("Petre", "Petre doagja od gradot Radovis.", magicTricks[0], magicTricks[1], magicTricks[2]);
            players[2] = new Player("Igor", "Jas sum Igor Petrovski, dzverot Tetovski.", magicTricks[0], magicTricks[1], magicTricks[2]);
            players[3] = new Player("David", "Jas sum Horny i mnogu sum crazy!", magicTricks[0], magicTricks[1], magicTricks[2]);
            this.fillPlayersImages();

            players[0].SetCurrentImage(true);
            players[1].SetCurrentImage(false);
            players[2].SetCurrentImage(true);
            players[3].SetCurrentImage(false);


            
           



            pb1.BackColor = Color.Transparent;
            pb2.BackColor = Color.Red;
            pb3.BackColor = Color.Red;
            pb4.BackColor = Color.Red;
            pb1Parent.BackColor = Color.Yellow;
            pb2Parent.BackColor = Color.Green;
            pb3Parent.BackColor = Color.Transparent;
            pb4Parent.BackColor = Color.Transparent;




            lblPlayerOneDesc.Text = players[0].Description;
            lblPlayerTwoDesc.Text = players[1].Description;

            Invalidate();
        }