示例#1
0
 public void Attack(Direction direction, Random random)
 {
     if (equipedWeapon != null)
     {
         if (equipedWeapon is IPotion)
         {
             if (equipedWeapon == "BluePotion")
             {
                 BluePotion currentWeapon = equipedWeapon as BluePotion;
                 currentWeapon.Attack(direction, random);
                 equipedWeapon = null;
             }
             else
             {
                 RedPotion currentWeapon = equipedWeapon as RedPotion;
                 currentWeapon.Attack(direction, random);
                 equipedWeapon = null;
             }
         }
         else
         {
             equippedWeapon.Attack(direction, random);
         }
     }
 }
示例#2
0
    protected override void OnAwake()
    {
        bomb               = Resources.Load <Bomb>("Objects/Bomb");
        cardReset          = Resources.Load <CardReset>("Objects/CardReset");
        changeCardPosition = Resources.Load <ChangeCardPosition>("Objects/ChangeCardPosition");
        weapon             = Resources.Load <Weapon>("Objects/Weapon");
        flameThrower       = Resources.Load <FlameThrower>("Objects/Flame");


        //Trap
        thorn = Resources.Load <Thorn>(PATH_TRAP + "Thorn");
        //Trap


        //Coin
        goldCoin = Resources.Load <Coin>(PATH_COIN + "GoldCoin");
        //Coin


        //Monster
        ghost = Resources.Load <Monster>(PATH_MONSTER + "Ghost");
        slime = Resources.Load <Slime>(PATH_MONSTER + "Slime");
        imp   = Resources.Load <Imp>(PATH_MONSTER + "Imp");
        //Monster


        //Potion
        blackPotion  = Resources.Load <BlackPotion>(PATH_POTION + "BlackPotion");
        bluePotion   = Resources.Load <BluePotion>(PATH_POTION + "BluePotion");
        pinkPotion   = Resources.Load <PinkPotion>(PATH_POTION + "PinkPotion");
        purplePotion = Resources.Load <PurplePotion>(PATH_POTION + "PurplePotion");
        redPotion    = Resources.Load <RedPotion>(PATH_POTION + "RedPotion");
        yellowPotion = Resources.Load <YellowPotion>(PATH_POTION + "Yellowpotion");
        //Potion
    }
示例#3
0
    public void ReturnBluePotion(BluePotion card)
    {
        if (card.gameObject.activeSelf)
        {
            card.gameObject.SetActive(false);
        }

        card.transform.SetParent(_tr_BluePotion);
        _stack_BluePotion.Push(card);
    }
示例#4
0
    private void MakeBluePotion(int count)
    {
        for (int i = 0; i < count; i++)
        {
            BluePotion newBluePotion = Instantiate(DataManager.instance.bluePotion);
            newBluePotion.gameObject.SetActive(false);
            newBluePotion.transform.SetParent(_tr_BluePotion);

            _stack_BluePotion.Push(newBluePotion);
        }
    }
示例#5
0
        public void NewLevel(Random random)
        {
            level++;
            switch (level)
            {
            case 1:
                Enemies = new list <Enemy>()
                {
                    new Bat(this, GetRandomLocation(random)),
                };
                WeaponInRoom = new Sword(this, GetRandomLocation(random));
                break;

            case 2:
                Enemies = new list <Enemy>()
                {
                    new Ghost(this, GetRandomLocation(random)),
                };
                WeaponInRoom = new BluePotion(this, GetRandomLocation(random));
                break;
            }
        }
示例#6
0
文件: Game.cs 项目: vi24/Lab-2
        public void NewLevel(Random random)
        {
            _level++;
            switch (_level)
            {
            case 1:
                Enemies = new List <Enemy>()
                {
                    new Bat(this, GetRandomLocation(random)),
                };
                WeaponInRoom = new Sword(this, GetRandomLocation(random));
                break;

            case 2:
                Enemies = new List <Enemy>()
                {
                    new Ghost(this, GetRandomLocation(random)),
                };
                WeaponInRoom = new BluePotion(this, GetRandomLocation(random));
                break;

            case 3:
                Enemies = new List <Enemy>()
                {
                    new Ghost(this, GetRandomLocation(random)),
                };
                WeaponInRoom = new Bow(this, GetRandomLocation(random));
                break;

            case 4:
                Enemies = new List <Enemy>()
                {
                    new Bat(this, GetRandomLocation(random)),
                    new Ghost(this, GetRandomLocation(random))
                };
                if (WeaponInRoom.PickedUp)
                {
                    WeaponInRoom = new BluePotion(this, GetRandomLocation(random));
                }
                break;

            case 5:
                Enemies = new List <Enemy>()
                {
                    new Bat(this, GetRandomLocation(random)),
                    new Ghoul(this, GetRandomLocation(random))
                };
                WeaponInRoom = new RedPotion(this, GetRandomLocation(random));
                break;

            case 6:
                Enemies = new List <Enemy>()
                {
                    new Ghost(this, GetRandomLocation(random)),
                    new Ghoul(this, GetRandomLocation(random))
                };
                WeaponInRoom = new Mace(this, GetRandomLocation(random));
                break;

            case 7:
                Enemies = new List <Enemy>()
                {
                    new Bat(this, GetRandomLocation(random)),
                    new Ghost(this, GetRandomLocation(random)),
                    new Ghoul(this, GetRandomLocation(random)),
                };
                if (WeaponInRoom.PickedUp)
                {
                    WeaponInRoom = new Sword(this, GetRandomLocation(random));
                }
                break;

            case 8:
                Console.WriteLine("Finished");
                Application.Exit();
                break;
            }
        }
示例#7
0
文件: Game.cs 项目: CamoIV/HF_Csharp
        public void NewLevel(Random random)
        {
            level++;
            switch (level)
            {
            case 1:
                Enemies = new List <Enemy>()
                {
                    new Bat(this, GetRandomLocation(random))
                };
                WeaponInRoom = new Sword(this, GetRandomLocation(random));
                break;

            case 2:
                Enemies = new List <Enemy>()
                {
                    new Ghost(this, GetRandomLocation(random))
                };
                WeaponInRoom = new BluePotion(this, GetRandomLocation(random));
                break;

            case 3:
                Enemies = new List <Enemy>()
                {
                    new Ghoul(this, GetRandomLocation(random))
                };
                WeaponInRoom = new Bow(this, GetRandomLocation(random));
                break;

            case 4:
                Enemies = new List <Enemy>()
                {
                    new Bat(this, GetRandomLocation(random)),
                    new Ghost(this, GetRandomLocation(random))
                };
                if (WeaponInRoom == Bow)
                {
                    WeaponInRoom = new BluePotion(this, GetRandomLocation(random));
                }
                else
                {
                    WeaponInRoom = new Bow(this, GetRandomLocation(random));
                }
                break;

            case 5:
                Enemies = new List <Enemy>()
                {
                    new Bat(this, GetRandomLocation(random)),
                    new Ghoul(this, GetRandomLocation(random))
                };
                WeaponInRoom = new RedPotion(this, GetRandomLocation(random));
                break;

            case 6:
                Enemies = new List <Enemy>()
                {
                    new Ghost(this, GetRandomLocation(random)),
                    new Ghoul(this, GetRandomLocation(random))
                };
                WeaponInRoom = new Mace(this, GetRandomLocation(random));
                break;

            case 7:
                Enemies = new List <Enemy>()
                {
                    new Bat(this, GetRandomLocation(random)),
                    new Ghost(this, GetRandomLocation(random)),
                    new Ghoul(this, GetRandomLocation(random))
                };
                if (WeaponInRoom == Mace)
                {
                    WeaponInRoom = new RedPotion(this, GetRandomLocation(random));
                }
                else
                {
                    WeaponInRoom = new Mace(this, GetRandomLocation(random));
                }
                break;

            default:
                // end the game with Application.exit()
                break;
            }
        }
示例#8
0
        private void UpdateCharacters()
        {
            this.Text              = "A missão: Nivel " + game.Level;
            PBPlayer.Location      = game.PlayerLocation;
            lblptsVidaJogador.Text = game.PlayerHitPoints.ToString();

            bool showBat      = false;
            bool showGhost    = false;
            bool showZombie   = false;
            int  enemiesShown = 0;

            foreach (Enemy enemy in game.Enemies)
            {
                if (enemy is Bat)
                {
                    picBat.Location        = enemy.Location;
                    lblptsVidaMorcego.Text = enemy.HitPoints.ToString();
                    if (enemy.HitPoints > 0)
                    {
                        showBat = true;
                        enemiesShown++;
                    }
                }
                else if (enemy is Ghost)
                {
                    picGhost.Location       = enemy.Location;
                    lblptsVidaFantasma.Text = enemy.HitPoints.ToString();
                    if (enemy.HitPoints > 0)
                    {
                        showGhost = true;
                        enemiesShown++;
                    }
                }
                else
                {
                    picZombie.Location   = enemy.Location;
                    lblptsVidaZumbi.Text = enemy.HitPoints.ToString();
                    if (enemy.HitPoints > 0)
                    {
                        showZombie = true;
                        enemiesShown++;
                    }
                }
            }

            if (showBat == false)
            {
                picBat.Visible         = false;
                lblptsVidaMorcego.Text = "";
            }
            else
            {
                picBat.Visible = true;
            }

            if (showGhost == false)
            {
                picGhost.Visible        = false;
                lblptsVidaFantasma.Text = "";
            }
            else
            {
                picGhost.Visible = true;
            }

            if (showZombie == false)
            {
                picZombie.Visible    = false;
                lblptsVidaZumbi.Text = "";
            }
            else
            {
                picZombie.Visible = true;
            }

            picArmaArco.Visible          = false;
            picArmaBastao.Visible        = false;
            picArmaEspada.Visible        = false;
            picArmaPocaoAzul.Visible     = false;
            picArmaPocaoVermelha.Visible = false;

            Control weaponControl    = null;
            Control inventoryControl = null;

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

            case "BluePotion":
                weaponControl    = picArmaPocaoAzul;
                inventoryControl = picPocaoAzul;
                break;

            case "Bow":
                weaponControl    = picArmaArco;
                inventoryControl = picArco;
                break;

            case "Mace":
                weaponControl    = picArmaBastao;
                inventoryControl = picBastao;
                break;

            case "RedPotion":
                weaponControl    = picArmaPocaoVermelha;
                inventoryControl = picPocaoVermelha;
                break;

            default:
                break;
            }

            List <string> weapons = game.PlayerWeapons;

            foreach (string weapon in weapons)
            {
                switch (weapon)
                {
                case "Sword":
                    picEspada.Visible = true;
                    break;

                case "BluePotion":
                    picPocaoAzul.Visible = true;
                    break;

                case "RedPotion":
                    picPocaoVermelha.Visible = true;
                    break;

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

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

                default:
                    break;
                }
            }

            weaponControl.Location = game.WeaponInRoom.Location;
            if (game.WeaponInRoom.PickedUp)
            {
                weaponControl.Visible = false;

                if (game.WeaponInRoom is BluePotion)
                {
                    BluePotion potion = game.WeaponInRoom as BluePotion;
                    if (potion.Used == false)
                    {
                        inventoryControl.Visible = true;
                    }
                    else
                    {
                        inventoryControl.Visible = false;
                    }
                }
                else if (game.WeaponInRoom is RedPotion)
                {
                    RedPotion potion = game.WeaponInRoom as RedPotion;
                    if (potion.Used == false)
                    {
                        inventoryControl.Visible = true;
                    }
                    else
                    {
                        inventoryControl.Visible = false;
                    }
                }
                else
                {
                    inventoryControl.Visible = true;
                }
            }
            else
            {
                weaponControl.Visible    = true;
                inventoryControl.Visible = false;
            }
            if (game.PlayerHitPoints <= 0)
            {
                MessageBox.Show("Você Morreu", "Fim");
                Application.Exit();
            }
            if (enemiesShown < 1)
            {
                MessageBox.Show("Você derrotou todos os inimigos neste nivel", "Parabéns");
                game.NewLevel(random);
                UpdateCharacters();
            }
        }
示例#9
0
        public void NewLevel(Random random)
        {
            level++;
            switch (level)
            {
            case 1:
                Enemies = new List <Enemy>()
                {
                    new Bat(this, GetRandomLocation(random)),
                };
                WeaponInRoom = new Sword(this, GetRandomLocation(random));
                break;

            case 2:
                Enemies = new List <Enemy>()
                {
                    new Ghost(this, GetRandomLocation(random)),
                };
                WeaponInRoom = new BluePotion(this, GetRandomLocation(random));
                break;

            case 3:
                Enemies = new List <Enemy>()
                {
                    new Ghoul(this, GetRandomLocation(random)),
                };
                WeaponInRoom = new Bow(this, GetRandomLocation(random));
                break;

            case 4:
                Enemies = new List <Enemy>()
                {
                    new Bat(this, GetRandomLocation(random)), new Ghost(this, GetRandomLocation(random)),
                };
                if (!CheckPlayerInventory("Łuk"))
                {
                    WeaponInRoom = new Bow(this, GetRandomLocation(random));
                }
                else if (!CheckPlayerInventory("Niebieska Mikstura"))
                {
                    WeaponInRoom = new BluePotion(this, GetRandomLocation(random));
                }
                break;

            case 5:
                Enemies = new List <Enemy>()
                {
                    new Bat(this, GetRandomLocation(random)), new Ghoul(this, GetRandomLocation(random)),
                };
                WeaponInRoom = new RedPotion(this, GetRandomLocation(random));
                break;

            case 6:
                Enemies = new List <Enemy>()
                {
                    new Ghost(this, GetRandomLocation(random)), new Ghoul(this, GetRandomLocation(random)),
                };
                WeaponInRoom = new Mace(this, GetRandomLocation(random));
                break;

            case 7:
                Enemies = new List <Enemy>()
                {
                    new Bat(this, GetRandomLocation(random)), new Ghost(this, GetRandomLocation(random)), new Ghoul(this, GetRandomLocation(random)),
                };
                if (!CheckPlayerInventory("Maczuga"))
                {
                    WeaponInRoom = new Mace(this, GetRandomLocation(random));
                }
                else if (!CheckPlayerInventory("Czerwona Mikstura"))
                {
                    WeaponInRoom = new RedPotion(this, GetRandomLocation(random));
                }
                break;

            case 8:
                MessageBox.Show("Brawo! Zakończyłeś pomyślnie ostatni poziom!");
                Application.Exit();
                break;
            }
        }