Exemplo n.º 1
0
        public RoomBl GetRoom(int id)
        {
            Room     room     = _context.Room.FirstOrDefault(p => p.Id == id);
            RoomProp roomProp = _context.RoomProp.FirstOrDefault(p => p.IdRoom == id);
            RoomBl   roomBl;

            if (roomProp == null)
            {
                roomBl = new RoomBl
                {
                    Id       = room.Id,
                    Number   = room.Number,
                    Cost     = (int)room.Cost,
                    Сapacity = room.Сapacity,
                    Type     = room.Type,

                    Shower      = false,
                    Restroom    = false,
                    Description = "",
                    Bed         = 0,
                    Wifi        = false,
                    Tv          = false,
                    Fridge      = false,
                };
            }
            else
            {
                roomBl = new RoomBl
                {
                    Id       = room.Id,
                    Number   = room.Number,
                    Cost     = (int)room.Cost,
                    Сapacity = room.Сapacity,
                    Type     = room.Type,

                    Shower      = roomProp.Shower == null ? false : roomProp.Shower,
                    Restroom    = roomProp.Restroom == null ? false : roomProp.Restroom,
                    Description = roomProp.Description == null ? "" : roomProp.Description,
                    Bed         = roomProp.Bed == null ? 0 : roomProp.Bed,
                    Wifi        = roomProp.Wifi == null ? false : roomProp.Wifi,
                    Tv          = roomProp.Tv == null ? false : roomProp.Tv,
                    Fridge      = roomProp.Fridge == null ? false : roomProp.Fridge,
                };
            }

            return(roomBl);
        }
Exemplo n.º 2
0
        public bool EditRoom(RoomBl room)
        {
            try
            {
                Room smalroom = new Room
                {
                    Id       = room.Id,
                    Number   = room.Number,
                    Cost     = room.Cost,
                    Сapacity = room.Сapacity,
                    Type     = room.Type,
                };
                _context.Room.Update(smalroom);
                _context.SaveChanges();

                RoomProp roomPropCheck = _context.RoomProp.FirstOrDefault(p => p.IdRoom == room.Id);
                RoomProp roomProp      = new RoomProp
                {
                    IdRoom      = smalroom.Id,
                    Shower      = room.Shower,
                    Restroom    = room.Restroom,
                    Description = room.Description,
                    Bed         = room.Bed,
                    Wifi        = room.Wifi,
                    Tv          = room.Tv,
                    Fridge      = room.Fridge,
                };
                if (roomPropCheck == null)
                {
                    _context.RoomProp.Add(roomProp);
                }
                else
                {
                    _context.RoomProp.Update(roomProp);
                }

                _context.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                return(false);

                throw;
            }
        }
Exemplo n.º 3
0
        public bool DeleteRoom(int id)
        {
            try
            {
                Room room = _context.Room.FirstOrDefault(p => p.Id == id);
                _context.Room.Remove(room);
                _context.SaveChanges();
                RoomProp roomProp = _context.RoomProp.FirstOrDefault(p => p.IdRoom == id);
                _context.RoomProp.Remove(roomProp);
                _context.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                return(false);

                throw;
            }
        }
Exemplo n.º 4
0
        public bool CreateRoom(RoomBl room)
        {
            try
            {
                Room smalroom = new Room
                {
                    Id       = room.Id,
                    Number   = room.Number,
                    Cost     = room.Cost,
                    Сapacity = room.Сapacity,
                    Type     = room.Type,
                };
                _context.Room.Add(smalroom);
                _context.SaveChanges();

                RoomProp RoomBl = new RoomProp
                {
                    IdRoom      = smalroom.Id,
                    Shower      = room.Shower,
                    Restroom    = room.Restroom,
                    Description = room.Description,
                    Bed         = room.Bed,
                    Wifi        = room.Wifi,
                    Tv          = room.Tv,
                    Fridge      = room.Fridge,
                };
                _context.RoomProp.Add(RoomBl);
                _context.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                return(false);

                throw;
            }
        }
Exemplo n.º 5
0
    void ObjectSelection()
    {
        scroll_position = GUILayout.BeginScrollView(scroll_position);

        int   icon_size      = 100;
        float view_width     = EditorGUIUtility.currentViewWidth;
        int   number_can_fit = (int)view_width / icon_size;

        number_can_fit = System.Math.Min(System.Math.Max(1, number_can_fit), prop_icons.Length);

        int old_enemy = object_selection_number;

        object_selection_number = GUILayout.SelectionGrid(object_selection_number, prop_icons, number_can_fit, GUILayout.Height(icon_size * Mathf.CeilToInt((float)prop_icons.Length / number_can_fit)), GUILayout.MinWidth(icon_size * number_can_fit));

        if (object_selection_number != old_enemy)
        {
            RoomProp to_copy = available_props[object_selection_number];
            SetMouseHoverObject(to_copy.gameObject);
            mouse_object.SetActive(false);
            mouse_object.name = to_copy.name;
        }

        GUILayout.EndScrollView();
    }
Exemplo n.º 6
0
    void OnGUI()
    {
        EditorGUI.BeginDisabledGroup(true);
        EditorGUILayout.ObjectField("Current RoomEditor:", room_editor, typeof(RoomEditor), false);
        EditorGUI.EndDisabledGroup();

        RoomModeToggle();

        if (room_mode == RoomEditMode.Info)
        {
            LevelAesthetics old_level_set = level_set;
            level_set = (LevelAesthetics)EditorGUILayout.ObjectField("Level Set", level_set, typeof(LevelAesthetics), true);
            if (level_set != old_level_set && level_set != null)
            {
                SetLevelSet(level_set);
            }

            SetSizeButton();

            SaveRoomOptions();

            LoadRoomOptions();
        }

        if (room_mode == RoomEditMode.Block)
        {
            BlockModeToggle();

            if (block_mode == BlockEditMode.Place)
            {
                TileTypeToolbar();
            }
        }

        if (room_mode == RoomEditMode.RoomSet)
        {
            RoomSetModeToggle();

            if (room_set_mode == RoomSetEditMode.Enemies)
            {
                EnemySelection();
            }
            else if (room_set_mode == RoomSetEditMode.EnemyHierarchy)
            {
                Enemy to_remove = null;
                foreach (Enemy e in placed_enemies)
                {
                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("X", GUILayout.Width(20)))
                    {
                        to_remove = e;
                    }
                    if (GUILayout.Button(e.name, EditorStyles.label))
                    {
                        Selection.objects = new Object[] { e.gameObject };
                        Tools.current     = Tool.Move;
                    }
                    EditorGUILayout.EndHorizontal();
                }
                if (to_remove != null)
                {
                    placed_enemies.Remove(to_remove);
                    room_editor.RemoveEnemy(to_remove);
                    DestroyImmediate(to_remove.gameObject);
                }
            }
            else if (room_set_mode == RoomSetEditMode.Objects)
            {
                ObjectSelection();
            }
            else if (room_set_mode == RoomSetEditMode.ObjectHierarchy)
            {
                RoomProp to_remove = null;
                foreach (RoomProp prop in placed_props)
                {
                    if (prop == null)
                    {
                        continue;
                    }
                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("X", GUILayout.Width(20)))
                    {
                        to_remove = prop;
                    }
                    if (GUILayout.Button(prop.name, EditorStyles.label))
                    {
                        Selection.objects = new Object[] { prop.gameObject };
                        Tools.current     = Tool.Move;
                    }
                    EditorGUILayout.EndHorizontal();
                }
                if (to_remove != null)
                {
                    placed_props.Remove(to_remove);
                    DestroyImmediate(to_remove.gameObject);
                }
            }
        }
    }