Exemplo n.º 1
0
 private void btnRun_Click(object sender, EventArgs e)
 {
     if (character.Health <= 0)
     {
         UpdateStats();
         game.ChangeState(GameState.DEAD);
         lblEndFightMessage.Text    = "You Were Defeated!";
         lblEndFightMessage.Visible = true;
         Refresh();
         Thread.Sleep(1200);
         EndFight();
         FrmGameOver frmGameOver = new FrmGameOver();
         frmGameOver.Show();
     }
     if (rand.NextDouble() < 0.25)
     {
         lblEndFightMessage.Text    = "You Ran Like a Coward!";
         lblEndFightMessage.Visible = true;
         Refresh();
         Thread.Sleep(1200);
         EndFight();
     }
     else
     {
         doEnemyAttack();
     }
 }
Exemplo n.º 2
0
        private void btnSimpleAttack_Click(object sender, EventArgs e)
        {
            float prevEnemyHealth = enemy.Health;

            character.SimpleAttack(enemy);
            float enemyDamage = (float)Math.Round(prevEnemyHealth - enemy.Health);

            lblEnemyDamage.Text    = enemyDamage.ToString();
            lblEnemyDamage.Visible = true;
            tmrEnemyDamage.Enabled = true;
            if (enemy.Health <= 0)
            {
                character.GainXP(enemy.XpDropped);
                lblEndFightMessage.Text    = "You Gained " + Math.Round(enemy.XpDropped) + " xp!";
                lblEndFightMessage.Visible = true;
                Refresh();
                Thread.Sleep(1200);
                EndFight();
                if (character.ShouldLevelUp)
                {
                    FrmLevelUp frmLevelUp = new FrmLevelUp();
                    frmLevelUp.Show();
                }
            }
            else
            {
                float prevPlayerHealth = character.Health;
                enemy.SimpleAttack(character);
                float playerDamage = (float)Math.Round(prevPlayerHealth - character.Health);
                lblPlayerDamage.Text    = playerDamage.ToString();
                lblPlayerDamage.Visible = true;
                tmrPlayerDamage.Enabled = true;
                if (character.Health <= 0)
                {
                    UpdateStats();
                    game.ChangeState(GameState.DEAD);
                    lblEndFightMessage.Text    = "You Were Defeated!";
                    lblEndFightMessage.Visible = true;
                    Refresh();
                    Thread.Sleep(1200);
                    EndFight();
                    FrmGameOver frmGameOver = new FrmGameOver();
                    frmGameOver.Show();
                }
                else
                {
                    UpdateStats();
                }
            }
        }
Exemplo n.º 3
0
        private void doEnemyAttack()
        {
            float prevPlayerHealth = character.Health;

            enemy.SimpleAttack(character);
            float playerDamage = (float)Math.Round(prevPlayerHealth - character.Health);

            lblPlayerDamage.Text    = playerDamage.ToString();
            lblPlayerDamage.Visible = true;
            tmrPlayerDamage.Enabled = true;
            if (character.Health <= 0)
            {
                lblPlayerDamage.Visible = false;
                lblEnemyDamage.Visible  = false;

                // check if player ran out of hearts:
                if (character.ShouldRespawn() == false)
                {
                    UpdateStats();
                    game.ChangeState(GameState.DEAD);
                    lblEndFightMessage.Text    = "You Were Defeated!";
                    lblEndFightMessage.Visible = true;
                    Refresh();
                    Thread.Sleep(1200);
                    EndFight();
                    FrmGameOver frmGameOver = new FrmGameOver();
                    frmGameOver.Show();
                }
                else
                {
                    lblEndFightMessage.Text    = "Hearts left: " + character.hearts + ". Respawning!";
                    lblEndFightMessage.Visible = true;
                    Refresh();
                    Thread.Sleep(1200);
                    EndFight();

                    //this.Close();     // BYR: I am trying to close old window
                    //Respawn();        //      but I can't figure it out how

                    character.RefillHealthAndMana();
                    character.BackToStart();// This is the method that takes you to the Title screen TLF
                }
            }
            else
            {
                UpdateStats();
            }
        }
Exemplo n.º 4
0
        protected override void combatStuff()
        {
            if (enemy.Health <= 0)
            {
                game.ChangeState(GameState.WIN);
                Refresh();
                Thread.Sleep(1200);
                EndFight();
                FrmGameOver frmGameOver = new FrmGameOver();
                frmGameOver.Show();
            }
            else
            {
                if (!upgrade && enemy.Health < 0.5 * enemy.MaxHealth)
                {
                    upgrade = true;
                    picEnemy.BackgroundImage = Resources.fireBowser;
                    for (int i = 0; i < 3; ++i)
                    {
                        enemy.LevelUp();
                    }
                }

                float prevPlayerHealth = character.Health;
                enemy.SimpleAttack(character);
                float playerDamage = (float)Math.Round(prevPlayerHealth - character.Health);
                lblPlayerDamage.Text    = playerDamage.ToString();
                lblPlayerDamage.Visible = true;
                tmrPlayerDamage.Enabled = true;
                if (character.Health <= 0)
                {
                    UpdateStats();
                    game.ChangeState(GameState.DEAD);
                    lblEndFightMessage.Text    = "You Were Defeated!";
                    lblEndFightMessage.Visible = true;
                    Refresh();
                    Thread.Sleep(1200);
                    EndFight();
                    FrmGameOver frmGameOver = new FrmGameOver();
                    frmGameOver.Show();
                }
                else
                {
                    UpdateStats();
                }
            }
        }
Exemplo n.º 5
0
 private void btnRun_Click(object sender, EventArgs e)
 {
     // if not boss allow normal run
     if (enemytype != "boss")
     {
         if (rand.NextDouble() < 0.25)
         {
             lblEndFightMessage.Text    = "You Ran Like a Coward!";
             lblEndFightMessage.Visible = true;
             Refresh();
             Thread.Sleep(1200);
             EndFight();
         }
         else
         {
             enemy.SimpleAttack(character);
             if (character.Health <= 0)
             {
                 UpdateStats();
                 game.ChangeState(GameState.DEAD);
                 lblEndFightMessage.Text    = "You Were Defeated!";
                 lblEndFightMessage.Visible = true;
                 Refresh();
                 Thread.Sleep(1200);
                 EndFight();
                 FrmGameOver frmGameOver = new FrmGameOver();
                 frmGameOver.Show();
             }
             else
             {
                 UpdateStats();
             }
         }
     }
     // if boss fight then do not allow run
     else
     {
         lblEndFightMessage.Text    = "You Can't Run From This!";
         lblEndFightMessage.Visible = true;
         Refresh();
         Thread.Sleep(1200);
         lblEndFightMessage.Visible = false;
         Refresh();
     }
 }
 protected virtual void combatStuff()
 {
     if (enemy.Health <= 0)
     {
         character.GainXP(enemy.XpDropped, enemy.Level, character.Level);
         lblEndFightMessage.Text    = "You Gained " + Math.Round(enemy.XpDropped * 2.5F) + " xp!";
         lblEndFightMessage.Visible = true;
         character.regenerateHealth();
         character.regenerateMana();
         Refresh();
         Thread.Sleep(1200);
         EndFight();
         if (character.ShouldLevelUp)
         {
             FrmLevelUp frmLevelUp = new FrmLevelUp();
             frmLevelUp.Show();
         }
     }
     else
     {
         float prevPlayerHealth = character.Health;
         enemy.EnemyAttack(character);
         float playerDamage = (float)Math.Round(prevPlayerHealth - character.Health);
         lblPlayerDamage.Text    = playerDamage.ToString();
         lblPlayerDamage.Visible = true;
         tmrPlayerDamage.Enabled = true;
         if (character.Health <= 0)
         {
             UpdateStats();
             game.ChangeState(GameState.DEAD);
             lblEndFightMessage.Text    = "You Were Defeated!";
             lblEndFightMessage.Visible = true;
             Refresh();
             Thread.Sleep(1200);
             EndFight();
             FrmGameOver frmGameOver = new FrmGameOver();
             frmGameOver.Show();
         }
         else
         {
             UpdateStats();
         }
     }
 }
Exemplo n.º 7
0
 private void btnRun_Click(object sender, EventArgs e)
 {
     if (rand.NextDouble() < 0.25)
     {
         lblEndFightMessage.Text    = "You Ran Like a Coward!";
         lblEndFightMessage.Visible = true;
         Refresh();
         Thread.Sleep(1200);
         EndFight();
     }
     else
     {
         float prevPlayerHealth = character.Health;
         enemy.SimpleAttack(character);
         float playerDamage = (float)Math.Round(prevPlayerHealth - character.Health);
         lblPlayerDamage.ForeColor = Color.Red;
         lblPlayerDamage.Text      = playerDamage.ToString();
         lblPlayerDamage.Visible   = true;
         tmrPlayerDamage.Enabled   = true;
         if (character.Health <= 0)
         {
             if (character.undead)
             {
                 UpdateStats();
                 character.Health = character.MaxHealth;
             }
             else
             {
                 UpdateStats();
                 game.ChangeState(GameState.DEAD);
                 lblEndFightMessage.Text    = "You Were Defeated!";
                 lblEndFightMessage.Visible = true;
                 Refresh();
                 Thread.Sleep(1200);
                 EndFight();
                 FrmGameOver frmGameOver = new FrmGameOver();
                 frmGameOver.Show();
             }
         }
     }
     UpdateStats();
 }
Exemplo n.º 8
0
        private void doEnemyAttack()
        {
            float prevPlayerHealth = character.Health;

            enemy.SimpleAttack(character);
            float playerDamage = (float)Math.Round(prevPlayerHealth - character.Health);

            lblPlayerDamage.Text    = playerDamage.ToString();
            lblPlayerDamage.Visible = true;
            tmrPlayerDamage.Enabled = true;
            if (character.Health <= 0)
            {
                // check if player ran out of hearts:
                if (character.ShouldRespawn() == false)
                {
                    UpdateStats();
                    game.ChangeState(GameState.DEAD);
                    lblEndFightMessage.Text    = "You Were Defeated!";
                    lblEndFightMessage.Visible = true;
                    Refresh();
                    Thread.Sleep(1200);
                    EndFight();
                    FrmGameOver frmGameOver = new FrmGameOver();
                    frmGameOver.Show();
                }
                else
                {
                    lblEndFightMessage.Text    = "Hearts left: " + character.hearts + ". Respawning!";
                    lblEndFightMessage.Visible = true;
                    Refresh();
                    Thread.Sleep(1200);
                    EndFight();
                    character.RefillHealthAndMana();
                    character.BackToStart();
                }
            }
            else
            {
                UpdateStats();
            }
        }
Exemplo n.º 9
0
        private void btnRun_Click(object sender, EventArgs e)
        {
            SoundPlayer sp = new SoundPlayer(@"Resources\bossmusic.wav");

            boss.SimpleAttack(character);
            UpdateStats();
            lblEndFightMessage.Text    = "You can't run from the boss!";
            lblEndFightMessage.Visible = true;

            if (character.Health <= 0)
            {
                UpdateStats();
                game.ChangeState(GameState.DEAD);
                sp.Play();
                lblEndFightMessage.Text    = "You Were Defeated!";
                lblEndFightMessage.Visible = true;
                Refresh();
                Thread.Sleep(1200);
                EndFight();
                FrmGameOver frmGameOver = new FrmGameOver();
                frmGameOver.Show();
            }
        }
Exemplo n.º 10
0
 private void btnRun_Click(object sender, EventArgs e)
 {
     if (rand.NextDouble() < 0.05)
     {
         lblEndFightMessage.Text    = "You Somehow Managed To Escape!";
         lblEndFightMessage.Visible = true;
         Refresh();
         Thread.Sleep(1200);
         EndFight();
     }
     else
     {
         // perform enemy turn
         float prevPlayerHealth = character.Health;
         boss.SimpleAttack(character);
         float playerDamage = (float)Math.Round(prevPlayerHealth - character.Health);
         lblPlayerDamage.Text    = playerDamage.ToString();
         lblPlayerDamage.Visible = true;
         tmrPlayerDamage.Enabled = true;
         if (character.Health <= 0)
         {
             UpdateStats();
             game.ChangeState(GameState.DEAD);
             lblEndFightMessage.Text    = "You Were Defeated!";
             lblEndFightMessage.Visible = true;
             Refresh();
             Thread.Sleep(1200);
             EndFight();
             FrmGameOver frmGameOver = new FrmGameOver();
             frmGameOver.Show();
         }
         else
         {
             UpdateStats();
         }
     }
 }
Exemplo n.º 11
0
        private void btnSimpleAttack_Click(object sender, EventArgs e)
        {
            // make swing noise
            sp.Play();

            float prevEnemyHealth = enemy.Health;

            character.SimpleAttack(enemy);
            float enemyDamage = (float)Math.Round(prevEnemyHealth - enemy.Health);

            lblEnemyDamage.Text    = enemyDamage.ToString();
            lblEnemyDamage.Visible = true;
            tmrEnemyDamage.Enabled = true;
            if (enemy.Health <= 0)
            {
                character.GainXP(enemy.XpDropped);
                lblEndFightMessage.Text    = "You Gained " + Math.Round(enemy.XpDropped) + " xp!";
                lblEndFightMessage.Visible = true;

                Refresh();
                Thread.Sleep(1200);
                EndFight();
                if (character.ShouldLevelUp)
                {
                    FrmLevelUp frmLevelUp = new FrmLevelUp();
                    frmLevelUp.Show();
                }
                if (character.DidDrop() == true & character.HasWeapon == false)
                {
                    FrmDrop frmDrop = new FrmDrop();
                    frmDrop.Show();
                    frmDrop.Refresh();
                    Thread.Sleep(3000);
                    frmDrop.sp.Stop();
                    frmDrop.Hide();
                    character.HasWeapon = true;
                }

                if (enemy.CoinDropped > 0)
                {
                    FrmReward frmReward = new FrmReward();
                    frmReward.Amt = enemy.CoinDropped;
                    character.GetMoney(enemy.CoinDropped);
                    frmReward.Show();
                }
            }
            else
            {
                float prevPlayerHealth = character.Health;
                enemy.SimpleAttack(character);
                float playerDamage = (float)Math.Round(prevPlayerHealth - character.Health);
                lblPlayerDamage.Text    = playerDamage.ToString();
                lblPlayerDamage.Visible = true;
                tmrPlayerDamage.Enabled = true;
                if (character.Health <= 0)
                {
                    UpdateStats();
                    game.ChangeState(GameState.DEAD);
                    lblEndFightMessage.Text    = "You Were Defeated!";
                    lblEndFightMessage.Visible = true;
                    character.HasWeapon        = false;
                    Refresh();
                    Thread.Sleep(1200);
                    EndFight();
                    FrmGameOver frmGameOver = new FrmGameOver();
                    frmGameOver.Show();
                }
                else
                {
                    UpdateStats();
                }
            }
        }
Exemplo n.º 12
0
        private void btnSimpleAttack_Click(object sender, EventArgs e)
        {
            if (lblEndFightMessage.Visible == true)
            {
                lblEndFightMessage.Visible = false;
            }
            float prevEnemyHealth = boss.Health;

            weapon.SimpleWeaponAttack(boss);
            float enemyDamage = (float)Math.Round(prevEnemyHealth - boss.Health);

            lblEnemyDamage.Text    = enemyDamage.ToString();
            lblEnemyDamage.Visible = true;
            tmrEnemyDamage.Enabled = true;
            //TODO: ZAB
            SoundPlayer sp = new SoundPlayer(@"Resources\bossmusic.wav");

            if (boss.Health <= 0)
            {
                character.GainXP(boss.XpDropped);
                lblEndFightMessage.Text    = "You Gained " + Math.Round(boss.XpDropped) + " xp!";
                lblEndFightMessage.Visible = true;
                SoundPlayer bg = new SoundPlayer(@"Resources\victory.wav");
                bg.Play();
                Refresh();
                Thread.Sleep(1200);
                EndFight();
                if (character.ShouldLevelUp)
                {
                    FrmLevelUp frmLevelUp = new FrmLevelUp();
                    frmLevelUp.Show();
                }
            }
            else
            {
                float prevPlayerHealth = character.Health;
                boss.SimpleAttack(character);
                float playerDamage = (float)Math.Round(prevPlayerHealth - character.Health);
                lblPlayerDamage.Text    = playerDamage.ToString();
                lblPlayerDamage.Visible = true;
                tmrPlayerDamage.Enabled = true;
                //TODO: ZAB
                Thread.Sleep(175);//that is .175 of a second , lets the sound play out completely
                if (character.Health <= 0)
                {
                    UpdateStats();
                    game.ChangeState(GameState.DEAD);
                    sp = new SoundPlayer(@"Resources\game_over.wav");
                    sp.Play();
                    lblEndFightMessage.Text    = "You Were Defeated!";
                    lblEndFightMessage.Visible = true;
                    Refresh();
                    Thread.Sleep(1200);
                    EndFight();
                    FrmGameOver frmGameOver = new FrmGameOver();
                    frmGameOver.Show();
                }
                else
                {
                    UpdateStats();
                }
            }
        }
Exemplo n.º 13
0
        private void btnMagicAttack_Click(object sender, EventArgs e)
        {
            float prevEnemyHealth = boss.Health;

            weapon.ManaWeaponAttack(boss);
            float enemyDamage = (float)Math.Round(prevEnemyHealth - boss.Health);

            lblEnemyDamage.Text    = enemyDamage.ToString();
            lblEnemyDamage.Visible = true;
            tmrEnemyDamage.Enabled = true;
            if (character.Mana != 0)
            {
                weapon.ManaWeaponAttack(boss);
                character.Mana -= 10;
                if (boss.Health <= 0)
                {
                    character.GainXP(boss.XpDropped);
                    lblEndFightMessage.Text    = "You Gained " + Math.Round(boss.XpDropped) + " xp!";
                    character.Mana             = 40;
                    lblEndFightMessage.Visible = true;
                    Refresh();
                    Thread.Sleep(1200);
                    EndFight();
                    if (character.ShouldLevelUp)
                    {
                        FrmLevelUp frmLevelUp = new FrmLevelUp();
                        frmLevelUp.Show();
                    }
                }
                else
                {
                    float prevPlayerHealth = character.Health;
                    boss.SimpleAttack(character);
                    float playerDamage = (float)Math.Round(prevPlayerHealth - character.Health);
                    lblPlayerDamage.Text    = playerDamage.ToString();
                    lblPlayerDamage.Visible = true;
                    tmrPlayerDamage.Enabled = true;

                    if (character.Health <= 0)
                    {
                        UpdateStats();
                        game.ChangeState(GameState.DEAD);
                        lblEndFightMessage.Text    = "You Were Defeated!";
                        lblEndFightMessage.Visible = true;
                        Refresh();
                        Thread.Sleep(1200);
                        EndFight();
                        FrmGameOver frmGameOver = new FrmGameOver();
                        frmGameOver.Show();
                    }
                    else
                    {
                        UpdateStats();
                    }
                }
            }
            else
            {
                lblEndFightMessage.Text    = "You have no more mana";
                lblEndFightMessage.Visible = true;
                lblEnemyDamage.Visible     = false;
            };
        }
Exemplo n.º 14
0
        private void btnMagicAttack_Click(object sender, EventArgs e)
        {
            MidFightlabel.Text = "";
            MakeMagicSoundEffect();
            _counter             = 0;
            tmrAnimation.Enabled = true;
            tmrAnimation.Start();

            if (Game.GetGame().Character.Mana >= 5)
            {
                //Form2 f2 = new Form2();
                //f2.Show();
                float prevEnemyHealth = enemy.Health;
                character.MagicAttack(enemy);

                float enemyDamage = (float)Math.Round(prevEnemyHealth - enemy.Health);
                lblEnemyDamage.Text    = enemyDamage.ToString();
                lblEnemyDamage.Visible = true;
                tmrEnemyDamage.Enabled = true;
                if (enemy.Health <= 0)
                {
                    float X = enemy.XpDropped;
                    character.GainXP(X);
                    roll.GainXP(X);
                    rush.GainXP(X);
                    character.GainGb(enemy.GbDropped);
                    character.GainPt(enemy.PtDropped);
                    lblEndFightMessage.Text    = "You Gained " + Math.Round(enemy.XpDropped) + " xp and" + Math.Round(enemy.GbDropped) + " gb and" + Math.Round(enemy.PtDropped) + "Pt!";
                    lblEndFightMessage.Visible = true;
                    Refresh();
                    Thread.Sleep(1200);
                    EndFight();
                    LevelUpcheck();
                }

                else
                {
                    float prevPlayerHealth = character.Health;
                    enemy.SimpleAttack(character);
                    float playerDamage = (float)Math.Round(prevPlayerHealth - character.Health);
                    lblPlayerDamage.ForeColor = Color.Red;
                    lblPlayerDamage.Text      = playerDamage.ToString();
                    lblPlayerDamage.Visible   = true;
                    tmrPlayerDamage.Enabled   = true;
                    if (character.Health <= 0)
                    {
                        if (character.undead)
                        {
                            UpdateStats();
                            character.Health = character.MaxHealth;
                        }
                        else
                        {
                            UpdateStats();
                            game.ChangeState(GameState.DEAD);
                            lblEndFightMessage.Text    = "You Were Defeated!";
                            lblEndFightMessage.Visible = true;
                            Refresh();
                            Thread.Sleep(1200);
                            EndFight();
                            FrmGameOver frmGameOver = new FrmGameOver();
                            frmGameOver.Show();
                        }
                    }
                    else
                    {
                        UpdateStats();
                        MagAtk(roll, enemy);
                        MagAtk(rush, enemy);
                        MidFightlabel.Text   += " Damage dealt by party = " + Math.Round(PartyDamage);
                        MidFightlabel.Visible = true;
                    }
                }
            }
        }
Exemplo n.º 15
0
        private void btnSimpleAttack_Click(object sender, EventArgs e)
        {
            float prevEnemyHealth = enemy.Health;

            character.SimpleAttack(enemy);
            float enemyDamage = (float)Math.Round(prevEnemyHealth - enemy.Health);

            lblEnemyDamage.Text    = enemyDamage.ToString();
            lblEnemyDamage.Visible = true;
            tmrEnemyDamage.Enabled = true;
            if (enemy.Health <= 0)
            {
                //Generate a number 0-9 then if that number is > 4 give the player a potion
                int potion = rand.Next(10);
                if (potion > 4)
                {
                    //Set the potioncount higher in the inventory
                    inventory.getPotion();
                    label10.Text    = "You got a potion!!!";
                    label10.Visible = true;
                }

                character.GainXP(enemy.XpDropped);
                lblEndFightMessage.Text    = "You Gained " + Math.Round(enemy.XpDropped) + " xp!";
                lblEndFightMessage.Visible = true;
                Refresh();
                Thread.Sleep(1200);
                EndFight();
                //Once the fight ends (but before levelling up) reset the characters strength and def stats (in case postions were used.)
                character.ResetStrDef();
                if (character.ShouldLevelUp)
                {
                    FrmLevelUp frmLevelUp = new FrmLevelUp();
                    frmLevelUp.Show();
                }
            }
            else
            {
                float prevPlayerHealth = character.Health;
                enemy.SimpleAttack(character);
                float playerDamage = (float)Math.Round(prevPlayerHealth - character.Health);
                lblPlayerDamage.Text    = playerDamage.ToString();
                lblPlayerDamage.Visible = true;
                tmrPlayerDamage.Enabled = true;
                if (character.Health <= 0)
                {
                    UpdateStats();
                    character.ResetStrDef();
                    game.ChangeState(GameState.DEAD);
                    lblEndFightMessage.Text    = "You Were Defeated!";
                    lblEndFightMessage.Visible = true;
                    Refresh();
                    Thread.Sleep(1200);
                    EndFight();
                    FrmGameOver frmGameOver = new FrmGameOver();
                    frmGameOver.Show();
                }
                else
                {
                    UpdateStats();
                }
            }
        }
Exemplo n.º 16
0
        private void FrmMap_KeyDown(object sender, KeyEventArgs e)
        {
            MoveDir dir = MoveDir.NO_MOVE;

            switch (e.KeyCode)
            {
            case Keys.Left:
                dir = MoveDir.LEFT;
                break;

            case Keys.Right:
                dir = MoveDir.RIGHT;
                break;

            case Keys.Up:
                dir = MoveDir.UP;
                break;

            case Keys.Down:
                dir = MoveDir.DOWN;
                break;

            case Keys.I:
                FrmInventory frmInventory = new FrmInventory();
                frmInventory.Show();
                break;
            }
            if (dir != MoveDir.NO_MOVE)
            {
                character.Move(dir);
                if (game.State == GameState.FIGHTING)
                {
                    FrmArena frmArena = new FrmArena();
                    frmArena.Show();
                }
                if (game.State == GameState.BOSSFIGHT)
                {
                    FrmBossFight frmBossFight = new FrmBossFight();
                    character.inventory.AddWeapon(Killer);
                    frmBossFight.Show();
                }
                if (game.State == GameState.NEXT_LEVEL)
                {
                    //TODO:ZAB
                    this.level_on += 1;
                    game.ChangeState(GameState.LOADING);
                    // needs character so he moves on level 2 and more
                    string loadmap = "Resources/level" + level_on.ToString() + ".txt";
                    CharWeaponList = character.inventory.ReturnWeaponList();
                    character      = map.LoadMap(loadmap, grpMap, str => Resources.ResourceManager.GetObject(str) as Bitmap);
                    character.inventory.SetWeaponList(CharWeaponList);
                    if (level_on == 2)
                    {
                        character.inventory.AddWeapon(Crawler);
                    }
                    if (level_on == 3)
                    {
                        character.inventory.AddWeapon(Destroyer);
                    }
                    Width  = grpMap.Width + 25;
                    Height = grpMap.Height + 50;
                    //moves chararter back to start of level
                    character.BackToStart();
                    //code below resets the character to level 1
                    //game.SetCharacter(character);
                }
                if (game.State == GameState.DEAD)
                {
                    //TODO : ZAB
                    game.ChangeState(GameState.DEAD);
                    FrmGameOver frmGameOver = new FrmGameOver();
                    frmGameOver.Show();
                }
            }
        }
Exemplo n.º 17
0
        private void btnSimpleAttack_Click(object sender, EventArgs e)
        {
            // make swing noise
            sp.Play();

            float prevEnemyHealth = boss.Health;

            character.SimpleAttack(boss);
            float enemyDamage = (float)Math.Round(prevEnemyHealth - boss.Health);

            lblEnemyDamage.Text    = enemyDamage.ToString();
            lblEnemyDamage.Visible = true;
            tmrEnemyDamage.Enabled = true;
            if (boss.Health <= 0)
            {
                character.GainXP(boss.XpDropped);
                lblEndFightMessage.Text    = "You Gained " + Math.Round(boss.XpDropped) + " xp!";
                lblEndFightMessage.Visible = true;
                Refresh();
                Thread.Sleep(1200);
                EndFight();
                if (character.ShouldLevelUp)
                {
                    FrmLevelUp frmLevelUp = new FrmLevelUp();
                    frmLevelUp.Show();
                }
                Refresh();
                Thread.Sleep(1200);
                DialogResult result = MessageBox.Show("Congratulations on beating the boss!\n You are about to enter a 'coin frenzy' period.\n" +
                                                      "You will have 60 seconds to collect as many coins as possible . . . in the DARK! Good LUCK!", "Announcement", MessageBoxButtons.OK);

                if (result == DialogResult.OK)
                {
                    FrmCoinFrenzy frmCF = new FrmCoinFrenzy();
                    frmCF.Show();
                }
            }
            else
            {
                float prevPlayerHealth = character.Health;
                boss.SimpleAttack(character);
                float playerDamage = (float)Math.Round(prevPlayerHealth - character.Health);
                lblPlayerDamage.Text    = playerDamage.ToString();
                lblPlayerDamage.Visible = true;
                tmrPlayerDamage.Enabled = true;
                if (character.Health <= 0)
                {
                    UpdateStats();
                    game.ChangeState(GameState.DEAD);
                    lblEndFightMessage.Text    = "You Were Defeated!";
                    lblEndFightMessage.Visible = true;
                    Refresh();
                    Thread.Sleep(1200);
                    EndFight();
                    FrmGameOver frmGameOver = new FrmGameOver();
                    frmGameOver.Show();
                }
                else
                {
                    UpdateStats();
                }
            }
        }