Пример #1
0
        void OnGUI()
        {
            if (SimulateNetworking == false && CommandManager.sendType == SendState.Network)
            {
                if (isConnected == false)
                {
                    GUILayout.Label("Host Address: ");

                    IP = GUILayout.TextField(IP.ToString());

                    if (GUILayout.Button("Connect", GUILayout.Width(200f)))
                    {
                        Connect(IP);
                    }

                    GUILayout.Space(10f);
                    GUILayout.Label("Room Size: ");
                    int.TryParse(GUILayout.TextField(RoomSize.ToString()), out _roomSize);
                    if (GUILayout.Button("Host", GUILayout.Width(200f)))
                    {
                        NetworkHelper.Host(RoomSize);
                    }
                }
                else
                {
                }
            }
        }
Пример #2
0
    bool CheckParallel(Cardinal direction, Vector2 startPos, RoomSize roomSize)
    {
        Vector2 dir = new Vector2(0, 0);
        Tile    tile;

        for (int i = 0; i < (int)roomSize; i++)
        {
            if (direction == Cardinal.up)
            {
                dir = Vector2.up;
            }
            else if (direction == Cardinal.down)
            {
                dir = Vector2.down;
            }
            else if (direction == Cardinal.left)
            {
                dir = Vector2.left;
            }
            else if (direction == Cardinal.right)
            {
                dir = Vector2.right;
            }

            if (tiles.TryGetValue(dir * i + startPos, out tile))
            {
                return(false);
            }
        }
        return(true);
    }
Пример #3
0
        public static RoomSizeViewModel GetRoomSizeViewModel(int roomsizeid)
        {
            RoomSizeViewModel model = null;
            RoomSize size = GetRoomSize(roomsizeid);
            if (size != null)
            {
                model = new RoomSizeViewModel();
                model.RoomSize = size;

                using (SqlConnection conn = Connection.GetConnection())
                {
                    if (conn != null)
                    {
                        string sql = "SELECT COUNT(DISTINCT RoomID) count FROM Room, dbo.RoomType WHERE Room.RoomTypeID = RoomType.RoomTypeID AND RoomSizeID = @roomsizeid";
                        SqlCommand cm = new SqlCommand(sql, conn);
                        cm.Parameters.AddWithValue("@roomsizeid", roomsizeid);
                        var rs = cm.ExecuteReader();
                        if (rs.Read())
                        {
                            model.Count = rs.GetInt32(0);
                        }
                        conn.Close();
                    }
                }
            }
            return model;
        }
Пример #4
0
 public static List<RoomSize> GetAllRoomSize()
 {
     List<RoomSize> list = new List<RoomSize>();
     SqlConnection conn = Connection.GetConnection();
     if (conn != null)
     {
         string sql = "select * from RoomSize";
         SqlCommand cm = new SqlCommand(sql, conn);
         var rs = cm.ExecuteReader();
         if (rs.HasRows)
         {
             while (rs.Read())
             {
                 RoomSize size = new RoomSize();
                 size.RoomSizeID = rs.GetInt32(0);
                 size.RoomSizeName = rs.GetString(1);
                 size.RoomSizeShortName = rs.GetString(2);
                 size.GuestCount = rs.GetInt32(3);
                 size.Description = rs.GetString(4);
                 list.Add(size);
             }
         }
         conn.Close();
     };
     return list;
 }
Пример #5
0
 public static RoomSize GetRoomSize(int id)
 {
     RoomSize rs = null;
     SqlConnection conn = Connection.GetConnection();
     if (conn != null)
     {
         string sql = "select * from RoomSize where RoomSizeID = @id";
         SqlCommand cm = new SqlCommand(sql, conn);
         cm.Parameters.AddWithValue("@id", id);
         var reader = cm.ExecuteReader();
         if (reader.HasRows)
         {
             if (reader.Read())
             {
                 rs = new RoomSize();
                 rs.RoomSizeID = reader.GetInt32(0);
                 rs.RoomSizeName = reader.GetString(1);
                 rs.RoomSizeShortName = reader.GetString(2);
                 rs.GuestCount = reader.GetInt32(3);
                 rs.Description = reader.GetString(4);
             }
         }
         conn.Close();
     }
     return rs;
 }
Пример #6
0
 public Roomie(ref DungeonGenerator map, Vector2Int location, Vector2Int forward, int age, int maxAge, int generation,
               int dW, RoomSize s, int cat) : base(ref map, location, forward, age, maxAge, generation)
 {
     defaultWidth = dW;
     roomSize     = s;
     category     = cat;
 }
Пример #7
0
 // コンストラクタ
 public Room2(RoomSize size, Vector3 position)
 {
     _top     = (int)position.z;
     _left    = (int)position.x;
     _bottom  = (int)position.z + size.Height;
     _right   = (int)position.x - size.Widht;
     roomSize = size;
 }
Пример #8
0
 public static Room generate(RoomSize size, Random r, int dispersion)
 {
     BasicRoomSize s = SizeDef[(int)size];
     return new BasicRoom((int)((r.NextDouble() < 0.5 ? 1 : -1) * (Math.Pow(dispersion, r.NextDouble()) - 1)),
         (int)((r.NextDouble() < 0.5 ? 1 : -1) * (Math.Pow(dispersion, r.NextDouble()) - 1)),
         (int)((s.maxW - s.minW) * r.NextDouble() + s.minW),
         (int)((s.maxH - s.minH) * r.NextDouble() + s.minH));
 }
Пример #9
0
        public static Room generate(RoomSize size, Random r, int dispersion)
        {
            BasicRoomSize s = SizeDef[(int)size];

            return(new BasicRoom((int)((r.NextDouble() < 0.5 ? 1 : -1) * (Math.Pow(dispersion, r.NextDouble()) - 1)),
                                 (int)((r.NextDouble() < 0.5 ? 1 : -1) * (Math.Pow(dispersion, r.NextDouble()) - 1)),
                                 (int)((s.maxW - s.minW) * r.NextDouble() + s.minW),
                                 (int)((s.maxH - s.minH) * r.NextDouble() + s.minH)));
        }
Пример #10
0
    void Build(float dl, RoomSize roomSize, Vector2 startPos, Cardinal direction)
    {
        Vector2 corner = startPos;

        if (direction == Cardinal.up)
        {
            corner += new Vector2(-dl, 0);
        }
        if (direction == Cardinal.down)
        {
            corner += new Vector2(-dl, -((int)roomSize - 1));
        }
        if (direction == Cardinal.left)
        {
            corner += new Vector2(-((int)roomSize - 1), -dl);
        }
        if (direction == Cardinal.right)
        {
            corner += new Vector2(0, -dl);
        }

        for (int x = 0; x < (int)roomSize; x++)
        {
            for (int y = 0; y < (int)roomSize; y++)
            {
                Tile tile = new Tile();
                tile.roomNumber = newRoom.roomNumber;
                tile.pos        = new Vector2(x, y) + corner;

                tiles.Add(tile.pos, tile); // add tile to dictionary
                newRoom.tiles.Add(tile);   // add tile to the new room


                // building walls
                if (x == 0)
                {
                    tile.left = WallType.wall;
                }
                if (y == 0)
                {
                    tile.down = WallType.wall;
                }
                if (x == (int)roomSize - 1)
                {
                    tile.right = WallType.wall;
                }
                if (y == (int)roomSize - 1)
                {
                    tile.up = WallType.wall;
                }
            }
        }

        rooms.Add(newRoom);
    }
Пример #11
0
    /*
     * 部屋の生成
     * 区画生成時と同時に生成
     */
    public void CreateRoom(int area_num)
    {
        // 部屋の大きさだけ先に生成
        RoomSize size = new RoomSize(area_num == 1 || area_num == (DUNGEON_SIZE * DUNGEON_SIZE));

        // 部屋が区画内に収まる範囲で部屋の位置決め(ランダム)
        int     room_top  = Random.Range(_top + OUTSKIRTS, _bottom - OUTSKIRTS - size.Height);
        int     room_left = Random.Range(_right + OUTSKIRTS + size.Widht, _left - OUTSKIRTS);
        Vector3 position  = new Vector3(room_left, 0, room_top);

        // 部屋の作成
        room = new Room2(size, position);
        room.Create(area_num);
    }
Пример #12
0
 public void SetReservation(Reservation res, RoomSize size = RoomSize.LABSIZE, Building building = Building.ANY, int floor = -1, List <RoomItems> requiredItems = null)
 {
     requestedReservation = res;
     reservationRoomSize  = size;
     if (requiredItems == null)
     {
         requiredItems = new List <RoomItems>();
     }
     reservationItems      = requiredItems;
     reservationBuilding   = building;
     this.reservationFloor = floor;
     Debug.Log("Set reservation: " + requestedReservation.ToString());
     FindSuitableReservations();
     if (suitableRooms.Count == 0)
     {
         Debug.Log("none available");
     }
 }
Пример #13
0
    public override int GetHashCode()
    {
        int hash = 1;

        if (RoomSize != 0)
        {
            hash ^= RoomSize.GetHashCode();
        }
        if (RoomType != 0)
        {
            hash ^= RoomType.GetHashCode();
        }
        if (_unknownFields != null)
        {
            hash ^= _unknownFields.GetHashCode();
        }
        return(hash);
    }
Пример #14
0
        private void GenerateFeatures()
        {
            AllFeatures       = new List <IFeature>();
            _currFeatureCount = 0;
            // start top left
            FeaturePosition position    = new FeaturePosition(1, 1, Direction.None);
            Vector3Int      size        = RoomSize.GetRandomValue();
            IFeature        tempFeature = null;

            StartPos = position + new Vector3Int(size.x / 2, size.y / 2, 0);

            _factories[0].TryCreateFeature(position, size.ToVector2Int(), Tilemap, ref tempFeature);

            _featureQueue.Enqueue(tempFeature);
            AllFeatures.Add(tempFeature);

            _currFeatureCount++;

            while (_featureQueue.Count > 0 && _currFeatureCount < FeatureCount)
            {
                var lastFeature = _featureQueue.Dequeue();

                position = lastFeature.GetNewFeaturePosition();
                size     = RoomSize.GetRandomValue();
                Debug.Log($"feature at {position.ToString()} of size {size}");

                IFeatureFactory factory    = _factories[Random.Range(0, _factories.Count)];
                IFeature        newFeature = null;
                if (factory.TryCreateFeature(position, size.ToVector2Int(), Tilemap, ref newFeature))
                {
                    lastFeature.AddExit(position);
                    AllFeatures.Add(newFeature);


                    _featureQueue.Enqueue(newFeature);
                    _currFeatureCount++;
                }

                if (lastFeature.CanMakeNewFeature())
                {
                    _featureQueue.Enqueue(lastFeature);
                }
            }
        }
Пример #15
0
 public static bool UpdateRoomSize(RoomSize size)
 {
     using (SqlConnection conn = Connection.GetConnection())
     {
         if (conn != null)
         {
             string sql = "UPDATE RoomSize SET RoomSizeName = @name, RoomSizeShortName = @shortname ,GuestCount = @guestCount , Description = @description WHERE RoomSizeID =@id";
             SqlCommand cm = new SqlCommand(sql, conn);
             cm.Parameters.AddWithValue("@id", size.RoomSizeID);
             cm.Parameters.AddWithValue("@name", size.RoomSizeName);
             cm.Parameters.AddWithValue("@shortname", size.RoomSizeShortName);
             cm.Parameters.AddWithValue("@guestCount", size.GuestCount);
             cm.Parameters.AddWithValue("@description", size.Description);
             cm.ExecuteNonQuery();
             return true;
         }
     }
     return false;
 }
Пример #16
0
    public static string RoomSizeToString(RoomSize roomSize)
    {
        switch (roomSize)
        {
        case RoomSize.ANY:
            return("Labroom");

        case RoomSize.LABSIZE:
            return("Labroom");

        case RoomSize.LECTURESIZE:
            return("Lecture room");

        case RoomSize.TEAMSIZE:
            return("Team room");

        default:
            return("Labroom");
        }
    }
Пример #17
0
 public void SetRoomSize() => roomSize = roomType.roomSizes[Random.Range(0, roomType.roomSizes.Count)];
Пример #18
0
        public FilterDTO SetFilter(IEnumerable <Genre> genres, IEnumerable <GenreDTO> genresDB, RoomSize roomSize)
        {
            // Get Movie Criteria from appsettings.json
            var moviCriteria = _config.GetSection($"MovieCriteria:{roomSize}").GetChildren();
            var appsettings  = moviCriteria.ToDictionary(v => v.Key, v => v.Value);

            var filter = new FilterDTO();

            filter.VoteCount   = appsettings["Vote_Count"];
            filter.VoteAverage = appsettings["Vote_Average"];
            filter.Genres      = GetFilterGenres(genres, genresDB);

            return(filter);
        }
Пример #19
0
 public IActionResult UpdateRoomSize(RoomSize size)
 {
     RoomSizeDAO.UpdateRoomSize(size);
     return(Json(size.RoomSizeID));
 }
        private async Task <List <string> > GenerateMovies(int numberOfMovies, IEnumerable <GenreDTO> genresDB, IEnumerable <Core.Domain.Genre> genres, RoomSize roomSize)
        {
            var result = new List <string>();

            var filter    = _moviesFromAPIService.SetFilter(genres, genresDB, roomSize);
            var moviesAPI = await _moviesFromAPIService.GetMoviesFromAPI(filter);

            using (var jsonDoc = JsonDocument.Parse(moviesAPI.ToString()))
            {
                var root   = jsonDoc.RootElement;
                var movies = root.GetProperty("results").EnumerateArray().Take(numberOfMovies).ToList();

                foreach (var movie in movies)
                {
                    result.Add(movie.GetProperty("title").GetString());
                }
            }
            return(result);
        }
 public static IEnumerable <Room> GetAvailableRooms(ApplicationDbContext context, RoomSize roomSize, DateTime from, DateTime to)
 {
     return(context.Room
            .Include(r => r.Bookings)
            .Include(r => r.Blocks)
            .Where(r => r.RoomSize == roomSize)
            .Where(r => IsAvailable(r, from, to)));
 }
Пример #22
0
 public void SetRoomSizeDropdownValue()
 {
     roomSize = (RoomSize)roomSizeDropdown.value;
 }
Пример #23
0
    Pass CheckPerpendicular(Cardinal direction, Vector2 startPos, RoomSize roomSize)
    {
        float ur = 0, dl = 0;

        if (!CheckParallel(direction, startPos, roomSize))
        {
            return(null);
        }

        for (int i = 1; i < (int)roomSize; i++)
        {
            bool trueFalse = Random.value > .5f;

            if (direction == Cardinal.up || direction == Cardinal.down)
            {
                if (trueFalse)
                {
                    dl++;
                    if (!CheckParallel(direction, startPos + Vector2.left * dl, roomSize))
                    {
                        dl--;
                        ur++;
                        if (!CheckParallel(direction, startPos + Vector2.right * ur, roomSize))
                        {
                            return(null);
                        }
                    }
                }
                else
                {
                    ur++;
                    if (!CheckParallel(direction, startPos + Vector2.right * ur, roomSize))
                    {
                        ur--;
                        dl++;
                        if (!CheckParallel(direction, startPos + Vector2.left * dl, roomSize))
                        {
                            return(null);
                        }
                    }
                }
            }
            if (direction == Cardinal.left || direction == Cardinal.right)
            {
                if (trueFalse)
                {
                    dl++;
                    if (!CheckParallel(direction, startPos + Vector2.down * dl, roomSize))
                    {
                        dl--;
                        ur++;
                        if (!CheckParallel(direction, startPos + Vector2.up * ur, roomSize))
                        {
                            return(null);
                        }
                    }
                }
                else
                {
                    ur++;
                    if (!CheckParallel(direction, startPos + Vector2.up * ur, roomSize))
                    {
                        ur--;
                        dl++;
                        if (!CheckParallel(direction, startPos + Vector2.down * dl, roomSize))
                        {
                            return(null);
                        }
                    }
                }
            }
        }

        Pass dlPass = new Pass();

        dlPass.dl = dl;
        return(dlPass);
    }