Esempio n. 1
0
    private void Awake()
    {
        pixelShader   = Resources.Load <Material>("Materials/PixelSnapMat");
        ground        = Resources.Load <Tile>("Tiles/Ground_Tile");
        backGround    = Resources.Load <Tile>("Tiles/BackGround_Tile");
        SpawnerPrefab = Resources.Load <GameObject>("Prefabs/Spawner");
        chunkSize     = GameManager.Instance.Settings.chunkSize;

        width  = worldInfo.worldSizeInChunks.x;
        heigth = worldInfo.worldSizeInChunks.y;

        if (worldInfo.chunks == null)
        {
            worldInfo.chunks = new ChunkInfo[width][];
            for (int i = 0; i < width; i++)
            {
                worldInfo.chunks[i] = new ChunkInfo[heigth];
            }
        }


        SetWorldColor(worldInfo.color);

        Physics2D.gravity = new Vector2(0, worldInfo.gravity);

        int layers = 2;

        for (int i = 0; i < layers; i++)
        {
            tileMaps.Add(SetupTilemap());
        }
        SetDungeons();
        SetUpWorld();
        navMesh = NodeNavMesh.CreateNavMesh(gameObject, tileMaps[0]);
        tileMaps[0].GetComponent <TilemapRenderer>().material = Resources.Load <Material>("Materials/GoundMat");
        tileMaps[0].GetComponent <TilemapRenderer>().material.SetColor("_Color1", worldInfo.color);

        SetSpawners();
        SetWorldLimits();
        FindObjectOfType <Player>().OnDiggingToDir += CheckDestruction;
        worldInfo.Save();
        TransformUtility.ChangeLayersRecursively(transform, gameObject.layer);
    }
Esempio n. 2
0
    List <WorldInfo> GetWorlds()
    {
        if (worlds.Count == 0)
        {
            List <WorldInfo> LoadedWorlds = XMLManager.LoadFolderData <WorldInfo>(XMLManager.WORLDINFO_FOLDER_NAME + "GeneratedWorlds");
            int remanigForCreate          = settings.numOfWorlds - LoadedWorlds.Count;

            if (remanigForCreate > 0)
            {
                for (int i = 0; i < remanigForCreate; i++)
                {
                    WorldInfo info = GenerateWorldInfo(settings.dificulty);
                    info.Save();
                    LoadedWorlds.Add(info);
                }
            }
            worlds        = LoadedWorlds;
            SelectedWorld = worlds[0];
        }

        return(worlds);
    }