Exemple #1
0
    public bool GenDungeon(int seed = -1)
    {
        if (PeGameMgr.IsSingle)
        {
            RandomDungenMgrData.DungeonId++;
        }

        generator = new DungeonGenerator(dungeonData.dungeonFlowPath);
        manager.transform.position = RandomDungenMgrData.genDunPos;
        if (manager == null || manager.transform == null)
        {
            Debug.LogError("manager==null||manager.transform==null!");
            return(false);
        }
        bool genSuccess = false;

        if (seed == -1)
        {
            genSuccess = generator.Generate(manager);            //new
            if (!genSuccess)
            {
                return(false);
            }
            Debug.Log("gen success without seed");
            GenWater_SafeBottom(RandomDungenMgrData.waterType);
            GeneralSet(true);
            GenContent();
        }
        else
        {
            genSuccess = generator.GenerateWithSeed(manager, seed);
            if (!genSuccess)
            {
                return(false);
            }
            Debug.Log("gen success with seed");
            GenWater_SafeBottom(RandomDungenMgrData.waterType);
            GeneralSet(true);
        }
        if (PeGameMgr.IsSingle)
        {
        }

        if (PeGameMgr.IsMulti)
        {
            seed = generator.ChosenSeed;
            PlayerNetwork.mainPlayer.RequestUploadDungeonSeed(RandomDungenMgrData.entrancePos, seed);
            Debug.Log("dun Seed: " + seed);

            ChangeOther(true);
        }
        Debug.Log("RemoveTerrainDependence");
        SceneMan.RemoveTerrainDependence();
        return(genSuccess);
    }