Exemple #1
0
        public Enemy(Point point, char symbol, Container cont) : base(point, symbol, cont)
        {
            //MovesCountPerTurn = 2;
            //IsWounded = true;
            this.Symbol = symbol;

#if ASCII_BUILD
            color = ConsoleColor.Red;
#endif
            Alive = true;

            if (string.IsNullOrEmpty(Name) && symbol != EnemySymbols.CommonEnemySymbol)
            {
                Name = NameFromSymbol(symbol);
            }

            AddFightItem(FightItemKind.Stone);
            var knife = AddFightItem(FightItemKind.ThrowingKnife);
            AddFightItem(FightItemKind.ExplosiveCocktail);
            AddFightItem(FightItemKind.PoisonCocktail);
            //var net = AddFightItem(FightItemKind.WeightedNet);
            //fightItems[FightItemKind.HunterTrap] = new ProjectileFightItem(FightItemKind.HunterTrap, this) { Count = RandHelper.GetRandomInt(3) + 1 };

            SetActiveFightItem(RandHelper.GetRandomElem <FightItem>(this.fightItems.Values.ToList()).FightItemKind);
            //SetActiveFightItem(knife.FightItemKind);

            SetResist(EntityStatKind.ResistCold, 15);
            SetResist(EntityStatKind.ResistFire, 15);
            SetResist(EntityStatKind.ResistPoison, 15);
            SetResist(EntityStatKind.ResistLighting, 15);
        }
Exemple #2
0
        public Enemy(Point point, char symbol, Container cont) : base(point, symbol, cont)
        {
            //MovesCountPerTurn = 2;
            //IsWounded = true;
            this.Symbol = symbol;

#if ASCII_BUILD
            color = ConsoleColor.Red;
#endif
            Alive = true;

            if (string.IsNullOrEmpty(Name) && symbol != EnemySymbols.CommonEnemySymbol)
            {
                Name = NameFromSymbol(symbol);
            }

            AddFightItem(FightItemKind.Stone);
            AddFightItem(FightItemKind.ThrowingKnife);
            AddFightItem(FightItemKind.ExplosiveCocktail);
            AddFightItem(FightItemKind.PoisonCocktail);
            //fightItems[FightItemKind.HunterTrap] = new ProjectileFightItem(FightItemKind.HunterTrap, this) { Count = RandHelper.GetRandomInt(3) + 1 };

            this.ActiveFightItem = RandHelper.GetRandomElem <FightItem>(this.fightItems.Values.ToList());

            SetResist(EntityStatKind.ResistCold, 15);
            SetResist(EntityStatKind.ResistFire, 15);
            SetResist(EntityStatKind.ResistPoison, 15);
            SetResist(EntityStatKind.ResistLighting, 15);

            Stats.SetNominal(EntityStatKind.MeleeAttack, BaseStrength.Value.Nominal + 2);//attack is same as str for a simple entity
        }
Exemple #3
0
        public static float GetRandAttackVariation(float currentAttackValue, List <int> attackValueDecrease, bool signed)
        {
            var percentToDecrease = RandHelper.GetRandomElem(attackValueDecrease);
            var variation         = CalcPercentageValue(currentAttackValue, percentToDecrease);

            var sign = 1;

            if (signed)
            {
                sign = RandHelper.Random.NextDouble() > .5f ? -1 : 1;
            }

            return(sign * variation);
        }
Exemple #4
0
        public T RollDice(T unset, T[] skip, double factor = 0)
        {
            var rand = RandHelper.GetRandomDouble();

            if (factor != 0)
            {
                rand -= factor;
            }
            var matches = GetMatchesAboveThreashold(rand);

            if (matches.Any())
            {
                return(RandHelper.GetRandomElem <T>(matches, skip));
            }
            return(unset);
        }
 protected void MakeMagic(EquipmentClass eqClass, Equipment eq)
 {
     if (eq.Class == EquipmentClass.Unique)
     {
         return;
     }
     if (eq.IsPlain())
     {
         eq.MakeMagic();
     }
     if (!eq.IsSecondMagicLevel && eqClass == EquipmentClass.MagicSecLevel)
     {
         var stats = eq.GetPossibleMagicStats();
         var stat  = RandHelper.GetRandomElem(stats);
         eq.MakeMagicSecLevel(stat.Key, 3);//TODO !
     }
 }
Exemple #6
0
        protected Tuple <string, EquipmentMaterial> GetRandomFromList(int level, ref EquipmentMaterial mat, List <Equipment> plains)
        {
            Tuple <string, EquipmentMaterial> res = null;
            var eqsAtLevel = plains.Where(i => i.LevelIndex == level).ToList();

            var eq = RandHelper.GetRandomElem <Equipment>(eqsAtLevel);

            if (eq != null)
            {
                if (eq.IsMaterialAware() && mat == EquipmentMaterial.Unset)
                {
                    mat = EquipmentMaterial.Bronze;
                }
                res = new Tuple <string, EquipmentMaterial>(eq.tag1, mat);
            }

            return(res);
        }
Exemple #7
0
        private CraftingResult CraftOneEq(Equipment srcEq)
        {
            if (srcEq.WasCraftedBy(RecipeKind.TwoEq))
            {
                return(ReturnCraftingError("Can not craft equipment which was already crafted in pairs"));
            }
            ;

            var srcLootKind   = srcEq.EquipmentKind;
            var lks           = Equipment.GetPossibleLootKindsForCrafting().ToList();
            var destLk        = RandHelper.GetRandomElem <EquipmentKind>(lks, new EquipmentKind[] { srcLootKind });
            var lootGenerator = container.GetInstance <LootGenerator>();
            var destEq        = lootGenerator.GetRandomEquipment(destLk, srcEq.MinDropDungeonLevel, null);

            if (srcEq.Class == EquipmentClass.Magic)
            {
                destEq.SetClass(EquipmentClass.Magic, srcEq.MinDropDungeonLevel, null, srcEq.IsSecondMagicLevel);
            }
            var srcStatsCount = srcEq.GetMagicStats().Count;

            if (srcStatsCount > destEq.GetMagicStats().Count)
            {
                var diff = srcStatsCount - destEq.GetMagicStats().Count;
                for (int i = 0; i < diff; i++)
                {
                    destEq.AddRandomMagicStat();
                }
            }
            if (srcEq.Enchantable)
            {
                destEq.MakeEnchantable();
            }
            destEq.WasCrafted     = true;
            destEq.CraftingRecipe = RecipeKind.OneEq;
            return(ReturnCraftedLoot(destEq));
        }
 public Recipe GetRandomRecipe(int level)//TODO ! level
 {
     return(RandHelper.GetRandomElem <Recipe>(recipesPrototypes).Clone());
 }