private void PlaceEquipment()
 {
     foreach (var room in _map.Rooms)
     {
         if (Dice.Roll("1D10") < 3)
         {
             if (_map.DoesRoomHaveWalkableSpace(room))
             {
                 Point randomRoomLocation = _map.GetRandomLocationInRoom(room);
                 if (randomRoomLocation != null)
                 {
                     Equipment equipment;
                     try
                     {
                         equipment = _equipmentGenerator.CreateEquipment();
                     }
                     catch (InvalidOperationException)
                     {
                         // no more equipment to generate so just quit adding to this level
                         return;
                     }
                     Point location = _map.GetRandomLocationInRoom(room);
                     _map.AddTreasure(location.X, location.Y, equipment);
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 private void PlaceEquipment()
 {
     foreach (var room in _map.Rooms)
     {
         if (Dice.Roll("1D10") < 3)
         {
             if (_map.DoesRoomHaveWalkableSpace(room))
             {
                 Point randomRoomLocation = _map.GetRandomLocationInRoom(room);
                 if (randomRoomLocation != null)
                 {
                     Equipment equipment;
                     try
                     {
                         equipment = _equipmentGenerator.CreateEquipment();
                     }
                     catch (InvalidOperationException)
                     {
                         // no more equipment to generate so just quit adding to this level
                         return;
                     }
                     Point location = _map.GetRandomLocationInRoom(room);
                     equipment.go = GameObject.Instantiate <GameObject>(Game.Items[equipment.Name],
                                                                        new Vector2(location.X, location.Y), Quaternion.identity);
                     equipment.go.transform.SetParent(Game.itemsHolder);
                     equipment.go.GetComponent <Renderer>().enabled = false;
                     Game.ItemsTiles[location.X, location.Y]        = equipment;
                     _map.AddTreasure(location.X, location.Y, equipment);
                 }
             }
         }
     }
 }