Esempio n. 1
0
    private IEnumerator LoadSave()
    {
        //Debug.Log("Seed:" + PlayerPrefs.GetInt("Seed"));

        myWorldGeneration.myUseSeed = true;
        GameInstance.GetInstance().SetSeed(PlayerPrefs.GetInt("Seed"));

        myWorldGeneration.GenerateWorld();

        //Debug.Log("PlayerRoomX:" + PlayerPrefs.GetInt("PlayerRoomX"));
        //Debug.Log("PlayerRoomY:" + PlayerPrefs.GetInt("PlayerRoomY"));
        //Debug.Log("PlayerBiomeX:" + PlayerPrefs.GetInt("PlayerBiomeX"));
        //Debug.Log("PlayerBiomeY:" + PlayerPrefs.GetInt("PlayerBiomeY"));

        while (!myWorldGeneration.myGenerationFinished)
        {
            yield return(null);
        }

        myWorldGeneration.ActivateBiome(PlayerPrefs.GetInt("PlayerBiomeX"), PlayerPrefs.GetInt("PlayerBiomeY"));
        Room theRoom = myWorldGeneration.ActivateRoom(PlayerPrefs.GetInt("PlayerRoomX"), PlayerPrefs.GetInt("PlayerRoomY"));

        myWorldGeneration.PlacePlayerInRoom(theRoom);

        myWorldGeneration.PlacePlayerAt(PlayerPrefs.GetFloat("PlayerX"), PlayerPrefs.GetFloat("PlayerY"));

        MapUI mapUI = FindObjectOfType <MapUI>();

        int roomVisited = PlayerPrefs.GetInt("RoomsVisited");

        for (int i = 0; i < roomVisited; ++i)
        {
            Biome biome = myWorldGeneration.GetBiome(PlayerPrefs.GetInt("Visited" + i + "BiomeX"), PlayerPrefs.GetInt("Visited" + i + "BiomeY"));

            mapUI.SetRoomVisited(PlayerPrefs.GetInt("Visited" + i + "RoomX"), PlayerPrefs.GetInt("Visited" + i + "RoomY"), biome);
        }

        myWorldGeneration.GetPlayerMovement().GetComponent <PlayerData>().SetSoulsCollected(PlayerPrefs.GetInt("PlayerSouls"));

        /*
         * PlayerPrefs.SetInt("ResourceNum", resourceToSave.Count);
         *
         * for (int i = 0; i < resourceToSave.Count; ++i)
         * {
         *  PlayerPrefs.SetInt("Resource" + i + "Life", resourceToSave[i].GetCurrentLife());
         *  PlayerPrefs.SetFloat("Resource" + i + "Time", resourceToSave[i].GetCurrentTimeToRefill());
         *  PlayerPrefs.SetInt("Resource" + i + "X", resourceToSave[i].GetTile().myTileData.myX);
         *  PlayerPrefs.SetInt("Resource" + i + "Y", resourceToSave[i].GetTile().myTileData.myY);
         *  PlayerPrefs.SetInt("Resource" + i + "BiomeX", resourceToSave[i].GetTile().myParentRoom.GetBiome().myX);
         *  PlayerPrefs.SetInt("Resource" + i + "BiomeY", resourceToSave[i].GetTile().myParentRoom.GetBiome().myY);
         * }
         */
    }
Esempio n. 2
0
    void Start()
    {
        gameObject.AddComponent <EntityManager>();
        Random.InitState(seed);
        spawnPosition = new Vector3(VoxelData.WorldSizeInVoxels / 2f, VoxelData.ChunkHeight - 150f, VoxelData.WorldSizeInVoxels / 2f);
        worldGen      = new WorldGeneration(this);
        worldGen.GenerateWorld();
        Player player = new Player(this, hightlightBlock, placeBlock, placeBlockMesh, debugOverlay);

        player.Start();
        player.position      = spawnPosition;
        playerLastChunkCoord = GetChunkCoord(player.position);
    }
Esempio n. 3
0
    void Update()
    {
        if (!start)
        {
            switch (stage)
            {
            case 0:
                counter_intro++;

                titleScreen.SetActive(true);
                titleText.position = new Vector3(titleText.position.x, initialTitlePositionY + 6 * Mathf.Sin(counter_intro * 2 * Mathf.Deg2Rad), 0);
                if (counter_intro > 90)
                {
                    textLeftSide.SetActive(true);
                    textRightSide.SetActive(true);

                    if (input._B || input._A)
                    {
                        if (input._B)
                        {
                            difficulty = 1;
                        }
                        if (input._A)
                        {
                            difficulty = 0;
                        }
                        SoundController.instance.PlaySound("snd_UI");
                        stage = 1;
                        StartCoroutine(world.GenerateWorld());
                    }
                }
                break;

            case 1:
                counter_continuous++;
                if (counter_continuous > 360)
                {
                    counter_continuous -= 360;
                }

                titleScreen.SetActive(false);
                instructionsScreen.SetActive(true);
                if (ready_to_start)
                {
                    if ((counter_continuous / 20) % 4 < 2)
                    {
                        pressKeyToBeginText.GetComponent <Text>().color = Colors.x_shadow;
                    }
                    else
                    {
                        pressKeyToBeginText.GetComponent <Text>().color = Colors.x_bush;
                    }
                    pressKeyToBeginText.SetActive(true);
                    if (input._B || input._A)
                    {
                        SoundController.instance.PlaySound("snd_UI");
                        start = true;
                        titleScreen.SetActive(false);
                        instructionsScreen.SetActive(false);
                        gameScreen.SetActive(true);
                    }
                }
                break;
            }
        }
    }