void CreateRoom(RoomContainer room, int sizeX, int sizeY, List <Enemy> enemies)
    {
        room.frontWall.position  += (Vector3.forward * ((float)sizeY / 2)) + (Vector3.up * 10);
        room.frontWall.localScale = new Vector3(sizeX, 20, 1);

        room.leftWall.position  += (-Vector3.right * ((float)sizeX / 2)) + (Vector3.up * 10);
        room.leftWall.localScale = new Vector3(sizeY, 20, 1);

        room.rightWall.position  += (Vector3.right * ((float)sizeX / 2)) + (Vector3.up * 10);
        room.rightWall.localScale = new Vector3(sizeY, 20, 1);

        room.backWall.position  += (-Vector3.forward * ((float)sizeY / 2)) + (Vector3.up * 10);
        room.backWall.localScale = new Vector3(sizeX, 20, 1);

        for (int i = 0; i < enemies.Count; i++)
        {
            if (enemies[i].type == EnemyType.SKELETON)
            {
                Instantiate(skeletonPrefab, room.transform.position + (Vector3.forward * (i - 1)) + (Vector3.up * 10), Quaternion.identity);
            }
            if (enemies[i].type == EnemyType.ZOMBIE)
            {
                Instantiate(zombiePrefab, room.transform.position + (Vector3.forward * (i - 1)) + (Vector3.up * 10), Quaternion.identity);
            }
        }
    }
Exemple #2
0
    RoomContainer DeterminantSpecificRoom(List <RoomContainer> ignoreParent, List <MapWay> roomWay, string roomName)
    {
        Vector2Int specificMapAdditionalDirection = RoomManager.WayDirectionSet[RoomManager.WayInverseSet[roomWay[0]]];
        Vector2Int specificMapIncludeAxisOutLine  = specificMapAdditionalDirection;

        specificMapIncludeAxisOutLine.x *= specificMapIncludeAxisOutLine.x > 0 ? mapIndexMax.x  : -(mapIndexMin.x);
        specificMapIncludeAxisOutLine.y *= specificMapIncludeAxisOutLine.y > 0 ? mapIndexMax.y  : -(mapIndexMin.y);


        List <RoomContainer> outLineRooms = madeRooms.Where((r) => (specificMapIncludeAxisOutLine.x != 0 && specificMapIncludeAxisOutLine.x == r.RoomIndex.x) ||
                                                            (specificMapIncludeAxisOutLine.y != 0 && specificMapIncludeAxisOutLine.y == r.RoomIndex.y)).
                                            Except(ignoreParent).ToList();

        RoomContainer specificParentRoom = outLineRooms[Random.Range(0, outLineRooms.Count)];
        MapWay        ToBossWay          = RoomManager.WayDirectionSet.First((p) => p.Value == specificMapAdditionalDirection).Key;

        specificParentRoom.Way.Add(ToBossWay);

        RoomContainer specificRoom = new RoomContainer(specificParentRoom.RoomIndex + specificMapAdditionalDirection, roomWay);

        madeRooms.Add(specificRoom);

        SetMapInstance(specificRoom, roomName);

        return(specificRoom);
    }
Exemple #3
0
 void SetMapInstance(RoomContainer current, string mapName)
 {
     if (current.RoomInstance != null)
     {
         return;
     }
     current.RoomInstance = Room.CreateRoom(mapName, current.RoomIndex);
 }
Exemple #4
0
    public IEnumerable <ManagerProgress> Initialize()
    {
#if UNITY_EDITOR
        RoomContainer.Initialize();
#endif
        LoadRoomContentConfig();
        yield return(new ManagerProgress(1f, ""));
    }
Exemple #5
0
    public static void ChangeRoom(MapWay way)
    {
        RoomContainer rc = Instance.AllRoom.Find((r) => r.RoomIndex == Instance.CurrentRoom.RoomIndex + WayDirectionSet[way]);

        if (rc != null)
        {
            Instance.ChangeRoom(rc.RoomInstance);
        }
    }
Exemple #6
0
    public List <RoomContainer> CreateMap(ThemeTable data)
    {
        RoomContainer testMap = new RoomContainer(Vector2Int.zero, new List <MapWay>());

        testMap.RoomInstance = Room.CreateRoom(MapName, Vector2Int.zero);
        return(new List <RoomContainer>()
        {
            testMap
        });
    }
 public RoomArchiveContainer GetRoomArchive(RoomContainer room)
 {
     foreach (RoomArchiveContainer roomArchive in _roomsArchive)
     {
         if (roomArchive.GetRoom().Name.Equals(room.Name))
         {
             return(roomArchive);
         }
     }
     return(null);
 }
        /// <summary>
        /// Creates a dungeon that is linked to another dungeon through a portalChunk
        /// </summary>
        /// <param name="linkedDungeon">The Dungeon for the portal to link to</param>
        /// <param name="vector">The position to warp to into the other dungeon</param>
        public Dungeon(Dungeon linkedDungeon, Vector2 vector)
        {
            rooms = new RoomContainer();
            random = new Random();

            extraBeginningChunk = new SquareChunk(-2, 10000);

            starter = new PortalChunk(-1, 230, linkedDungeon, vector);
            if (!GetType().Equals(typeof(PresetDungeon)))
                generateDungeon();
        }
    public static void Main()
    {
        // create a root container
        var room = new RoomContainer();
        // create a child
        var table = new Table(room, 4);

        // put the table in the room
        room.Add(table);
        MakeMess(room);
    }
        public void GetAllINTEGRATION_ShouldGetCalledAfterInitialisation()
        {
            // Arrange
            var roomsExpected   = TestDB.GetRoomsTable();
            var roundsExpected  = TestDB.GetRoundsTable();
            var pocketsExpected = TestDB.GetPocketTable();
            var usersExpected   = TestDB.GetUserTable();

            int roomsCountExpected   = roomsExpected.Count;
            int roundsCountExpected  = roundsExpected.Count;
            int playerCountExpected  = usersExpected.Count;
            int pocketsCountExpected = pocketsExpected.Count;


            // Act
            // Initializing RoomContainer should inititialize all data of rooms, rounds and pockets.
            RoomContainer container = new RoomContainer(repo.CreateRoomContainerDAL(),
                                                        repo.CreateRoomDAL(),
                                                        repo.CreateRoundDAL(),
                                                        repo.CreateUserDAL(),
                                                        repo.CreateBetDAL(),
                                                        new Wheel(new NumberGenerator()));

            int roomsCountResult   = 0;
            int roundsCountResult  = 0;
            int playerCountResult  = 0;
            int pocketsCountResult = 0;


            foreach (var room in container.Rooms)
            {
                roomsCountResult++;
                var tempRoom = room;
                foreach (var round in tempRoom.Rounds)
                {
                    roundsCountResult++;
                    var tempRound = round;

                    if (tempRound.Pocket != null)
                    {
                        pocketsCountResult++;
                    }
                }
                foreach (var player in tempRoom.Players)
                {
                    playerCountResult++;
                }
            }

            // Assert
            Assert.Equal(roomsCountExpected, roomsCountResult);
            Assert.Equal(roundsCountExpected, roundsCountResult);
            Assert.Equal(pocketsCountExpected, pocketsCountResult);
        }
Exemple #11
0
    void ChooseMapInstance(RoomContainer current)
    {
        if (current.RoomInstance != null)
        {
            return;
        }

        List <List <MapWay> > keys = mapList.Keys.Where((k) => current.Way.Count == k.Count &&
                                                        k.Intersect(current.Way).Count() == current.Way.Count).ToList();

        current.RoomInstance = Room.CreateRoom(mapList[keys[Random.Range(0, keys.Count)]].mapName, current.RoomIndex);
    }
 public void AddRoomsToList(List <Room> roomList)
 {
     foreach (Room item in roomList)
     {
         //Amount of rooms added
         RoomContainer roomContainer = new RoomContainer();
         listRooms.Add(roomContainer);
         //The size of room added for every room
         Room newRoom = new Room(item.buildingSpace);
         givenRooms.Add(newRoom);
     }
 }
Exemple #13
0
        public TMClientInfoInRoom QuitRoom(TMContext context)
        {
            var info = FindClientInfo(context.Client);

            ClientInfos.Remove(info);
            this.RpcAllAsync("OnClientQuit", info);
            if (ClientInfos.Count == 0)
            {
                RoomContainer.ClearRoom(this);
            }
            return(info);
        }
Exemple #14
0
        public void GetAllRooms_ShouldWork()
        {
            // Arrange
            int roomsCountExpected   = 2;
            int roundsCountExpected  = 4;
            int playerCountExpected  = 3;
            int pocketsCountExpected = 4;

            // Act
            using (TransactionScope scope = new TransactionScope())
            {
                container = new RoomContainer(
                    repo.CreateRoomContainerDAL(),
                    repo.CreateRoomDAL(),
                    repo.CreateRoundDAL(),
                    repo.CreateUserDAL(),
                    repo.CreateBetDAL(),
                    new Wheel(new NumberGenerator()));


                int roomsCountResult   = 0;
                int roundsCountResult  = 0;
                int playerCountResult  = 0;
                int pocketsCountResult = 0;


                foreach (var room in container.Rooms)
                {
                    roomsCountResult++;

                    foreach (var round in room.Rounds)
                    {
                        roundsCountResult++;

                        if (round.Pocket != null)
                        {
                            pocketsCountResult++;
                        }
                    }
                    foreach (var player in room.Players)
                    {
                        playerCountResult++;
                    }
                }

                // Assert
                Assert.Equal(roomsCountExpected, roomsCountResult);
                Assert.Equal(roundsCountExpected, roundsCountResult);
                Assert.Equal(playerCountExpected, playerCountResult);
                Assert.Equal(pocketsCountExpected, pocketsCountResult);
            }
        }
    //  to show you how to access the properties
    //  if you don't already have a reference:
    public static void MakeMess(RoomContainer room)
    {
        if (room == null)
        {
            throw new ArgumentNullException("room");
        }
        var seats = room.GetChildren <Table>().First().Seats.ToArray();

        for (int index = 0; index < seats.Length; index++)
        {
            Console.WriteLine("You have kicked over Seat #{0}", (index + 1).ToString());
        }
    }
Exemple #16
0
    public List <RoomContainer> CreateMap(ThemeTable data)
    {
        currentTheme = data;

        SamplingMapList(data._Name);

        roomFactoryProccess = new List <RoomContainer>();
        madeRooms           = new List <RoomContainer>();

        RoomContainer first = new RoomContainer(Vector2Int.zero, new List <MapWay>()
        {
            MapWay.E_TOP
        });

        SetMapInstance(first, data._StartRoomName);

        madeRooms.Add(first);

        Vector2Int firstIndex;

        first.GetWayDestinationIndex(MapWay.E_TOP, out firstIndex);

        roomFactoryProccess.Add(new RoomContainer(firstIndex, new List <MapWay>()
        {
            RoomManager.WayInverseSet[MapWay.E_TOP]
        }));

        RoomContainer current;

        while (roomFactoryProccess.Count != 0)
        {
            current = roomFactoryProccess[0];
            roomFactoryProccess.RemoveAt(0);

            TransitionRoomFactoryProccess(current);
        }

        List <RoomContainer> specificRoomList = new List <RoomContainer>()
        {
            first
        };

        specificRoomList.Add(DeterminantSpecificRoom(specificRoomList, ConvertWayList(currentTheme._BossRoomName), currentTheme._BossRoomName));

        foreach (var roomContainer in madeRooms)
        {
            ChooseMapInstance(roomContainer);
        }

        return(madeRooms);
    }
Exemple #17
0
    public static void Initialize()
    {
        GameObject obj = GameObject.Find("RoomContainer");

        if (obj == null)
        {
            obj = new GameObject("RoomContainer");
        }
        instance = obj.GetComponent <RoomContainer>();
        if (instance == null)
        {
            instance = obj.AddComponent <RoomContainer>();
            DontDestroyOnLoad(instance);
        }
    }
Exemple #18
0
        private void SendRoomArchive(ClientController clientController, RoomContainer roomRequestHistory)
        {
            var roomArchive = _messagesContainer.GetRoomArchive(roomRequestHistory);

            if (roomArchive != null)
            {
                Console.WriteLine("Room archive sent to room {0} ", roomRequestHistory.Name);
                SendCommandToClient(clientController, new CommandContainer(CommandType.RoomArchive, roomArchive));
            }
            else
            {
                Console.WriteLine("Room {0} does not exists", roomRequestHistory.Name);
                SendCommandToClient(clientController, new CommandContainer(CommandType.RoomDoesNotExists, null));
            }
        }
Exemple #19
0
        /// <summary>
        /// Loads the set of Locations grouped by room from the Locations.xml file.
        /// </summary>
        /// <returns>A LocationManager that contains the set of objects and categories</returns>
        public static LocationManager LoadLocations(string filePath)
        {
            RoomContainer container = Load <RoomContainer>(filePath);

            if (container == null)
            {
                throw new Exception("No objects found");
            }
            LocationManager manager = LocationManager.Instance;

            foreach (Room r in container.Rooms)
            {
                manager.Add(r);
            }
            return(manager);
        }
Exemple #20
0
        public void Split(bool horizontal, int maxTreeDepth, List <RoomContainer> roomContainers)
        {
            int newTreeDepth = this.treeDepth + 1;

            this.isSplitHorizontally = horizontal;
            this.isLastNode          = false;

            // create two new roomcontainers
            if (horizontal)
            {
                int split_x = this.x + FindRandomSplit(this.width);
                this.split = split_x;

                int left_w  = split_x - this.x;
                int right_w = this.width - left_w;

                l_child = new RoomContainer(this.x, this.y, left_w, this.height, newTreeDepth, roomContainers);
                r_child = new RoomContainer(split_x, this.y, right_w, this.height, newTreeDepth, roomContainers);
            }
            else
            {
                int split_y = this.y + FindRandomSplit(this.height);
                this.split = split_y;

                int left_h  = split_y - this.y;
                int right_h = this.height - left_h;

                l_child = new RoomContainer(this.x, this.y, this.width, left_h, newTreeDepth, roomContainers);
                r_child = new RoomContainer(this.x, split_y, this.width, right_h, newTreeDepth, roomContainers);
            }

            // recursively create more sub rooms in newly created rooms if maxTreeDepth hasn't been reached yet
            // if this room was split horizontally, split the next rooms vertically (and vice versa)
            // Somtimes it will randomly stop splitting a room and leave it bigger.
            if (newTreeDepth < maxTreeDepth)
            {
                if (Random.Range(0, 1f) > (STOP_SPLITTING_CHANCE * newTreeDepth) + (2 * -STOP_SPLITTING_CHANCE))
                {
                    l_child.Split(!horizontal, maxTreeDepth, roomContainers);
                }
                if (Random.Range(0, 1f) > (STOP_SPLITTING_CHANCE * newTreeDepth) + (2 * -STOP_SPLITTING_CHANCE))
                {
                    r_child.Split(!horizontal, maxTreeDepth, roomContainers);
                }
            }
        }
        public RoomContainerTests()
        {
            repo      = new InMemRepository();
            container = new RoomContainer(
                repo.CreateRoomContainerDAL(),
                repo.CreateRoomDAL(),
                repo.CreateRoundDAL(),
                repo.CreateUserDAL(),
                repo.CreateBetDAL(),
                new Wheel(new NumberGenerator()));

            room = new Room(1,
                            repo.CreateRoomDAL(),
                            repo.CreateRoundDAL(),
                            repo.CreateUserDAL(),
                            repo.CreateBetDAL(),
                            new Wheel(new NumberGenerator()));
        }
Exemple #22
0
        private void CreateRoom(ClientController clientController, RoomContainer newRoom)
        {
            var newRoomUsers = new RoomUsersContainer(newRoom);

            if (!_roomsContainer.RoomExist(newRoomUsers))
            {
                _roomsContainer.AddRoom(newRoomUsers);
                _messagesContainer.AddRoomArchive(new RoomArchiveContainer(newRoom));
                Console.WriteLine("New room created {0}", newRoomUsers.GetRoom().Name);
                SendCommandToClient(clientController, new CommandContainer(CommandType.RoomCreated, null));
                SendCommandToAllClients(clientController, new CommandContainer(CommandType.RoomList, _roomsContainer));
            }
            else
            {
                Console.WriteLine("Room {0} already exists", newRoomUsers.GetRoom().Name);
                SendCommandToClient(clientController, new CommandContainer(CommandType.RoomAlreadyExists, null));
            }
        }
        //Creates a New Dungeon, Generates it if it is not Preset.
        public Dungeon()
        {
            if (!deserializing)
            {
                rooms = new RoomContainer();
                random = new Random();

                starter = new SquareChunk(-1, 10000);

                //Logger.getInstance().log(SerializeThing());

                //if not preset, make it.
                if (!GetType().Equals(typeof(PresetDungeon)))
                    generateDungeon();
            }
            else
            {
                entities = new MobContainer();
                //deserializing = false;
            }
        }
Exemple #24
0
    void TransitionRoomFactoryProccess(RoomContainer current)
    {
        int randomConnectionCount = CalculateTransitionRoomWayCount(current.Way.Count);

        List <MapWay> otherList = RoomManager.WayList.Except(current.Way).ToList();

        for (int i = 0; i < randomConnectionCount; ++i)
        {
            int    index      = Random.Range(0, otherList.Count);
            MapWay currentWay = otherList[index];

            if (ConnectNearRoom(current, currentWay))
            {
                current.Way.Add(otherList[index]);
            }

            otherList.RemoveAt(index);
        }

        madeRooms.Add(current);
    }
Exemple #25
0
        // these methods are becoming abomiantions like a UFKCING spaghetti monster PIECE Of shit
        public List <RoomContainer> GetTwoClosestContainers(List <RoomContainer> roomContainers)
        {
            int pathMiddle;
            List <RoomContainer> temp = new List <RoomContainer>();

            int[] distances = new int[roomContainers.Count];
            int[] shortestDistanceIndexes = new int[2];

            if (this.isHorizontal)
            {
                pathMiddle = this.x + (this.width / 2);
                for (int i = 0; i < roomContainers.Count; i++)
                {
                    RoomContainer rc          = roomContainers[i];
                    int           rcLeft      = rc.x;
                    int           rcRight     = rc.x + rc.width;
                    int           rc_distance = Mathf.Min(Mathf.Abs(rcLeft - pathMiddle), Mathf.Abs(rcRight - pathMiddle));
                    rc.distanceFromPath = rc_distance;
                }
            }
            else
            {
                pathMiddle = this.y + (this.height / 2);
                for (int i = 0; i < roomContainers.Count; i++)
                {
                    RoomContainer rc          = roomContainers[i];
                    int           rcLeft      = rc.y;
                    int           rcRight     = rc.y + rc.height;
                    int           rc_distance = Mathf.Min(Mathf.Abs(rcLeft - pathMiddle), Mathf.Abs(rcRight - pathMiddle));
                    rc.distanceFromPath = rc_distance;
                }
            }

            List <RoomContainer> sortedList = roomContainers.OrderBy(rc => rc.distanceFromPath).ToList();

            sortedList.RemoveRange(2, sortedList.Count - 2);
            return(sortedList);
        }
Exemple #26
0
    bool ConnectNearRoom(RoomContainer current, MapWay currentWay)
    {
        Vector2Int wayDirIndex = current.RoomIndex + RoomManager.WayDirectionSet[currentWay];

        RoomContainer container = madeRooms.Find((r) => r.RoomIndex == wayDirIndex);

        if (container == null)
        {
            container = roomFactoryProccess.Find((r) => r.RoomIndex == wayDirIndex);

            if (container == null)
            {
                roomFactoryProccess.Add(new RoomContainer(wayDirIndex, new List <MapWay>()
                {
                    RoomManager.WayInverseSet[currentWay]
                }));

                mapIndexMin.x = Mathf.Min(mapIndexMin.x, wayDirIndex.x);
                mapIndexMin.y = Mathf.Min(mapIndexMin.y, wayDirIndex.y);

                mapIndexMax.x = Mathf.Max(mapIndexMax.x, wayDirIndex.x);
                mapIndexMax.y = Mathf.Max(mapIndexMax.y, wayDirIndex.y);
            }
            else
            {
                container.Way.Add(RoomManager.WayInverseSet[currentWay]);
            }

            return(true);
        }
        else if (container.Way.Contains(RoomManager.WayInverseSet[currentWay]))
        {
            return(true);
        }

        return(false);
    }
    void Start()
    {
        DungeonIO loader    = GameObject.FindGameObjectWithTag("DungeonLoader").GetComponent <DungeonIO>();
        Vector3   spawnPos  = Vector3.zero;
        bool      direction = true;

        for (int i = 0; i < loader.rooms.Count; i++)
        {
            RoomContainer newRoom = Instantiate(roomPrefab, spawnPos, Quaternion.identity).GetComponent <RoomContainer>();
            CreateRoom(newRoom, (int)loader.rooms[i].size.x, (int)loader.rooms[i].size.y, loader.rooms[i].enemies);

            switch (Random.Range(0, 2))
            {
            case 0:
                if (direction)
                {
                    spawnPos.x += 20;
                }
                else
                {
                    spawnPos.x -= 20;
                }
                break;

            case 1:
                spawnPos.z += 20;
                switch (Random.Range(0, 2))
                {
                case 0: direction = true; break;

                case 1: direction = false; break;
                }
                break;
            }
        }
    }
Exemple #28
0
        public void FillRoomNeighboursAfterPathCreation(List <RoomContainer> finalNodes, Dictionary <string, Path> _pathDict)
        {
            // TODO: Sometimes a path doesn't intersect multiple rooms and keeps going until it reaches another path.
            // In that case, neighbours don't get added correctly because the connected RoomContainer will be removed in this step:

            if (finalNodes.Count == 2)
            {
                RoomContainer rc1 = finalNodes[0];
                RoomContainer rc2 = finalNodes[1];

                rc1.room.neighbours.Add(rc2.room);
                rc2.room.neighbours.Add(rc1.room);

                if (!_pathDict.ContainsKey(rc1.id + "-" + rc2.id))
                {
                    _pathDict.Add(rc1.id + "-" + rc2.id, this);
                }

                if (!_pathDict.ContainsKey(rc2.id + "-" + rc1.id))
                {
                    _pathDict.Add(rc2.id + "-" + rc1.id, this);
                }
            }
        }
Exemple #29
0
    void GenerateRoomContainers()
    {
        RoomContainer mainContainer = new RoomContainer(0, 0, WIDTH, HEIGHT, 0, roomContainers);

        mainContainer.Split(true, MAX_TREE_DEPTH, roomContainers);
    }
Exemple #30
0
 private void Start()
 {
     _roomContainer = GameObject.FindGameObjectWithTag("RoomContainer").GetComponent <RoomContainer>();
     Invoke("Spawn", 0.1f);
     indexer++;
 }
        /// <summary>
        /// Writes the datafiles, asking the user for overwriting.
        /// </summary>
        /// <param name="gestures">Gestures list container</param>
        /// <param name="categories">Categories list container.</param>
        /// <param name="locations">Locations list container.</param>
        /// <param name="names">Names list container.</param>
        /// <param name="questions">Questions list container.</param>
        private static void WriteDatafiles(GestureContainer gestures, CategoryContainer categories, RoomContainer locations, NameContainer names, QuestionsContainer questions)
        {
            string path = Loader.GetPath("Gestures.xml");

            if (Overwrite(path))
            {
                Loader.Save(path, gestures);
            }
            path = Loader.GetPath("Locations.xml");
            if (Overwrite(path))
            {
                Loader.Save(path, locations);
            }
            path = Loader.GetPath("Names.xml");
            if (Overwrite(path))
            {
                Loader.Save(path, names);
            }
            path = Loader.GetPath("Objects.xml");
            if (Overwrite(path))
            {
                Loader.Save(path, categories);
            }
            path = Loader.GetPath("Questions.xml");
            if (Overwrite(path))
            {
                Loader.Save(path, questions);
            }
        }
 public RoomContainerTests()
 {
     container = new RoomContainer(TestFactory.CreateTestRoomContainerDAL());
     room      = new Room("Speed Roulette", TestFactory.CreateTestRoomDAL());
 }