예제 #1
0
        override public JSONNode ToJson()
        {
            var main = base.ToJson();

            main["variety"] = Variety.ToString();

            return(main);
        }
예제 #2
0
        override public JSONNode ToJson()
        {
            var main = base.ToJson();

            JSONArray nestedEnvironments = new JSONArray();

            foreach (var environment in GetComponentsInChildren <Environment>())
            {
                if (environment == this || environment == null || environment.transform.parent != transform)
                {
                    continue;
                }

                nestedEnvironments.Add(environment.ToJson());
            }

            main["variety"]            = Variety.ToString();
            main["heightDelta"]        = HeightDelta.ToString();
            main["nestedEnvironments"] = nestedEnvironments;

            return(main);
        }
예제 #3
0
        public JSONNode ToJson()
        {
            if (!Validate())
            {
                return(null);
            }

            bool   boundsSet = false;
            Bounds bounds    = new Bounds();

            JSONArray environments = new JSONArray();

            foreach (var environment in GetComponentsInChildren <Environment>())
            {
                if (environment == null || environment.transform.parent.gameObject != gameObject)
                {
                    continue;
                }

                if (boundsSet)
                {
                    var localBounds = environment.Bounds;
                    bounds.Encapsulate(localBounds.min);
                    bounds.Encapsulate(localBounds.max);
                }
                else
                {
                    bounds    = environment.Bounds;
                    boundsSet = true;
                }
                environments.Add(environment.ToJson());
            }

            JSONArray linearObstacles = new JSONArray();

            foreach (var linearObstacle in GetComponentsInChildren <LinearObstacle>())
            {
                if (linearObstacle == null || linearObstacle.transform.parent.gameObject != gameObject)
                {
                    continue;
                }

                if (boundsSet)
                {
                    var localBounds = linearObstacle.Bounds;
                    bounds.Encapsulate(localBounds.min);
                    bounds.Encapsulate(localBounds.max);
                }
                else
                {
                    bounds    = linearObstacle.Bounds;
                    boundsSet = true;
                }
                linearObstacles.Add(linearObstacle.ToJson());
            }

            JSONArray center = new JSONArray();

            center.Add(bounds.center.x);
            center.Add(bounds.center.z);

            JSONArray size = new JSONArray();

            size.Add(bounds.size.x);
            size.Add(bounds.size.z);

            JSONObject main = new JSONObject();

            main["name"] = gameObject.name;
            main["baselineEnvironment"] = BaselineEnvironment.ToString();
            main["environments"]        = environments;
            main["linearObstacles"]     = linearObstacles;
            main["center"] = center;
            main["size"]   = size;

            return(main);
        }