Exemple #1
0
    void StartGame(int randomSeed)
    {
        Random.InitState(randomSeed);
        cutsceneBars.gameObject.SetActive(true);

        tm.SpawnPlayer();
        tm.GenerateIslands();

        Player.instance.Init();
        GameObject.FindObjectOfType <MapReveal> ().Init();
        GameObject.FindObjectOfType <CameraController> ().Init();

        Mind[] minds = GameObject.FindObjectsOfType <Mind> ();
        foreach (Mind mind in minds)
        {
            mind.Init();
        }

        player = GameObject.Find("Player").GetComponent <Body> ();

        GameObject[] enemiesGOArray = GameObject.FindGameObjectsWithTag("Enemy");
        for (int i = 0; i < enemiesGOArray.Length; i++)
        {
            enemies.Add(enemiesGOArray [i].GetComponent <Body> ());
        }

        if (isLoadingFromSave)
        {
            foreach (SavedGame.SavedBuilding building in SavedGame.data.buildings)
            {
                building.Spawn();
            }

            foreach (SavedGame.SavedPickup pickup in SavedGame.data.pickups)
            {
                pickup.Spawn();
            }

            foreach (SavedGame.SavedResourceTile resourceTile in SavedGame.data.resourceTiles)
            {
                resourceTile.Spawn();
            }

            Crafting.instance.TestForCrafting();

            GetComponent <MapReveal> ().LoadSavedRevealArea();
        }

        print("Done loading");
        PlayerTurnStart();
        isLoadingFromSave = false;
    }