public void Create(int width, int height, StageOption stageOption) { if (width <= 0 || height <= 0) { Debug.LogError("width, height は1以上にする必要があります。"); width = (width <= 0) ? 4 : width; height = (height <= 0) ? 4 : height; } Reset(width, height); foreach (var obj in Map) { var tile = obj.GetComponent <Tile>(); var pos = tile.Pos; for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { var x = (int)pos.x + j; var y = (int)pos.y + i; if ((i == 0 && j == 0) || !(0 <= x && x < Width) || !(0 <= y && y < Height)) { continue; } tile.AddAroundTile(Map[y, x].GetComponent <Tile>()); } } } foreach (var enemy in stageOption.SpawnTable) { SetContents(new Enemy(enemy)); } for (int i = 0; i < stageOption.PickPoint; i++) { var items = new List <ItemData>(); var value = UnityEngine.Random.Range(1, 5); foreach (var data in RandomWithWeight.Lottos <ItemData>(_order.Data.ItemTable, value)) { var item = ScriptableObject.Instantiate(data); var characteristics = RandomWithWeight.Lottos <CharacteristicsData>(_order.Data.CharacteristicsTable, UnityEngine.Random.Range(0, 3)); item.Quality = (int)_order.Data.QualityRange.randomValue; item.Init(characteristics.Distinct(new ObjectCompare <CharacteristicsData>())); items.Add(item); } SetContents(new Pick(items)); } if (NowFloor < _order.Data.Floor) { SetContents(new Stair()); } else { SetContents(new Exit()); } _info.ShowContents(stageOption); _info.SetFloor(_order.Data.Name + NowFloor + "F"); _info.SetTimer(stageOption.Openable); }
public void Next() { var size = UnityEngine.Random.Range(4, 7); var enemy = (int)(Mathf.Pow(size, 2) * _order.Data.SpawnRate); var pickPoint = (int)(Mathf.Pow(size, 2) * _order.Data.PickRate); var option = new StageOption() { Enemy = enemy, PickPoint = pickPoint, Openable = (int)(Mathf.Pow(size, 2) * _order.Data.OpenableRate), SpawnTable = RandomWithWeight.Lottos <EnemyData>(_order.Data.SpawnTable, enemy), }; NowFloor++; Create(size, size, option); }