Example #1
0
        public void DisplayEnemyAttackSprites(BattleEnemy currentListEnemy)
        {
            enemyAttackPictureBox.Visible = true;      //separate pictureBox control for the enemies' attacks
            HideEnemyDefaultPicture(currentListEnemy); //enemy cannot be visible in attack pictureBox and default pictureBox simultaneously
            try
            {
                if (currentListEnemy is Goomba)
                {
                    enemyAttackPictureBox.Load("https://raw.githubusercontent.com/TantumErgo/PaperMario/master/GoombaHeadbonkRotated.png");
                    enemyAttackPictureBox.Location = new Point(186, 23);
                }
                else if (currentListEnemy is SpikedGoomba)
                {
                    enemyAttackPictureBox.Load("https://raw.githubusercontent.com/TantumErgo/PaperMario/master/SpikedGoombaHeadbonkRotated.png");
                    enemyAttackPictureBox.Location = new Point(186, 23);
                }
                else if (currentListEnemy is Paragoomba)
                {
                    enemyAttackPictureBox.Load("https://raw.githubusercontent.com/TantumErgo/PaperMario/master/ParagoombaAttack.png");
                    enemyAttackPictureBox.Location = new Point(174, 70);
                }

                marioDefaultPicturebox.Load("https://raw.githubusercontent.com/TantumErgo/PaperMario/master/MarioHurt.png");
            }
            catch
            {
                MessageBox.Show("Internet connection is required to run this program. Please check your internet connection and restart the program.");
                Environment.Exit(1);
            }
            return;
        }
Example #2
0
 public void DisplayUserAttackSprites(AttackType selectedAttack, BattleEnemy enemyToAttack)
 {
     if (selectedAttack == AttackType.Jump) //user takes damage instead if enemy is spiked and is jumped on
     {
         IsEnemySpiked(enemyToAttack);
     }
     else if (selectedAttack == AttackType.Hammer)
     {
         try
         {
             marioDefaultPicturebox.Load("https://raw.githubusercontent.com/TantumErgo/PaperMario/master/MarioHammer.png");
         }
         catch
         {
             MessageBox.Show("Internet connection is required to run this program. Please check your internet connection and restart the program.");
             Environment.Exit(1);
         }
         HammerSpriteDisplay(enemyToAttack); //the Hammer itself is a separate sprite in its own pictureBox control
         enemyToAttack.Health -= 1;          //because damage logic is only one line, object logic is combined with UI logic
         instructionLabel.Text = "The Enemy Took 1 Damage! The Enemies Attack Next!";
     }
     else //Tattle attack does no damage
     {
         try
         {
             marioDefaultPicturebox.Load("https://raw.githubusercontent.com/TantumErgo/PaperMario/master/MarioTattle.png");
         }
         catch
         {
             MessageBox.Show("Internet connection is required to run this program. Please check your internet connection and restart the program.");
             Environment.Exit(1);
         }
         instructionLabel.Visible = false;
     }
 }
Example #3
0
 public void PictureBoxLoader(BattleEnemy enemyToDisplay)
 {
     try
     {
         if (enemyToDisplay.SpotOnScreen == 1)
         {
             if (enemyToDisplay is Goomba)
             {
                 enemy1BattlePicture.Load("https://raw.githubusercontent.com/TantumErgo/PaperMario/master/GoombaCropEnemy.png");
             }
             else if (enemyToDisplay is SpikedGoomba)
             {
                 enemy1BattlePicture.Load("https://raw.githubusercontent.com/TantumErgo/PaperMario/master/SpikedGoomba.png");
             }
             else if (enemyToDisplay is Paragoomba)
             {
                 enemy1BattlePicture.Load("https://raw.githubusercontent.com/TantumErgo/PaperMario/master/Paragoomba.png");
             }
         }
         else if (enemyToDisplay.SpotOnScreen == 2)
         {
             if (enemyToDisplay is Goomba)
             {
                 enemy2BattlePicture.Load("https://raw.githubusercontent.com/TantumErgo/PaperMario/master/GoombaCropEnemy.png");
             }
             else if (enemyToDisplay is SpikedGoomba)
             {
                 enemy2BattlePicture.Load("https://raw.githubusercontent.com/TantumErgo/PaperMario/master/SpikedGoomba.png");
             }
             else if (enemyToDisplay is Paragoomba)
             {
                 enemy2BattlePicture.Load("https://raw.githubusercontent.com/TantumErgo/PaperMario/master/Paragoomba.png");
             }
         }
         else if (enemyToDisplay.SpotOnScreen == 3)
         {
             if (enemyToDisplay is Goomba)
             {
                 enemy3BattlePicture.Load("https://raw.githubusercontent.com/TantumErgo/PaperMario/master/GoombaCropEnemy.png");
             }
             else if (enemyToDisplay is SpikedGoomba)
             {
                 enemy3BattlePicture.Load("https://raw.githubusercontent.com/TantumErgo/PaperMario/master/SpikedGoomba.png");
             }
             else if (enemyToDisplay is Paragoomba)
             {
                 enemy3BattlePicture.Load("https://raw.githubusercontent.com/TantumErgo/PaperMario/master/Paragoomba.png");
             }
         }
         return;
     }
     catch
     {
         MessageBox.Show("Internet connection is required to run this program. Please check your internet connection and restart the program.");
         Environment.Exit(1);
     }
 }
Example #4
0
        public void Tattle(BattleEnemy enemyToTattle) //retrieves enemy info from database and displays to user
        {
            try
            {
                using (var db = new EnemyDatabaseContext4())
                {
                    var query = from g in db.Enemies
                                where g.EnemyId == enemyToTattle.ID
                                select g;

                    foreach (var item in query)
                    {
                        TattleForm tattleForm = new TattleForm(item);
                        tattleForm.ShowDialog();
                    }
                }
            }
            catch //Mainly used to catch SqlException when attempting to communicate with database; attempts again by re-sending data
            {
                BattleEnemy enemyToResend = enemyToTattle;
                Tattle(enemyToResend);
            }

            for (int i = 0; i < (enemyList.ToArray()).Length; i++) //This for loop makes enemy HP bars visible
            {
                var tattledEnemyType = enemyToTattle.GetType();    //once one enemy of any type is Tattled, HP bars of all enemies of that type are visible
                if (enemyList[i].GetType() == tattledEnemyType)
                {
                    switch (enemyList[i].SpotOnScreen)
                    {
                    case 1:
                        enemy1HPLabel.Visible = true;
                        enemy1HPLabel.Text    = "HP: " + enemy1.Health + " / " + enemy1.MaxHealth;
                        break;

                    case 2:
                        enemy2HPLabel.Visible = true;
                        enemy2HPLabel.Text    = "HP: " + enemy2.Health + " / " + enemy2.MaxHealth;
                        break;

                    case 3:
                        enemy3HPLabel.Visible = true;
                        enemy3HPLabel.Text    = "HP: " + enemy3.Health + " / " + enemy3.MaxHealth;
                        break;
                    }
                }
            }
        }
Example #5
0
        public void HideEnemyDefaultPicture(BattleEnemy enemyToHide)
        {
            switch (enemyToHide.SpotOnScreen)
            {
            case 1:
                enemy1BattlePicture.Visible = false;
                return;

            case 2:
                enemy2BattlePicture.Visible = false;
                return;

            case 3:
                enemy3BattlePicture.Visible = false;
                return;
            }
        }
Example #6
0
        public void DisplayEnemyDefaultSprites(BattleEnemy enemyToDisplay)
        {
            switch (enemyToDisplay.SpotOnScreen) //uses the property to determine the correct picturebox control to load
            {
            case 1:
                PictureBoxLoader(enemyToDisplay);
                return;

            case 2:
                PictureBoxLoader(enemyToDisplay);
                return;

            case 3:
                PictureBoxLoader(enemyToDisplay);
                return;
            }
        }
Example #7
0
        public void DisplayEnemyHurtSprites(BattleEnemy clickedEnemy)
        {
            switch (clickedEnemy.SpotOnScreen) //uses same logic as DisplayEnemyDefaultSprites, but calls a different function
            {
            case 1:
                PictureBoxLoaderHurt(clickedEnemy);
                return;

            case 2:
                PictureBoxLoaderHurt(clickedEnemy);
                return;

            case 3:
                PictureBoxLoaderHurt(clickedEnemy);
                return;
            }
        }
Example #8
0
        public BattleEnemy BuildEnemyCaller(BattleEnemy enemyToSet, int id, int spotOnScreen) //named this because this function calls the appropriate object's constructor
        {
            switch (id)
            {
            case 1:
                enemyToSet = new Goomba(spotOnScreen);
                break;

            case 2:
                enemyToSet = new SpikedGoomba(spotOnScreen);
                break;

            case 3:
                enemyToSet = new Paragoomba(spotOnScreen);
                break;
            }
            return(enemyToSet);
        }
Example #9
0
        public void DisplayHiddenSprites(BattleEnemy attackingEnemy)
        {
            enemyAttackPictureBox.Visible = false;
            switch (attackingEnemy.SpotOnScreen)
            {
            case 1:
                enemy1BattlePicture.Visible = true;
                return;

            case 2:
                enemy2BattlePicture.Visible = true;
                return;

            case 3:
                enemy3BattlePicture.Visible = true;
                return;
            }
        }
Example #10
0
        public void HammerSpriteDisplay(BattleEnemy enemyToAttack)
        {
            hammerAttackPictureBox.Visible = true;

            switch (enemyToAttack.SpotOnScreen)
            {
            case 1:
                marioDefaultPicturebox.Location = new Point(461, 160);
                hammerAttackPictureBox.Location = new Point(548, 225);
                return;

            case 2:
                marioDefaultPicturebox.Location = new Point(587, 162);
                hammerAttackPictureBox.Location = new Point(674, 227);
                return;

            case 3:
                marioDefaultPicturebox.Location = new Point(716, 150);
                hammerAttackPictureBox.Location = new Point(803, 215);
                return;
            }
        }
Example #11
0
        public void IsEnemySpiked(BattleEnemy enemyToAttack) //primary focus of this function is displaying user sprite
        {
            if (enemyToAttack.IsSpiked)                      //sets the Image property of the pictureBox
            {
                try
                {
                    marioDefaultPicturebox.Load("https://raw.githubusercontent.com/TantumErgo/PaperMario/master/MarioSpikeJump.png");

                    switch (enemyToAttack.SpotOnScreen)
                    {
                    case 1:
                        enemy1BattlePicture.Load("https://raw.githubusercontent.com/TantumErgo/PaperMario/master/SpikedGoombaLaugh.png");
                        break;

                    case 2:
                        enemy2BattlePicture.Load("https://raw.githubusercontent.com/TantumErgo/PaperMario/master/SpikedGoombaLaugh.png");
                        break;

                    case 3:
                        enemy3BattlePicture.Load("https://raw.githubusercontent.com/TantumErgo/PaperMario/master/SpikedGoombaLaugh.png");
                        break;
                    }
                }
                catch
                {
                    MessageBox.Show("Internet connection is required to run this program. Please check your internet connection and restart the program.");
                    Environment.Exit(1);
                }
                BattleForm.CURRENT_MARIO_HP -= 1; //because damage logic is only one line of code, object logic is combined with UI logic
                instructionLabel.Text        = "You Took 1 Damage! The Enemies Attack Next!";
            }
            else
            {
                try
                {
                    marioDefaultPicturebox.Load("https://raw.githubusercontent.com/TantumErgo/PaperMario/master/MarioJump.png");
                }
                catch
                {
                    MessageBox.Show("Internet connection is required to run this program. Please check your internet connection and restart the program.");
                    Environment.Exit(1);
                }
                enemyToAttack.Health -= 1;
                instructionLabel.Text = "The Enemy Took 1 Damage! The Enemies Attack Next!";
            }

            switch (enemyToAttack.SpotOnScreen) //sets the Location of the pictureBox
            {
            case 1:
            {
                marioDefaultPicturebox.Location = new Point(575, 65);
                return;
            }

            case 2:
            {
                marioDefaultPicturebox.Location = new Point(672, 20);
                return;
            }

            case 3:
            {
                marioDefaultPicturebox.Location = new Point(806, 18);
                return;
            }
            }
        }