/// <summary> /// バトル開始 /// </summary> /// <returns></returns> public static AsyncSubject <List <LootItemStruct> > BootBattle() { AsyncSubject <List <LootItemStruct> > subject = new AsyncSubject <List <LootItemStruct> >(); var dungeon = DungeonDictionary.GetDungeonMapData(DungeonDataModel.Instance.DungeonId); var enemies = BattleLogic.EnemiesChoice(); var enemyDataModel = EnemyDataModel.Instance; enemyDataModel.Initialize(); enemies.Enemies.ForEach(enemyId => { float level = Random.Range(dungeon.enemyLevel.min, dungeon.enemyLevel.max); level = level * DungeonDataModel.Instance.Location.y + 1; level += enemies.AddLevel; enemyDataModel.Add(EnemyLogic.Create(enemyId, (int)level)); }); _battleScene = Object.Instantiate((GameObject)Resources.Load("Prefabs/Scene/Battle"), Vector3.zero, Quaternion.identity); _battleScene.transform.Find("FrontCanvas").GetComponent <Canvas>().worldCamera = GameObject.Find("MainCamera").GetComponent <Camera>(); var battleManager = _battleScene.transform.Find("System").GetComponent <BattleManager>(); battleManager.Initialize(); battleManager.EndBattle.Subscribe(loots => { subject.OnNext(loots); subject.OnCompleted(); }); return(subject); }
/// <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> /// <returns></returns> public static List <LootItemStruct> DungeonLootChoice(float rate = 1) { //ダンジョン固有アイテムも抽選する var dungeonData = DungeonDictionary.GetDungeonMapData(DungeonDataModel.Instance.DungeonId); var drops = DropLottery(dungeonData.drops, rate); return(drops); }
private static int GetMapFloorSize(string dungeonId) { int count = 0; var map = DungeonDictionary.GetDungeonMapData(dungeonId).map; count += map.battle; count += map.boss; count += map.elite; count += map.evt; count += map.treasure; return(count); }
public static void CreateMap(string dungeonId) { DungeonSerializable dungeonData = DungeonDictionary.GetDungeonMapData(dungeonId); var model = DungeonDataModel.Instance; model.Location = new Vector3Int(DungeonConsts.WIDTH_SIZE / 2, -1, 0); model.DungeonId = dungeonId; model.DungeonFloorSize = GetMapFloorSize(dungeonId); model.DungeonFloor = new DungeonDataModel.DungeonFloorStruct[DungeonConsts.WIDTH_SIZE][]; for (int x = 0; x < DungeonConsts.WIDTH_SIZE; x++) { //model.DungeonFloor[x] = new DungeonEnum.Tiles[floorSize]; model.DungeonFloor[x] = new DungeonDataModel.DungeonFloorStruct[model.DungeonFloorSize]; DungeonEventCreateLogic choice = new DungeonEventCreateLogic(); choice.Add(dungeonData.map.battle, DungeonEnum.Tiles.Battle); choice.Add(dungeonData.map.elite, DungeonEnum.Tiles.Elite); choice.Add(dungeonData.map.evt, DungeonEnum.Tiles.Evt); choice.Add(dungeonData.map.treasure, DungeonEnum.Tiles.Treasure); for (int y = 0; y < model.DungeonFloorSize; y++) { //最初の左右、ボス前の左右、ボス以外はブランク if (IsBlank(x, y, dungeonId)) { //model.DungeonFloor[x][y] = DungeonEnum.Tiles.Blank; model.DungeonFloor[x][y] = new DungeonDataModel.DungeonFloorStruct() { Tile = DungeonEnum.Tiles.Blank, Enabled = false }; } else { model.DungeonFloor[x][y] = new DungeonDataModel.DungeonFloorStruct() { Tile = choice.ChoicePickOut(), Enabled = true }; //model.DungeonFloor[x][y] = choice.ChoicePickOut(); } /*//最初は雑魚バトル確定 * if (y == 1 && x != 0 && x != DungeonConsts.WIDTH_SIZE - 1) * model.DungeonCell[x][y] = DungeonEnum.Events.Battle;*/ //最終フロアの中央はボス /*if (y == floorSize && x == (int) (DungeonConsts.WIDTH_SIZE / 2)) * model.DungeonCell[x][y] = DungeonEnum.Events.Boss;*/ } } }
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 }); }