Exemplo n.º 1
0
    public void reloadRoom(Room roomT)
    {
        //TODO Remove offsets for positions dirty way
        //empty the room
        while (roomT.furnitures.Count > 0)
        {
            roomT.removeFurniture(roomT.furnitures [0]);
        }


        string xmlConfiguration = configurations[RandomHelper.nextInt(configurations.Count)];

        Catalog catalog = Catalog.getCatalog();

        XmlDocument doc = new XmlDocument();

        doc.LoadXml(RoomConcretizer.pickConcreteFurnitures(xmlConfiguration));

        XmlNode     room       = doc.SelectSingleNode("Room").SelectSingleNode("Furnitures");
        XmlNodeList furnitures = room.SelectNodes("Furniture");

        foreach (XmlNode furnitureNode in furnitures)
        {
            string id = furnitureNode.SelectSingleNode("CatalogId").InnerText;

            XmlNode positionNode = furnitureNode.SelectSingleNode("Position");
            Vector3 position     = new Vector3();
            position.x = (float)Convert.ToDouble(positionNode.Attributes["posX"].Value) * catalog.scale - 1.75F;
            position.y = (float)Convert.ToDouble(furnitureNode.Attributes["height"].Value) * catalog.scale / 2.0f;
            position.z = (float)Convert.ToDouble(positionNode.Attributes["posY"].Value) * catalog.scale - 2.04F;

            float angle = (float)Convert.ToDouble(furnitureNode.Attributes["rotation"].Value);

            if (id != null)
            {
                String     mid = id;
                GameObject fur = catalog.createFurniture(mid, position, angle, true);
                if (fur != null)
                {
                    fur.transform.SetParent(roomT.gameObject.transform);
                    roomT.addFurniture(fur.GetComponent <Furniture>());
                }
            }
        }
    }
Exemplo n.º 2
0
 public void Recolor(Room room)
 {
     RoomConcretizer.refurnish(room);
 }