Exemplo n.º 1
0
 private void BuildMap(SerializableMap loadedMap)
 {
     if (terrainElementPrefab == null)
     {
         Debug.LogError($"{gameObject.name}: {nameof(terrainElementPrefab)} is not set. Could not build the map.");
         return;
     }
     if (characterPrefab == null)
     {
         Debug.LogError($"{gameObject.name}: {nameof(characterPrefab)} is not set. Could not build the map.");
         return;
     }
     terrainList = new List <TerrainElementHandler>();
     foreach (var terrainElement in loadedMap.terrainArray)
     {
         TerrainElementHandler loadedElement = Instantiate <TerrainElementHandler>(terrainElementPrefab, transform);
         loadedElement.InitializeTerrain(terrainElement);
         terrainList.Add(loadedElement);
     }
     charactersList = new List <CharacterHandler>();
     foreach (var characterElement in loadedMap.characterArray)
     {
         CharacterHandler loadedElement = Instantiate <CharacterHandler>(characterPrefab, transform);
         loadedElement.InitializeCharacter(characterElement);
         charactersList.Add(loadedElement);
     }
 }
Exemplo n.º 2
0
        public void GenerateTerrainElement()
        {
            TerrainElementHandler newTerrainElement = Instantiate <TerrainElementHandler>(terrainElementPrefab, transform);

            newTerrainElement.InitializeTerrain(new TerrainElement());
            if (terrainList == null)
            {
                terrainList = new List <TerrainElementHandler>();
            }
            UpdateMap();
        }