/// <summary> /// ダンジョンからドロップを抽選する /// </summary> /// <returns></returns> public static List <LootItemStruct> DungeonTreasureLootChoice() { var dungeonData = DungeonDictionary.GetDungeonMapData(DungeonDataModel.Instance.DungeonId); //ドロップアイテムを抽選する var drops = DropLottery(dungeonData.drops); //最低一個は抽選する var choice = new WeightChoice <string>(); dungeonData.drops.ForEach(drop => { choice.Add(drop.rate, drop.itemId); }); var itemId = choice.ChoiceOne(); drops.Add(new LootItemStruct() { ItemId = itemId, Amount = 1 }); //レアリティの抽選を行う drops.ForEach(drop => { DropLottery(ref drop); }); return(drops); }
/// <summary> /// レアリティ抽選 /// </summary> /// <param name="loot"></param> private static void DropLottery(ref LootItemStruct loot) { var choice = new WeightChoice <RealityEnum.Reality>(); choice.Add(2000, RealityEnum.Reality.Common); choice.Add(1700, RealityEnum.Reality.UnCommon); choice.Add(1200, RealityEnum.Reality.Rare); choice.Add(1000, RealityEnum.Reality.Magic); choice.Add(500, RealityEnum.Reality.Ancient); choice.Add(250, RealityEnum.Reality.Epic); choice.Add(100, RealityEnum.Reality.Miracle); choice.Add(50, RealityEnum.Reality.Legend); choice.Add(1, RealityEnum.Reality.God); loot.Reality = choice.ChoiceOne(); }
public static EnemiesStruct EnemiesChoice() { var dungeonData = DungeonDictionary.GetDungeonMapData(DungeonDataModel.Instance.DungeonId); var floor = DungeonDataModel.Instance.Floor; //敵の数 int amountMin = 0; int amountMax = 0; var enemyAmountData = dungeonData.enemyAmount.FirstOrDefault(x => x.border > floor); if (enemyAmountData == null) { enemyAmountData = dungeonData.enemyAmount.Last(); } amountMin = enemyAmountData.min; amountMax = enemyAmountData.max; //敵の種類パターン var enemiesData = dungeonData.enemies.FirstOrDefault(x => x.border > floor); if (enemiesData == null) { enemiesData = dungeonData.enemies.Last(); } WeightChoice <string> choice = new WeightChoice <string>(); enemiesData.monsters.ForEach(enemy => { choice.Add(1, enemy); }); var amount = Random.Range(amountMin, amountMax); List <string> enemies = new List <string>(); for (var x = 0; x < amount; x++) { enemies.Add(choice.ChoiceOne()); } return(new EnemiesStruct() { Enemies = enemies, AddLevel = enemiesData.addLevel }); }
/// <summary> /// 対象の中からランダムで生きているのを返す /// 敵対値が考慮される /// </summary> /// <returns></returns> public static BattlerSerializable GetAliveBattlerByRandom(List <BattlerSerializable> battlers) { WeightChoice <BattlerSerializable> weightChoice = new WeightChoice <BattlerSerializable>(); battlers.ForEach(battler => { if (BattlerDictionary.IsDeadByUniqId(battler.uniqId) == false) { weightChoice.Add(battler.parameter.hostile, battler); } }); if (weightChoice.Count == 0) { return(null); } return(weightChoice.ChoiceOne()); }
public AiSelectSkillResultSerializableData SelectSkill(int uniqId) { BattlerSerializable battler = BattlerDictionary.GetBattlerByUniqId(uniqId); //スキルを無造作に選ぶ、アタックの重みは少ない var choice = new WeightChoice <string>(); foreach (var x in battler.skills) { var _skill = SkillsDicionary.GetSkillById(x); if (_skill.skillId == SkillIds.ATTACK) { choice.Add(SkillWeights.VERY_LOW, x); } else if (battler.parameter.mp >= _skill.mp) { choice.Add(SkillWeights.NORMAL, x); } } AiSelectSkillResultSerializableData result = new AiSelectSkillResultSerializableData(); var skill = SkillsDicionary.GetSkillById(choice.ChoiceOne()); if (battler.parameter.mp >= skill.mp) { switch (skill.target) { case SkillConsts.ENEMY: case SkillConsts.MEMBER: result.TargetUniqIds.Add( AiLogic.ChoiceBattlerByHostile(BattleDictionary.GetAliveRivalBattlers(battler.battlerType))); break; case SkillConsts.ALL_ENEMY: case SkillConsts.ALL_MEMBER: result.TargetUniqIds = BattleDictionary.GetRivalUniqIds(battler.battlerType); break; } result.SkillId = skill.skillId; } return(result); }