예제 #1
0
        /// <summary>
        /// Creates the level.
        /// </summary>
        /// <param name="jsonText">The JSON text to create the level with.</param>
        private void CreateLevel(string jsonText)
        {
            Debug.Log(jsonText);

            JSONObject input = new JSONObject(jsonText);

            JSONObject    lemmingsJSON  = input.GetField("lemmings");
            LemmingsInput lemmingsInput = new LemmingsInput(lemmingsJSON);

            JSONObject goalJSON  = input.GetField("goal");
            GoalInput  goalInput = new GoalInput(goalJSON);

            CreateLemmings(lemmingsInput);
            CreateGoal(goalInput);

            CreateBoundingBoxes(input);

            JSONObject routeJSON = input.GetField("route");

            if (routeJSON != null)
            {
                RouteInput routeInput = new RouteInput(routeJSON);
                RouteRenderer.instance.DrawRoute(lemmingsInput.position, routeInput.route, goalInput.position);
            }

            LevelLogger.instance.json = jsonText;
            gameManager.isLoading     = false;
            GameManager.numDeaths     = 0;
            gameManager.CountDownStart();
        }
예제 #2
0
 /// <summary>
 /// Creates the lemmings in the level.
 /// </summary>
 /// <param name="lemmingsInput">JSON data for the starting points of the lemmings.</param>
 private void CreateLemmings(LemmingsInput lemmingsInput)
 {
     if (lemmingsInput.amount > 0)
     {
         Vector3        rotation = new Vector3(0, lemmingsInput.rotation, 0);
         LemmingSpawner spawner  = ObjectUtil.Instantiate(lemmingSpawnerPrefab, lemmingsInput.position, rotation) as LemmingSpawner;
         spawner.totalLemmings = lemmingsInput.amount;
         GameManager.instance.lemmingSpawner = spawner;
     }
 }