Пример #1
0
 private void Form1_Load(object sender, EventArgs e)
 {
     game = new Game(new Rectangle(110, 83, 680, 305));
     game.NewLevel(random);
     UpdateCharacters();
 }
Пример #2
0
        public void UpdateCharacters()
        {
            Playerimg.Location = game.PlayerLocation;
            pHP.Text           = game.PlayerHitPoints.ToString();

            Playerimg.Visible = true;

            Batimg.Visible   = false;
            Ghostimg.Visible = false;
            Ghoulimg.Visible = false;
            int enemiesshown = 0;

            Swordimg.Visible      = false;
            Bowimg.Visible        = false;
            Redpotionimg.Visible  = false;
            Bluepotionimg.Visible = false;
            Maseimg.Visible       = false;

            Control weaponControl = null;

            switch (game.WeaponInRoom.Name)
            {
            case "Sword":
                weaponControl = Swordimg;
                break;

            case "Bow":
                weaponControl = Bowimg;
                break;

            case "Mace":
                weaponControl = Maseimg;
                break;

            case "Blue Potion":
                weaponControl = Bluepotionimg;
                break;

            case "Red Potion":
                weaponControl = Redpotionimg;
                break;

            default: break;
            }

            weaponControl.Visible  = true;
            weaponControl.Location = game.WeaponInRoom.Location;

            foreach (Enemy enemy in game.Enemies)
            {
                if (enemy is Bat)
                {
                    Batimg.Location = enemy.Location;
                    bHP.Text        = enemy.HitPoints.ToString();
                    if (enemy.HitPoints > 0)
                    {
                        Batimg.Visible = true;
                        enemiesshown++;
                    }
                }
                else if (enemy is Ghost)
                {
                    Ghostimg.Location = enemy.Location;
                    GstHP.Text        = enemy.HitPoints.ToString();
                    if (enemy.HitPoints > 0)
                    {
                        Ghostimg.Visible = true;
                        enemiesshown++;
                    }
                }
                else if (enemy is Ghoul)
                {
                    Ghoulimg.Location = enemy.Location;
                    oulHP.Text        = enemy.HitPoints.ToString();
                    if (enemy.HitPoints > 0)
                    {
                        Ghoulimg.Visible = true;
                        enemiesshown++;
                    }
                }
            }

            string[] weaponnames = { "Bow", "Sword", "Mace", "Blue Potion", "Red Potion" };
            foreach (string wname in weaponnames)
            {
                if (game.CheckPlayerInventory(wname))
                {
                    switch (wname)
                    {
                    case "Sword":
                        itemSord.Visible = true;
                        break;

                    case "Bow":
                        itemBow.Visible = true;
                        break;

                    case "Mace":
                        itemMace.Visible = true;
                        break;

                    case "Blue Potion":
                        itemBP.Visible = true;
                        break;

                    case "Red Potion":
                        itemRP.Visible = true;
                        break;

                    default: break;
                    }
                }
            }
            if (game.WeaponInRoom.PickedUp)
            {
                weaponControl.Visible = false;
            }
            else
            {
                weaponControl.Visible = true;
            }
            if (game.PlayerHitPoints <= 0)
            {
                MessageBox.Show("You died");
                Application.Exit();
            }
            if (enemiesshown < 1)
            {
                MessageBox.Show("You have defeated the enemies on this level");
                game.NewLevel(random);
                UpdateCharacters();
            }
        }
Пример #3
0
 private void Form1_Load(object sender, EventArgs e)
 {
     game = new Game(new Rectangle(110,83,680,305));
     game.NewLevel(random);
     UpdateCharacters();
 }