예제 #1
0
        public static ST_Room AddRoom(int a_nX, int a_nY)
        {
            if (m_nRoomCheck <= 0)
            {
                return(null);
            }

            ST_Room stReturn = null;

            int nKey = a_nX.GetCoordKey(a_nY);

            if (m_refMapRoom.ContainsKey(nKey) == true)
            {
                return(m_refMapRoom[nKey]);
            }

            stReturn    = new ST_Room();
            stReturn.nX = a_nX;
            stReturn.nY = a_nY;

            // 랜덤하게 포탈 세팅. 좌표가 아닌 방의 속성을 정하는 것이기에 여기보단 위쪽에서 하는게 맞지만 반복문이 여기서 돌아 걍 여기서함
            stReturn.bPortal = (UnityEngine.Random.Range(0, 1.0f) > 0.7f);

            m_refLiCoord.Add(nKey);
            m_refMapRoom.Add(nKey, stReturn);

            --m_nRoomCheck;

            return(stReturn);
        }
예제 #2
0
        public static void CreateRoom(ref Dictionary <int, ST_Room> a_refInfo, ref List <int> a_liCoord, int a_nFloor, int a_nRoomCount)
        {
            Clear();
            a_refInfo.Clear();
            a_liCoord.Clear();

            m_refMapRoom = a_refInfo;
            m_refLiCoord = a_liCoord;
            m_nRoomCheck = a_nRoomCount;

            ST_Room stRoom = AddRoom(0, 0);

            // 방 생성
            while (true)
            {
                RecursiveCreateRoom(ref stRoom);

                if (m_nRoomCheck <= 0)
                {
                    break;
                }
            }

            Clear();
        }
예제 #3
0
        public static void RecursiveCreateRoom(ref ST_Room a_stRoom, eDir a_eDir = eDir.None)
        {
            if (a_eDir != eDir.None)
            {
                a_stRoom.eOpenDir |= a_eDir;
            }

            // 위
            if ((UnityEngine.Random.Range(0, 1.0f) > 0.5f))
            {
                var room = AddRoom(a_stRoom.nX, a_stRoom.nY + 1);

                if (room != null)
                {
                    a_stRoom.eOpenDir |= eDir.Top;
                    RecursiveCreateRoom(ref room, eDir.Bottom);
                }
            }

            // 왼쪽
            if ((a_stRoom.nX > 0) &&
                (UnityEngine.Random.Range(0, 1.0f) > 0.5f))
            {
                var room = AddRoom(a_stRoom.nX - 1, a_stRoom.nY);

                if (room != null)
                {
                    a_stRoom.eOpenDir |= eDir.Left;
                    RecursiveCreateRoom(ref room, eDir.Right);
                }
            }

            // 오른쪽
            if ((UnityEngine.Random.Range(0, 1.0f) > 0.5f))
            {
                var room = AddRoom(a_stRoom.nX + 1, a_stRoom.nY);

                if (room != null)
                {
                    a_stRoom.eOpenDir |= eDir.Right;
                    RecursiveCreateRoom(ref room, eDir.Left);
                }
            }

            // 아래
            if ((a_stRoom.nY > 0) &&
                (UnityEngine.Random.Range(0, 1.0f) > 0.5f))
            {
                var room = AddRoom(a_stRoom.nX, a_stRoom.nY - 1);

                if (room != null)
                {
                    a_stRoom.eOpenDir |= eDir.Bottom;
                    RecursiveCreateRoom(ref room, eDir.Top);
                }
            }
        }
예제 #4
0
        public void CreateDungeon(int a_nFloor, int a_nRoomCount, List <eNPC> a_liNPC)
        {
            Clear();
            m_nFloor        = a_nFloor;
            m_nRoomCount    = a_nRoomCount;
            m_nStartRoomKey = Define.GetCoordKey(0, 0);

            RoomMaker.CreateRoom(ref m_mapRoom, ref m_liCoordKey, a_nFloor, a_nRoomCount);

            m_mapRoom[m_nStartRoomKey].eState  = eRoomState.First;
            m_mapRoom[m_nStartRoomKey].bPortal = true;

            // 마지막 방 설정
            var node = m_mapRoom.GetEnumerator();

            ST_Room lastRoom = null;

            while (node.MoveNext())
            {
                lastRoom = node.Current.Value;
            }

            lastRoom.eState  = eRoomState.Last;
            lastRoom.bPortal = true;

            m_liCoordKey.Shuffle();

            int nIndex = 0;

            for (int i = 0; i < a_liNPC.Count; ++i)
            {
                var room = m_mapRoom[m_liCoordKey[nIndex]];

                if ((room.bHasNPC == true) ||
                    (room.bNoNPC == true))
                {
                    ++nIndex;
                    --i;

                    continue;
                }

                room.eExistNPC = a_liNPC[i];

                // 식당, 무기상인한테는 무조건 포탈 존재
                if (room.eExistNPC == eNPC.DungeonDining || room.eExistNPC == eNPC.DungeonWaepon)
                {
                    room.bPortal |= true;
                }
            }
        }