// フロアにアイテムを配置する private void SetupFloorItem(int n, GameObject layer) { Assert.IsTrue(_fieldItems.Count == 0); var rand = new System.Random(); Room[] rooms = _floor.GetRooms(); for (int i = 0; i < n; i++) { const int tryCount = 10; for (int j = 0; j < tryCount; j++) { var loc = Utils.RandomRoomLoc(rooms.Choice()); // 既にアイテム配置済みなら置けない if (_fieldItems.Where(e => e.Loc == loc).Any()) { continue; } if (_floor.CanPutItem(loc)) { if (rand.Next(2) % 2 == 100) { var item = FieldItemFactory.CreateHerb(loc, 0); AddFieldItem(item); } else { //var item = FieldItemFactory.CreateHerb(loc, layer); var item = FieldItemFactory.CreateHerb(loc, 0); AddFieldItem(item); } // AddFieldItem(FieldItemFactory.CreateHerb(loc, layer)); break; } } } }