Ejemplo n.º 1
0
        /// <summary>
        /// This method disables the current map and creates the next map and graph and sets it as the current.
        /// </summary>
        public static void SwitchToNextMap()
        {
            if (currentManager != null)
            {
                // Destroy the current map, and graph components attached this game object.
                currentManager.gameObject.Destroy(drawnMaps[currentMap]);
                currentManager.gameObject.Destroy(drawnGraphs[currentMap]);

                //It first grabs the current map and disables it.
                Map mapBeingDisabled = CurrentMap();

                if (mapBeingDisabled != null)
                {
                    mapBeingDisabled.gameObject.SetActiveRecursively(false);
                    ++currentMap;
                }

                //Then the next map and graph are created and the current map is set to it.
                Map mapBeingCreated = new Map(mapWidth, mapHeight, mapLevel);

                drawnMaps.Add(mapBeingCreated);

                currentManager.gameObject.AddComponent(mapBeingCreated);

                NavigatorMap graphBeingCreated = new NavigatorMap();

                drawnGraphs.Add(graphBeingCreated);

                currentManager.gameObject.AddComponent(graphBeingCreated);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// In the start() method, it first checks if it's the only MapManager. If it is
 /// it generates the first map and set it to the current map.
 /// </summary>
 public override void Start()
 {
     //If there is another MapManager, this instance doesn't make any changes.
     if (currentManager == null || currentManager == this)
     {
         //Otherwise, it sets itself as the current MapManager.
         currentManager = this;
         if (drawnMaps.Count == 0)
         {
             //It then generates the first map and Nabigator
             Map firstMap = new Map(mapWidth, mapHeight, mapLevel);
             drawnMaps.Add(firstMap);
             gameObject.AddComponent(firstMap);
             NavigatorMap firstGraph = new NavigatorMap();
             drawnGraphs.Add(firstGraph);
             gameObject.AddComponent(firstGraph);
         }
         else
         {
             Debug.LogWarning("There should only be one instance of MapManager.");
         }
     }
 }