public void SetupScene(int level)
    {
        DungeonHelper.rooms.Clear();         //make sure we start with nothing
        DungeonHelper.deadEnds.Clear();

        DungeonHelper.width  = DungeonHelper.defaultWidth + (int)Mathf.Log(level, 2.5f);
        DungeonHelper.height = DungeonHelper.defaultHeight + (int)Mathf.Log(level, 2.5f);
        DungeonHelper.depth  = DungeonHelper.defaultDepth + (int)Mathf.Log(level, 2.5f);

        Room.setRoomSize(DungeonHelper.roomSize);
        Room.setDrawSpace(DungeonHelper.roomSize * DungeonHelper.spacing);

        seed = System.DateTime.Now.ToString();

        DungeonHelper.map = new Room[DungeonHelper.width, DungeonHelper.depth, DungeonHelper.height];

        //we are initialized so generate the map:
        int i = 0;

        while (!RandomFillMap())
        {
            if (i >= 5)
            {
                throw new ApplicationException("Could not find a map after 5 tries");
            }
            i++;
        }


        //set a spawnroom:
        int spawn = UnityEngine.Random.Range(0, DungeonHelper.rooms.Count);

        DungeonHelper.rooms [spawn].setType(Type.SPAWN);
        DungeonHelper.rooms [spawn].SetAccesibleFromSpawn();
        DungeonHelper.Spawn = DungeonHelper.rooms [spawn];

        //we have a filled map and list with Room objects, now we make it so that there's no 'unreachable' rooms:
        MakeRoomsAccesible();

        //Now that our rooms are all accessible from any other room(be it through other rooms or not)
        //we can start to generate a simple maze-like connection between the rooms using recursive backtracking in PathGenerator
        //The odd thing here is we do not define an exit yet, we will define the exit later with the requirement to be a dead end.
        //Also we'll add some keys and locks if the exit room is for instance right next to the spawn room, but what are the chances right? ...right...
        PathGenerator.GeneratePath(DungeonHelper.map, DungeonHelper.rooms);

        //We have a maze with a path, now we choose an exit room
        DungeonHelper.AssignExitRoom();

        //Exit room exists, almost done with the calculations, let's make it somewhat harder for the user to reach the exit room
        DungeonHelper.CalculateRequiredKeys();

        //let's add the right monsters and puzzles to the rooms shall we?
        DungeonHelper.AddGamePlay();

//		Debug.Log (DungeonHelper.rooms.Count);
//		DungeonHelper.rooms.ForEach (item => Debug.Log (item));
//		Debug.Log ("Required keys: " + DungeonHelper.RequiredKeys);
    }
    // 이용가능 체크
    public bool IsAvailiable()
    {
        if (DungeonHelper.IsCleared(OpenDungeon) || TimeHelper.IsInCurrent(StartDate, EndDate))
        {
            return(true);
        }

        return(false);
    }
Exemple #3
0
    void InitGame()
    {
        doingSetup = true;

        try{
            DungeonHelper.Generate(level, mapGen);
        }catch (ApplicationException e) {
            Debug.Log(e.Message);
            Destroy(gameObject);
            Application.Quit();
        }
    }
    // 튜토리얼 선행 조건 체크
    static public bool CheckCondition(TutorialInfo info)
    {
        ETutorialCondition conditionType  = (ETutorialCondition)info.GetStartData().GetCONDITION_TYPE();
        string             conditionValue = info.GetStartData().GetCONDITION_VALUE();

        switch (conditionType)
        {
        case ETutorialCondition.EnterDungeon:     // 던전 입장시
            DataDungeon enterData = DataDungeon.GetByEnumID(conditionValue);
            if (enterData != null && BattleInfo != null)
            {
                return(enterData == BattleInfo.DataDungeon);
            }
            break;

        case ETutorialCondition.ClearDungeon:     // 던전 클리어
            DataDungeon clearData = DataDungeon.GetByEnumID(conditionValue);
            if (clearData != null)
            {
                return(DungeonHelper.GetDungeonRating(clearData) > 0);
            }
            break;

        case ETutorialCondition.ClearTutorial:     // 튜토리얼 클리어
            DataTutorial tutorialData = DataTutorial.GetByEnumID(conditionValue);
            if (tutorialData != null)
            {
                ETutorialGroup group = (ETutorialGroup)tutorialData.GetGROUP_TYPE();
                return(IsClearByGroup(group));
            }
            break;

        case ETutorialCondition.ClearCompletion:     // 컴플리션 클리어
            DataCompletion completionData = DataCompletion.GetByEnumID(conditionValue);
            if (completionData != null)
            {
                CompletionInfo completeInfo = CompletionHelper.GetMyCompletion(completionData.GetID());
                if (completeInfo != null)
                {
                    return(CompletionHelper.IsComplete(completeInfo));
                }
            }
            break;

        case ETutorialCondition.None:
            return(true);
        }
        return(false);
    }
Exemple #5
0
    public static void GeneratePath(Room[,,] map, List <Room> rooms)
    {
        Room spawn = DungeonHelper.Spawn;
        int  N = 1, S = 2, E = 4, W = 8, U = 16, D = 32;

        List <int> directions = new List <int> ();

        directions.Add(N);
        directions.Add(S);
        directions.Add(E);
        directions.Add(W);
        directions.Add(U);
        directions.Add(D);

        Dictionary <int, int> DX = new Dictionary <int, int> ();

        DX.Add(E, 1);
        DX.Add(W, -1);
        DX.Add(N, 0);
        DX.Add(S, 0);
        DX.Add(U, 0);
        DX.Add(D, 0);

        Dictionary <int, int> DY = new Dictionary <int, int> ();

        DY.Add(E, 0);
        DY.Add(W, 0);
        DY.Add(N, 0);
        DY.Add(S, 0);
        DY.Add(U, 1);
        DY.Add(D, -1);

        Dictionary <int, int> DZ = new Dictionary <int, int> ();

        DZ.Add(E, 0);
        DZ.Add(W, 0);
        DZ.Add(N, -1);
        DZ.Add(S, 1);
        DZ.Add(U, 0);
        DZ.Add(D, 0);

        Dictionary <int, int> OPPOSITE = new Dictionary <int, int> ();

        OPPOSITE.Add(E, W);
        OPPOSITE.Add(W, E);
        OPPOSITE.Add(N, S);
        OPPOSITE.Add(S, N);
        OPPOSITE.Add(U, D);
        OPPOSITE.Add(D, U);

        Room current = spawn;

        Room[]      previous  = new Room[rooms.Count];
        List <Room> processed = new List <Room> ();
        int         i         = 0;

        while (current != spawn || processed.Count < rooms.Count)
        {
            bool connected = false;
            directions.Shuffle();
            if (!processed.Contains(current))
            {
                processed.Add(current);
            }
            //Debug.Log ("started");

            foreach (int direction in directions)
            {
                if (!DungeonHelper.IsInMapRange((int)current.getPosition().x + DX[direction], (int)current.getPosition().y + DY[direction], (int)current.getPosition().z + DZ[direction]))
                {
                    continue;
                }
                Room next = map[(int)current.getPosition().x + DX[direction], (int)current.getPosition().y + DY[direction], (int)current.getPosition().z + DZ[direction]];
                //Debug.Log ("trying: " + next);

                if (next != null && !processed.Contains(next))
                {
                    //Debug.Log ("Making connection between " + current + " and " + next);
                    Room.ConnectRooms(current, next);
                    previous[i] = current;
                    current     = next;
                    i++;
                    connected = true;
                    break;
                }
            }

            if (!connected)
            {
                //Debug.Log ("returning to previous room: " + previous);
                i--;
                i       = i < 1 ? 0 : i;
                current = previous[i];
            }
        }
    }