示例#1
0
    IEnumerator LoadGameLevel(string levelName)
    {
        yield return(StartCoroutine(FadeScript.instance.FadeOut()));

        FadeScript.instance.gameObject.SetActive(false);
        _levelLoadingUI.SetActive(true);

        StaticMapInfo.SetLevelLoadData(levelName, true);
        AsyncOperation asyncMaster = SceneManager.LoadSceneAsync("Master");
        AsyncOperation asyncLevel  = SceneManager.LoadSceneAsync(levelName, LoadSceneMode.Additive);

        asyncMaster.allowSceneActivation = false;
        asyncLevel.allowSceneActivation  = false;

        //_isLoading = true;

        while (asyncMaster.progress < 0.9f && asyncLevel.progress < 0.9f)
        {
            yield return(null);
        }

        yield return(new WaitForSeconds(1f));

        yield return(StartCoroutine(FadeScript.instance.FadeOut()));

        asyncMaster.allowSceneActivation = true;
        asyncLevel.allowSceneActivation  = true;

        while (!SceneManager.GetSceneByName(levelName).isLoaded)
        {
            yield return(null);
        }

        SceneManager.UnloadSceneAsync(SceneManager.GetActiveScene().name);
    }
示例#2
0
 /// <summary>
 /// Go to level editor scene
 /// </summary>
 public void LevelEditor()
 {
     // _soundManager.ButtonClick();
     StaticMapInfo.LoadingIntoLevelEditor = true;
     StaticMapInfo.SetLevelLoadData("", false);
     StaticMapInfo.LevelEditorMode = WorldController.CurrentGameMode.Editor;
     StartCoroutine(FadeLoad("Master"));
 }
示例#3
0
 public void LoadMap(string mapName, bool IsResource)
 {
     _yourMapsPanel.SetActive(false);
     StaticMapInfo.LevelEditorLevel = mapName;
     StaticMapInfo.LoadIntoEditor(false);
     StaticMapInfo.SetLevelLoadData(mapName, false);
     LoadLevelSceneScript.instance.StartLoadLevel(StaticMapInfo.Level);
 }
示例#4
0
    IEnumerator LoadLevel(string levelName, bool res)
    {
        StaticMapInfo.SetLevelLoadData(levelName, res);
        AsyncOperation asyncMaster = SceneManager.LoadSceneAsync("Master");

        _levelLoadingUI.SetActive(true);
        //_isLoading = true;
        asyncMaster.allowSceneActivation = false;

        while (asyncMaster.progress < 0.9f)
        {
            yield return(null);
        }

        asyncMaster.allowSceneActivation = true;
    }
示例#5
0
 /// <summary>
 /// Checks all tiles, and ajusts walls
 /// </summary>
 static public void RockProximty()
 {
     for (int x = 0; x < Map.GridXSize_; x++)
     {
         for (int y = 0; y < Map.GridYSize_; y++)
         {
             Tile tile = StaticMapInfo.Map.GetTileAtPos(x, y);
             if (tile.tag == "RockTile")
             {
                 RockScript tileRockSript = tile.GetComponent <RockScript>();
                 tileRockSript.RockNorth     = StaticMapInfo.isWall(x, y + 1);
                 tileRockSript.RockNorthEast = StaticMapInfo.isWall(x + 1, y + 1);
                 tileRockSript.RockEast      = StaticMapInfo.isWall(x + 1, y);
                 tileRockSript.RockSouthEast = StaticMapInfo.isWall(x + 1, y - 1);
                 tileRockSript.RockSouth     = StaticMapInfo.isWall(x, y - 1);
                 tileRockSript.RockSouthWest = StaticMapInfo.isWall(x - 1, y - 1);
                 tileRockSript.RockWest      = StaticMapInfo.isWall(x - 1, y);
                 tileRockSript.RockNorthWest = StaticMapInfo.isWall(x - 1, y + 1);
             }
         }
     }
 }
示例#6
0
 void Awake()
 {
     StaticMapInfo.SetLevelLoadData(LevelName, true);
 }
    void RockProximty()
    {
        float             navMeshSize     = 5;
        float             tilesize        = StaticMapInfo.RockModleHolder.DefultTile.GetComponent <MeshRenderer>().bounds.size.x / 2;
        WorldController   worldController = WorldController.GetWorldController;
        List <GameObject> ambientObjects  = StaticMapInfo.RockModleHolder.AmbientObjects;
        List <Vector3>    oldVector3      = new List <Vector3>();
        List <float>      oldSize         = new List <float>();

        worldController._landslideRocks.Clear();
        worldController._defultTile.Clear();
        for (int x = 0; x < _TileMap.GridXSize_; x++)
        {
            for (int y = 0; y < _TileMap.GridYSize_; y++)
            {
                Tile tile = StaticMapInfo.Map.GetTileAtPos(x, y);
                if (tile.tag == "RockTile")
                {
                    RockScript tileRockSript = tile.GetComponent <RockScript>();
                    if (tileRockSript.RockType != RockScript.Type.SolidRock)
                    {
                        worldController._landslideRocks.Add(tileRockSript);
                    }

                    tileRockSript.RockNorth     = StaticMapInfo.isWall(x, y + 1);
                    tileRockSript.RockNorthEast = StaticMapInfo.isWall(x + 1, y + 1);
                    tileRockSript.RockEast      = StaticMapInfo.isWall(x + 1, y);
                    tileRockSript.RockSouthEast = StaticMapInfo.isWall(x + 1, y - 1);
                    tileRockSript.RockSouth     = StaticMapInfo.isWall(x, y - 1);
                    tileRockSript.RockSouthWest = StaticMapInfo.isWall(x - 1, y - 1);
                    tileRockSript.RockWest      = StaticMapInfo.isWall(x - 1, y);
                    tileRockSript.RockNorthWest = StaticMapInfo.isWall(x - 1, y + 1);
                }
                else if (tile.tag == "Floor")
                {
                    worldController._defultTile.Add(tile);
                    int ambinetObjectsAmount = 0;

                    if (!(StaticMapInfo.isWall(x, y + 1) ||
                          StaticMapInfo.isWall(x + 1, y + 1) ||
                          StaticMapInfo.isWall(x + 1, y) ||
                          StaticMapInfo.isWall(x + 1, y - 1) ||
                          StaticMapInfo.isWall(x, y - 1) ||
                          StaticMapInfo.isWall(x - 1, y - 1) ||
                          StaticMapInfo.isWall(x - 1, y) ||
                          StaticMapInfo.isWall(x - 1, y + 1)))
                    {
                        ambinetObjectsAmount = 3;
                    }

                    if (!StaticMapInfo.IsLevelInBuilt && WorldController.IsPlaying())
                    {
                        GameObject ranAmbentObject = ambientObjects[UnityEngine.Random.Range(0, ambientObjects.Count)];
                        if (ranAmbentObject != null)
                        {
                            if (ranAmbentObject.tag == "LightAmbent")
                            {
                                float scale = UnityEngine.Random.Range(0.4f, 1.1f);
                                ranAmbentObject.transform.localScale = new Vector3(scale, scale, scale);
                            }
                            MeshRenderer[] objectMeshRenders = ranAmbentObject.GetComponentsInChildren <MeshRenderer>();

                            float ranAmbentObjectSize = 0;

                            for (int i = 0; i < objectMeshRenders.Length; i++)
                            {
                                Vector3 objectSize = objectMeshRenders[i].bounds.size;
                                if (objectSize.x > ranAmbentObjectSize || objectSize.z > ranAmbentObjectSize)
                                {
                                    ranAmbentObjectSize = Mathf.Max(objectSize.x, objectSize.z);
                                }
                            }

                            if (ranAmbentObjectSize != 0)
                            {
                                ranAmbentObjectSize /= 2;
                                for (int i = 0; i < ambinetObjectsAmount; i++)
                                {
                                    bool    foundPos        = false;
                                    int     reposisionTimes = 0;
                                    Vector3 vector3;

                                    do
                                    {
                                        float tileOutlier = tilesize - ranAmbentObjectSize;
                                        vector3    = new Vector3(UnityEngine.Random.Range(-tileOutlier, tileOutlier), 0, UnityEngine.Random.Range(-tileOutlier, tileOutlier));
                                        vector3.x += tile.transform.position.x;
                                        vector3.z += tile.transform.position.z;

                                        if (oldVector3.Count == 0)
                                        {
                                            foundPos = true;
                                        }
                                        else
                                        {
                                            bool continueLoop = true;
                                            for (int n = 0; n < oldVector3.Count && continueLoop; n++)
                                            {
                                                if (Vector3.Distance(oldVector3[n], vector3) > oldSize[n] + navMeshSize + ranAmbentObjectSize)
                                                {
                                                    foundPos = true;
                                                }
                                                else
                                                {
                                                    foundPos     = false;
                                                    continueLoop = false;
                                                }
                                            }
                                            reposisionTimes++;
                                        }
                                    }while (reposisionTimes <= 10 && !foundPos);
                                    if (foundPos)
                                    {
                                        GameObject ambientObject = Instantiate(ranAmbentObject, vector3, new Quaternion(0, 0, 0, 0));
                                        oldVector3.Add(vector3);
                                        oldSize.Add(ranAmbentObjectSize);
                                        ambientObject.transform.parent = tile.transform;

                                        ambientObject.transform.Rotate(0, UnityEngine.Random.Range(0, 360), 0);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }