コード例 #1
0
ファイル: Player.cs プロジェクト: PetrovskiIgor/CombatGame
 public Player(string name, string description, Magic mOne, Magic mTwo, Magic mThree)
 {
     Name = name;
     Description = description;
     Health = 100;
     magicList = new List<Magic>();
     magicList.Add(mOne);
     magicList.Add(mTwo);
     magicList.Add(mThree);
     statePerson = State.STAND;
     IsJumped = false;
     DirectionPlayer = Direction.UNDEFINED;
     this.Velocity = 10; // treba da se smeni!!!!!!!!!
     this.X = 50;
     this.Y = 50;
 }
コード例 #2
0
ファイル: frmFight.cs プロジェクト: PetrovskiIgor/CombatGame
        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;
                        }
                       
                    }



                    
                }

               
            }
        }
コード例 #3
0
ファイル: frmFight.cs プロジェクト: PetrovskiIgor/CombatGame
        private void frmFight_KeyDown(object sender, KeyEventArgs e)
        {
            if(e.KeyCode==Keys.W)
            {
                playerTwo.IsJumped = true;
            }
            else if(e.KeyCode==Keys.Up)
            {
                playerOne.IsJumped = true;
            }
            else if (e.KeyCode==Keys.A)
            {
                
                a = true;
            }
            else if(e.KeyCode==Keys.D)
            {
                
                d = true;
            }
            else if (e.KeyCode==Keys.S)
            {
                playerTwo.ChangeState(State.KNEEL);
            }
            else if(e.KeyCode==Keys.Left)
            {
                
                left = true;
            }
            else if (e.KeyCode==Keys.Right)
            {
                
                right = true;
            }
            else if(e.KeyCode==Keys.Down)
            {
                down = true;
                playerOne.ChangeState(State.KNEEL);
            }
            else if(e.KeyCode== Keys.F)
            {
                if (!f)
                {
                    f = true;
                    playerTwo.ChangeState(State.ATTACK);
                    if (playerTwo.Attack(playerOne)) 
                    {
                        if(frmOptions.soundOn)
                        soundPunch.Play();
                        playerOne.DecreaseHealth(Player.HandPower);
                    }
                }
            }
            else if (e.KeyCode==Keys.G)
            {
                if (!g)
                {
                    g = true;
                    playerTwo.ChangeState(State.ATTACKLEG);
                    if (playerTwo.AttackLeg(playerOne))
                        playerOne.DecreaseHealth(Player.LegPower);
                }
            }
            else if(e.KeyCode==Keys.V)
            {
                playerTwo.ChangeState(State.ATTACKMAGIC);
                playerTwoMagic=playerTwo.AttackMagic();
                
              
            }
            else if(e.KeyCode==Keys.H)
            {
                playerTwo.ChangeState(State.DEFENSE);
            }
            else if(e.KeyCode==Keys.Enter)
            {
                if (!enter)
                {
                    enter = true;
                    playerOne.ChangeState(State.ATTACK);
                    if (playerOne.Attack(playerTwo))
                    {
                        if(frmOptions.soundOn)
                        soundPunch.Play();
                        playerTwo.DecreaseHealth(Player.HandPower);
                    }
                        
                }
            }
            else if(e.KeyCode==Keys.Add)
            {
                if (!add)
                {
                    add = true;
                    playerOne.ChangeState(State.ATTACKLEG);
                    if (playerOne.AttackLeg(playerTwo))
                        playerTwo.DecreaseHealth(Player.LegPower);
                }
            }
            else if(e.KeyCode==Keys.NumPad1)
            {

                playerOne.ChangeState(State.ATTACKMAGIC);
                playerOneMagic = playerOne.AttackMagic();
                
                //pbMagic1.BackColor = Color.Transparent;
                //pbMagic1.Image = playerOne.magicList.ElementAt(0).MagicImageLeft;
            }
            else if (e.KeyCode==Keys.NumPad0)
            {
                playerOne.ChangeState(State.DEFENSE);
            }
            
        }
コード例 #4
0
ファイル: frmFight.cs プロジェクト: PetrovskiIgor/CombatGame
        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;
                        }
                        
                    }
                }

               
            }
        }
コード例 #5
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();
        }