Exemplo n.º 1
0
 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);
 }