コード例 #1
0
        /// <summary>
        /// Constructs a fight
        /// </summary>
        /// <param name="fighter1">The aggressor</param>
        /// <param name="fighter2">The defender</param>
        public Fight(ref MetaHuman fighter1, ref MetaHuman fighter2)
        {
            Fighter1 = fighter1;
            Fighter2 = fighter2;

            Fighter1Attack = fighter1.Attack();
            Fighter2Block  = fighter2.Block();

            Damage = 0;
            Result = null;
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: Turtleman1024/SuperHeroGUI
        /// <summary>
        /// A method that has fighter1 attack fighter2
        /// </summary>
        private void Battle(ref MetaHuman fighter1, ref MetaHuman fighter2)
        {
            //Create a new battle
            Fight battle = new Fight(ref fighter1, ref fighter2);

            // Start a battle
            battle.StartBattle();

            //Get the results and
            action_label.Text += battle.GetResults();

            //Update the health bars
            UpdateHealthBar();
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: Turtleman1024/SuperHeroGUI
        /// <summary>
        /// This method starts the battle of the two MetaHumans.
        /// </summary>
        /// <param name="fighter1">The hero of the duel</param>
        /// <param name="fighter2">The villian of the duel</param>
        private void StartBattle(ref MetaHuman fighter1, ref MetaHuman fighter2)
        {
            //Check if they knocked each other out
            if (fighter1.GetHealth() <= 0 && fighter2.GetHealth() <= 0)
            {
                ///Set the health of the heroes back to original, game on.
                hero_health_label.Visible    = false;
                villian_health_label.Visible = false;

                ///Display message to the greeting label that a draw has occured.
                action_label.Text += "Duel is a draw";

                ///Set background image to the appropriate images.
                HeroLossAnimation(hero_picture_box);
                VillianLossAnimation(villian_picture_box);

                ///Disable attack button
                attack_button.Enabled = false;
                attack_button.Visible = false;

                ///Activate rest button
                reset_button.Visible = true;
                reset_button.Enabled = true;

                return;
            }

            //Neither fighter has been knocked out, fight.
            //Fighter1 attacks first
            Battle(ref fighter1, ref fighter2);


            //Check if fighter2 has not been knocked out
            if (fighter2.GetHealth() <= 0)
            {
                //Display message to the action label that Thanos has been knocked out and captain is victorius.
                action_label.Text += "\n\n" + fighter2.Name + " has been knocked out and " + fighter1.Name + " is Victorius\n";

                //Display message of the winner in greeting label
                greeting_label.Text = fighter1.Name + " Wins!";

                //Set background image to the appropriate images.
                HeroWinAnimation(hero_picture_box);
                VillianLossAnimation(villian_picture_box);

                //Disable attack button
                attack_button.Enabled = false;
                attack_button.Visible = false;

                //Activate rest button
                reset_button.Visible = true;
                reset_button.Enabled = true;

                return;
            }


            //Fighter2 attacks back
            Battle(ref fighter2, ref fighter1);

            //Check if fighter1 has not been knocked out
            if (fighter1.GetHealth() <= 0)
            {
                //Display message to the action label that fighter1 has been knocked out and fighter2 is victorius.
                action_label.Text += "\n\n" + fighter1.Name + " has been knocked out and " + fighter2.Name + " is Victorius\n";

                //Display message of the winner in greeting label
                greeting_label.Text = fighter2.Name + " Wins!";

                //Set background image to the appropriate images.
                HeroLossAnimation(hero_picture_box);
                VillianWinAnimation(villian_picture_box);

                //Disable attack button
                attack_button.Enabled = false;
                attack_button.Visible = false;

                //Activate rest button
                reset_button.Visible = true;
                reset_button.Enabled = true;

                return;
            }
        }