Exemple #1
0
        public void FromJSON(FloorController api, JSONNode root)
        {
            Rectangle r = GetComponent <Rectangle>();

            r.SetCenter(new Vector2(root["center_x"].AsFloat, root["center_y"].AsFloat));
            r.SetSize(new Vector2(root["width"].AsFloat, root["height"].AsFloat));
            r.SetRotation(root["rotation"].AsFloat);

            foreach (JSONNode node in root["aisles"].AsArray)
            {
                Aisle aisle = api.CreateAisle(Rect.zero, false, true, true);
                aisle.transform.SetParent(container, false);
                aisle.FromJSON(api, node);
            }
        }
Exemple #2
0
        /// <summary>
        /// Overwrites this floor's content with JSON object root.
        /// </summary>
        /// <param name = "api">The FloorController.</param>
        /// <param name="root">Root.</param>
        public void FromJSON(FloorController api, JSONNode root)
        {
            if (root == null)
            {
                return;
            }

            floorId    = root["floor_id"];
            floorName  = root["floor_name"];
            floorOrder = root["floor_order"];
            libraryId  = root["library"];

            if (api == null)
            {
                // Not ready to expand yet!
                floorJSONCache = root.ToString();
                return;
            }

            aisles.Clear();
            aisleAreas.Clear();
            walls.Clear();
            landmarks.Clear();

            foreach (JSONObject obj in root["aisles"].AsArray)
            {
                Aisle aisle = api.CreateAisle(Rect.zero, false, true);
                aisle.FromJSON(api, obj);
            }

            foreach (JSONObject obj in root["aisle_areas"].AsArray)
            {
                AisleArea aisleArea = api.CreateAisleArea(Rect.zero, false, true);
                aisleArea.FromJSON(api, obj);
            }

            foreach (JSONObject obj in root["walls"].AsArray)
            {
                Wall wall = api.CreateWall(Vector2.zero, Vector2.zero, false, true);
                wall.FromJSON(api, obj);
            }

            foreach (JSONObject obj in root["landmarks"].AsArray)
            {
                Landmark landmark = api.CreateLandmark(Rect.zero, false, true);
                landmark.FromJSON(api, obj);
            }
        }