示例#1
0
        private void button1_Click(object sender, EventArgs e)//Look for bag monster
        {
            if (MainPlayer.NumActions == 0)
            {
                World.EndGame(ref MainPlayer, ref enemyMonster, listBox1);
                InitializeMyComponents();
            }
            else
            {
                //actions
                MainPlayer.NumActions--;
                UpdateActions();

                int r = World.rand.Next(0, 2);
                if (r == 0)
                {
                    lblNarrator.Text = "No monster found";
                    ClearEnemyStatLabels();
                }
                else if (r == 1)
                {
                    enemyMonster     = World.GetRandomMonster();
                    lblNarrator.Text = "Found a " + enemyMonster.Type;

                    //stats for enemy label update
                    UpdateEnemyStatLabels();
                }
            }
        }
示例#2
0
        public override void Attack(BagMonster enemy)
        {
            double i = (AttackPoints / enemy.DefensePoints);

            i *= 20;
            enemy.CurrentHealth -= (int)i;
        }
示例#3
0
        private void btnAttack_Click(object sender, EventArgs e)//attack
        {
            if (MainPlayer.NumActions == 0)
            {
                World.EndGame(ref MainPlayer, ref enemyMonster, listBox1);
                InitializeMyComponents();
            }
            else
            {
                if (enemyMonster != null)
                {
                    if (MainPlayer.bagMonsters[listBox1.SelectedIndex] != null)
                    {
                        //actions
                        MainPlayer.NumActions--;
                        UpdateActions();
                        MainPlayer.bagMonsters[listBox1.SelectedIndex].Attack(enemyMonster);//attack
                        if (enemyMonster.CurrentHealth == 0)
                        {
                            lblNarrator.Text = "You have defeated the monster";                                           //kills the monster when at 0 health\
                            World.RefillHealth(MainPlayer.bagMonsters);                                                   //refill health

                            MainPlayer.bagMonsters[listBox1.SelectedIndex].ExperiencePoints += World.getXP(enemyMonster); //add xp
                            MainPlayer.TotalXPGained += World.getXP(enemyMonster);                                        //add xp

                            enemyMonster = null;
                        }
                        else
                        {
                            World.EnemyTurn(MainPlayer.bagMonsters[listBox1.SelectedIndex], enemyMonster, lblNarrator);//enemy turn
                            if (MainPlayer.bagMonsters[listBox1.SelectedIndex].IsAlive == false)
                            {
                                lblNarrator.Text = MainPlayer.bagMonsters[listBox1.SelectedIndex].Name + " has died!";
                                World.RemoveMonster(ref MainPlayer, ref MainPlayer.bagMonsters[listBox1.SelectedIndex], ref listBox1);
                                //hides buttons
                                btnRelease.Visible       = false;
                                btnLevelUp.Visible       = false;
                                btnMonsterRename.Visible = false;
                                btnMagicAttack.Visible   = false;
                                btnAttack.Visible        = false;
                                btnMagicHeal.Visible     = false;
                                //
                            }
                        }
                    }
                    else
                    {
                        lblNarrator.Text = "No Bagmonster to fight with!";
                    }
                }
                else
                {
                    lblNarrator.Text = "No monster to fight!";
                }
                //label updates
                UpdateEnemyStatLabels();
                UpdateSelectedStatLabels();
            }
        }
示例#4
0
        private void button4_Click(object sender, EventArgs e)//Catch
        {
            if (MainPlayer.NumActions == 0)
            {
                World.EndGame(ref MainPlayer, ref enemyMonster, listBox1);
                InitializeMyComponents();
            }
            else
            {
                //actions
                MainPlayer.NumActions--;
                UpdateActions();


                int i = World.rand.Next(0, 101);
                if (enemyMonster == null)
                {
                    lblNarrator.Text = "No monster to catch!";
                }
                else if (i <= enemyMonster.CatchChance * 100)
                {
                    lblNarrator.Text = "You caught it!";

                    World.CreatePlayerMonster(ref MainPlayer, "N/a", enemyMonster.Type, ref listBox1);
                    enemyMonster = null;
                    ClearEnemyStatLabels();
                }
                else//fail to catch
                {
                    if (listBox1.Items.Count == 0)//ends game
                    {
                        World.EndGame(ref MainPlayer, ref enemyMonster, listBox1);
                        InitializeMyComponents();
                    }
                    else
                    {
                        int y = World.rand.Next(0, listBox1.Items.Count);//attacks random monster in bag
                        lblNarrator.Text = "Failed to catch! The enemy attacks!";
                        World.EnemyTurn(MainPlayer.bagMonsters[y], enemyMonster, lblNarrator);
                        if (MainPlayer.bagMonsters[y].IsAlive == false)//checks for player monster death
                        {
                            lblNarrator.Text = MainPlayer.bagMonsters[y].Name + " has died!";
                            World.RemoveMonster(ref MainPlayer, ref MainPlayer.bagMonsters[y], ref listBox1);//removes monster
                            //hides buttons
                            btnRelease.Visible       = false;
                            btnLevelUp.Visible       = false;
                            btnMonsterRename.Visible = false;
                            btnMagicAttack.Visible   = false;
                            btnAttack.Visible        = false;
                            btnMagicHeal.Visible     = false;
                            //
                        }
                    }
                }
            }
        }
示例#5
0
        //*************************************************************************************************************************
        public static void RemoveMonster(ref Player p, ref BagMonster b, ref ListBox lb)//Deletes monster and related actions
        {
            p.MonsterCount--;

            lb.Items.RemoveAt(Array.IndexOf(p.bagMonsters, b));
            lb.SelectedIndex = -1;
            lb.Height       -= lb.ItemHeight;
            b = null;
            SortMonsterArray(p.bagMonsters);
        }
示例#6
0
 public override void Attack(BagMonster enemy)
 {
     if (enemy is BoogeyChild)
     {
         enemy.CurrentHealth -= 35;//35 damage to boogey boys
     }
     else
     {
         enemy.CurrentHealth -= 25;
     }                                  //25 to everything else
 }
示例#7
0
 public override void Attack(BagMonster enemy)
 {
     if (enemy is Boogey)
     {
         enemy.CurrentHealth -= 10;//10 damage to boogey men
     }
     else
     {
         enemy.CurrentHealth -= 15;
     }                                  //everything else
 }
示例#8
0
        public static void EndGame(ref Player player, ref BagMonster enemy, ListBox lb)//Kicks the player out of the world, ending the game
        {
            //Resets stats
            enemy = null;
            for (int i = 0; i < player.bagMonsters.Length; i++)
            {
                player.bagMonsters[i] = null;
            }

            //reset listbox
            lb.Items.Clear();
            //total xp gained + clears player
            MessageBox.Show("You have been kicked out!\nYour total experience gained: " + player.TotalXPGained.ToString());
            player = null;
        }
示例#9
0
        public static int getXP(BagMonster enemy)//checks for type of monster and returns xp based on state
        {
            switch (enemy.Type)
            {
            case "Boogey":
                return(50);

            case "Boogey Boy":
                return(20);

            case "Slender":
                return(100);

            case "Slender Girl":
                return(30);
            }
            return(0);
        }
示例#10
0
 public abstract void Attack(BagMonster enemy);      //attack action signature
 public abstract void MagicAttack(BagMonster enemy); //magic attack sig.
示例#11
0
 public abstract void Attack(BagMonster enemy);      //attack action signature
示例#12
0
 public override void MagicAttack(BagMonster enemy)
 {
     MagicPoints         -= 10;
     enemy.CurrentHealth -= 50;
 }
示例#13
0
 public override void Attack(BagMonster enemy)
 {
     base.Attack(enemy);
 }
示例#14
0
 public static void EnemyTurn(BagMonster playerMonster, BagMonster enemy, Label narrator)//enemy turn (AI)
 {
     /************************************************************************************************************/
     if (enemy is Slender || enemy is SlenderGirl) //actions for enemy Slender type
     {
         if (enemy.MagicPoints <= 20)              //recharge magic if low
         {
             enemy.MagicBoost();
             narrator.Text = "The enemy has boosted their magic points!";
         }
         else if (playerMonster.CurrentHealth <= 50 && enemy.MagicPoints >= 10)//finish a player off if low health
         {
             enemy.MagicAttack(playerMonster);
             narrator.Text = "The enemy has attacked you with magic!";
         }
         else if (enemy.MagicPoints >= 10)//random attack if enough magic
         {
             int x = rand.Next(0, 2);
             if (x == 0)
             {
                 enemy.MagicAttack(playerMonster);//magic attack
                 narrator.Text = "The enemy has attacked you with magic!";
             }
             else if (x == 1)
             {
                 enemy.Attack(playerMonster);//attack
                 narrator.Text = "The enemy has attacked you with fists!";
             }
         }
         else
         {
             enemy.Attack(playerMonster);
             narrator.Text = "The enemy has attacked you with fists!";
         }
     }
     else if (enemy is Boogey || enemy is BoogeyChild)             //actions for enemy boogey type
     {
         if (enemy.CurrentHealth <= 30 && enemy.MagicPoints >= 10) //heal when health is low
         {
             enemy.Heal();
             narrator.Text = "The enemy has healed!";
         }
         else if (enemy.MagicPoints >= 10) //when enough magic
         {
             int i = rand.Next(0, 2);      //random between magic attack and normal attack
             if (i == 0)
             {
                 enemy.MagicAttack(playerMonster);
                 narrator.Text = "The enemy has attacked you with magic!";
             }
             else if (i == 1)
             {
                 enemy.Attack(playerMonster);
                 narrator.Text = "The enemy has attacked you with fists!";
             }
         }
         else//when no points for magic or heal uneccesary
         {
             enemy.Attack(playerMonster);
             narrator.Text = "The enemy has attacked you with fists!";
         }
     }
     /******************************************************************************************************/
     //Checks for death and sets it to dead
     if (playerMonster.CurrentHealth == 0)
     {
         playerMonster.IsAlive = false;
     }
 }