コード例 #1
0
        /// <summary>
        /// Invokes when enemy die to gain expereince, gold and remove enemy from enemies list.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="enemyEventArgs"></param>
        public void OnEnemyDied(object sender, EnemyEventArgs enemyEventArgs)
        {
            BattleGround.BattleResult.AppendLine($"{enemyEventArgs.EnemyType} has been defeated by Player.");
            BattleGround.BattleResult.AppendLine($"Player won {enemyEventArgs.ExperienceGained} experience");
            BattleGround.BattleResult.AppendLine($"Player won {enemyEventArgs.GoldGained} gold");
            var potionGenerated = PotionGenerator.GeneratePotion();

            if (potionGenerated.PotionType != PotionType.None)
            {
                switch (potionGenerated.PotionType)
                {
                case PotionType.HealthPotion:
                    BattleGround.BattleResult.AppendLine($"Player obtained {potionGenerated.PotionType.ToString()}({potionGenerated.HealthBonus} health)");
                    break;

                case PotionType.XpPotion:
                    BattleGround.BattleResult.AppendLine($"Player obtained {potionGenerated.PotionType.ToString()}({potionGenerated.XpBonus} xp bonus)");
                    break;

                case PotionType.BonusDamagePotion:
                    BattleGround.BattleResult.AppendLine($"Player obtained {potionGenerated.PotionType.ToString()}({potionGenerated.DamageBonus} damage bonus)");
                    break;

                default:
                    break;
                }
                this.player.RecievePotion(potionGenerated);
            }
            this.player.GainGoldAndExperience(enemyEventArgs.ExperienceGained, enemyEventArgs.GoldGained);
            this.allEnemies = allEnemies.Where(e => e.IsAlive).ToList();
            this.dungeon[enemyEventArgs.Position.Row][enemyEventArgs.Position.Col] = ' ';
        }
コード例 #2
0
        private void InitLoot()
        {
            for (int i = 0; i < NUM_OF_LOOT; i++)
            {
                Potions.Add(PotionGenerator.GetPotion());
            }

            Random r = new Random();
            int    x, y;

            for (int i = 0; i < NUM_OF_LOOT; i++)
            {
                do
                {
                    x = r.Next(0, Height - 1);
                    y = r.Next(0, Width - 1);
                } while (Web[x, y] != '*');
                Web[x, y] = '$';
            }
        }
コード例 #3
0
    void Loot()
    {
        int temp = Random.Range(0, 3);

        if (temp == 0)
        {
            BaseArmour tempArmour = ArmourGenerator.generate(ctr);
            switch (tempArmour.Armour)
            {
            case (BaseArmour.ArmourTypes.HELMET):
                equip = tempArmour;
                break;

            case (BaseArmour.ArmourTypes.CHEST):
                equip2 = tempArmour;
                break;

            case (BaseArmour.ArmourTypes.BOOTS):
                equip3 = tempArmour;
                break;
            }
            Debug.Log("Armour drop");
        }
        else if (temp == 1)
        {
            weap = WeaponGenerator.generate(ctr);
            Debug.Log("Weapon drop");
        }
        else if (temp == 2)
        {
            BasePotion tempPot = PotionGenerator.generate(ctr);
            if (string.Compare(pot1.ItemName, "Empty") == 0)
            {
                pot1 = tempPot;
            }
            else if (string.Compare(pot2.ItemName, "Empty") == 0)
            {
                pot2 = tempPot;
            }
            else if (string.Compare(pot3.ItemName, "Empty") == 0)
            {
                pot3 = tempPot;
            }
            Debug.Log("Potion drop");
        }
        int diffrence = maxStamina - currStamina;

        maxStamina  = 40 + equip.Stamina + equip2.Stamina + equip3.Stamina + weap.Stamina;
        currStamina = 40 + equip.Stamina + equip2.Stamina + equip3.Stamina + weap.Stamina - diffrence;
        if (currStamina > maxStamina)
        {
            currStamina = maxStamina;
        }
        strength     = 3 + equip.Strength + equip2.Strength + equip3.Strength + weap.Strength;
        initiative   = 7 + equip.Initiative + equip2.Initiative + equip3.Initiative + weap.Initiative;
        weapon.text  = "Weapon: " + weap.ItemName;
        arm1.text    = "Helmet: " + equip.ItemName;
        arm2.text    = "Chestplate: " + equip2.ItemName;
        arm3.text    = "Boots: " + equip3.ItemName;
        potion1.text = "Potion1: " + pot1.ItemName;
        potion2.text = "Potion2: " + pot2.ItemName;
        potion3.text = "Potion3: " + pot3.ItemName;
    }