Exemplo n.º 1
0
        /// <summary>
        /// Проинициализировать гараж
        /// </summary>
        private void InitializeGarage(HouseInfo house)
        {
            if (string.IsNullOrEmpty(house.GaragePosition))
            {
                // не у всех домов может быть гараж?
                return;
            }
            // вход в гараж
            var enterPos = PositionConverter.ToVector3(house.GaragePosition);
            var enter    = _pointCreator.CreateMarker(Marker.Stripes, enterPos, Colors.Yellow, 2f);

            API.setEntityRotation(enter.Marker, PositionConverter.ToVector3(house.RotationAfterExit));
            enter.ColShape.onEntityEnterColShape += (shape, entity) => {
                _houseEventManager.OnPlayerWentToGarageEnter(entity, house.Id);
            };
            enter.ColShape.onEntityExitColShape += (shape, entity) => _houseEventManager.OnPlayerAway(entity);
            // выход
            var exits = HousesPositionsGetter.GetGarageInnerPositions(house.Type).GarageExits;

            foreach (var exit in exits)
            {
                var garageExit = API.createSphereColShape(exit, 2f);
                garageExit.dimension              = (int)-house.Id;
                garageExit.onEntityEnterColShape += (shape, entity) => {
                    _houseEventManager.OnPlayerExitGarage(entity, house.Id);
                };
                garageExit.onEntityExitColShape += (shape, entity) => _houseEventManager.OnPlayerAway(entity);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Обработать данные владельца дома
        /// </summary>
        private void ProcessOwner(HouseInfo house)
        {
            var player = _playerInfoManager.GetWithData(house.OwnerId);

            if (PlayerHelper.PlayerCorrect(player.Player))
            {
                var houseId = PlayerHelper.GetData(player.Player, HouseMenuHandler.IN_HOUSE, NO_OWNER);
                if (houseId == house.Id)
                {
                    player.Player.resetData(HouseMenuHandler.IN_HOUSE);
                    API.setEntityPosition(player.Player, PositionConverter.ToVector3(house.Position));
                    API.setEntityDimension(player.Player, 0);
                }
                MoveVehiclesOnParking(player.PlayerInfo.Vehicles.Values, player.Player);
                _playerInfoManager.RefreshUI(player.Player, player.PlayerInfo);
                API.sendNotificationToPlayer(player.Player, "~b~Аренда дома подошла к концу");
            }
            else
            {
                MoveVehiclesOnParking(player.PlayerInfo.Vehicles.Values);
                player.PlayerInfo.LastPosition = house.Position;
                player.PlayerInfo.Dimension    = 0;
                _playerInfoManager.Set(player.PlayerInfo);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Проинициализировать дом внутри
        /// </summary>
        private void InitializeHouseInside(HouseInfo house)
        {
            var positions = HousesPositionsGetter.InnerPositions[house.Type];

            CreateWardrobe(house, positions);
            CreateStorage(house, positions);
            CreateExitFromHouse(house, positions);
        }
        /// <summary>
        /// Удаляет транспорт из гаража
        /// </summary>
        private void UnparkVehicle(Client player, HouseInfo house)
        {
            var vehicle     = API.getPlayerVehicle(player);
            var vehicleInfo = _vehicleInfoManager.GetInfoByHandle(player, vehicle);

            vehicleInfo.HouseId = Validator.INVALID_ID;
            _houseManager.SetHouse(house);
            _vehicleInfoManager.SetInfo(player, vehicleInfo);
        }
        /// <summary>
        /// Войти в гараж
        /// </summary>
        private void EnterGarage(Client player, HouseInfo house)
        {
            LoadVehicles(player, house);
            var garage = HousesPositionsGetter.GetGarageInnerPositions(house.Type);

            SetGaragePosition(player, garage.AfterEnter, garage.EnterRotation, (int)house.Id);
            API.sendNativeToPlayer(player, Hash.DISPLAY_RADAR, false);
            API.triggerClientEvent(player, ServerEvent.HIDE_HOUSE_MENU);
        }
 /// <summary>
 /// Проверка, что дверь заперта
 /// </summary>
 private bool IsLocked(Client player, HouseInfo house)
 {
     if (house.Lock)
     {
         API.sendNotificationToPlayer(player, "~r~Дверь заперта");
         return(true);
     }
     return(false);
 }
Exemplo n.º 7
0
        /// <summary>
        /// Создает выход из дома
        /// </summary>
        private void CreateExitFromHouse(HouseInfo house, HousesInnerPositions positions)
        {
            var exit = _pointCreator.CreateMarker(
                Marker.UpsideDownCone, positions.Exit, Colors.Yellow,
                SHAPE_RANGE, dimention: (int)-house.Id
                );

            exit.ColShape.dimension              = (int)-house.Id;
            exit.ColShape.onEntityEnterColShape += (shape, entity) => { _houseEventManager.OnPlayerExit(entity, house.Id); };
            exit.ColShape.onEntityExitColShape  += (shape, entity) => _houseEventManager.OnPlayerAway(entity);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Создает значек дома на карте
        /// </summary>
        private void CreateBlips(HouseInfo house, Vector3 position)
        {
            var hasOwner   = house.OwnerId != NO_OWNER;
            var playerName = hasOwner
                ? _playerInfoManager.Get(house.OwnerId)?.Name
                : string.Empty;
            var blip = _pointCreator.CreateBlip(position, hasOwner ? 40 : 374, 0, scale: 0.6f);

            _blipsByHouses.Add(house.Id, blip);
            UpdateBlip(house, playerName);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Обновить иконку дома на карте
        /// </summary>
        public void UpdateBlip(HouseInfo house, string playerName = "")
        {
            var blip     = _blipsByHouses[house.Id];
            var hasOwner = !string.IsNullOrEmpty(playerName);
            var color    = hasOwner ? BUSY_HOUSE_COLOR : FREE_HOUSE_COLOR;
            var sprite   = hasOwner ? 40 : 374;
            var label    = $"{HouseHelper.GetHouseLabel(house.Type, playerName)}";

            API.setBlipColor(blip, color);
            API.setBlipSprite(blip, sprite);
            API.setBlipName(blip, label);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Установить аренду дома
        /// </summary>
        private void SetRent(Client player, HouseInfo house, PlayerInfo playerInfo, int daysRent)
        {
            var endOfRenting = DateTime.Now.AddDays(daysRent);
            var isRentExt    = Validator.IsValid(house.EndOfRenting);

            house.EndOfRenting = isRentExt ? house.EndOfRenting.AddDays(daysRent) : endOfRenting;
            house.OwnerId      = playerInfo.AccountId;
            _houseManager.SetHouse(house);
            _houseManager.UpdateBlip(house, playerInfo.Name);
            var actionName = isRentExt ? "продлена" : "оплачена";

            API.sendNotificationToPlayer(player, $"~g~Аренда {actionName} до {house.EndOfRenting:g}");
        }
Exemplo n.º 11
0
        /// <summary>
        /// Создает хранилище
        /// </summary>
        private void CreateStorage(HouseInfo house, HousesInnerPositions positions)
        {
            var storage = _pointCreator.CreateMarker(
                Marker.VerticalCylinder, positions.Storage, Colors.VividCyan,
                SHAPE_RANGE, dimention: (int)-house.Id
                );

            storage.ColShape.onEntityEnterColShape += (shape, entity) => _houseEventManager.OnPlayerEnterStorage(entity, house.Type);
            storage.ColShape.onEntityExitColShape  += (shape, entity) =>
                                                      PlayerHelper.ProcessAction(entity, player => API.triggerClientEvent(player, ServerEvent.HIDE_HOUSE_STORAGE_MENU));
            API.setMarkerScale(storage.Marker, _innerMarkerScale);
            API.setEntityPosition(storage.Marker, positions.Storage.Add(_displacement));
        }
Exemplo n.º 12
0
        /// <summary>
        /// Удалить транспорт из гаража при выходе игрока
        /// </summary>
        private void RemoveVehicles(Client player, HouseInfo house)
        {
            var vehicles = _vehicleInfoManager.GetPlayerVehicles(player);

            foreach (var vehicle in vehicles)
            {
                if (vehicle.HouseId != house.Id || vehicle.Instance == null)
                {
                    continue;
                }
                vehicle.IsSpawned = false;
                vehicle.Instance.delete();
                _vehicleInfoManager.SetInfo(player, vehicle);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Создает гардероб
        /// </summary>
        private void CreateWardrobe(HouseInfo house, HousesInnerPositions positions)
        {
            var wardrobe = _pointCreator.CreateMarker(
                Marker.VerticalCylinder, positions.Wardrobe, Colors.Yellow,
                SHAPE_RANGE, dimention: (int)-house.Id
                );

            wardrobe.ColShape.onEntityEnterColShape += (shape, entity) => _houseEventManager.OnPlayerEnterWardrobe(entity, house.Type);
            wardrobe.ColShape.onEntityExitColShape  += (shape, entity) => {
                var player = API.getPlayerFromHandle(entity);
                API.triggerClientEvent(player, ServerEvent.HIDE_CLOTHES_MENU);
            };
            API.setMarkerScale(wardrobe.Marker, _innerMarkerScale);
            API.setEntityPosition(wardrobe.Marker, positions.Wardrobe.Add(_displacement));
        }
Exemplo n.º 14
0
        /// <summary>
        /// Может ли игрок парковаться в гараже
        /// </summary>
        private bool CanParking(Client player, HouseInfo house, Vehicle vehicleInfo)
        {
            var vehiclesInGarage = _playerInfoManager.GetInfo(player).Vehicles.Values.Count(e => e.HouseId == house.Id);

            if (HouseHelper.GarageIsFull(house.Type, vehiclesInGarage))
            {
                API.sendNotificationToPlayer(player, "~r~В гараже больше нет мест", true);
                return(false);
            }
            if (vehicleInfo == null)
            {
                API.sendNotificationToPlayer(player, "~r~Нельзя парковать чужой транспорт в гараж", true);
                return(false);
            }
            return(true);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Загрузить машины в гараж
        /// </summary>
        private void LoadVehicles(Client player, HouseInfo house)
        {
            var vehicles         = _vehicleInfoManager.GetPlayerVehicles(player);
            var parkingPositions = HousesPositionsGetter.GetGarageInnerPositions(house.Type).Positions;
            var positionIndex    = 0;

            foreach (var vehicle in vehicles)
            {
                if (vehicle.HouseId != house.Id)
                {
                    continue;
                }
                var position = parkingPositions[positionIndex];
                vehicle.IsSpawned = true;
                _vehicleManager.CreateVehicle(vehicle, position.Item1, position.Item2, (int)-house.Id);
                _vehicleInfoManager.SetInfo(player, vehicle);
                positionIndex++;
            }
        }
Exemplo n.º 16
0
 /// <summary>
 /// Припарковать транспорт
 /// </summary>
 private void ParkVehicle(Client player, HouseInfo house, Vehicle vehicleInfo)
 {
     vehicleInfo.HouseId = house.Id;
     _houseManager.SetHouse(house);
     _vehicleInfoManager.SetInfo(player, vehicleInfo);
 }
Exemplo n.º 17
0
 /// <summary>
 /// Записать информацию о доме
 /// </summary>
 public void SetHouse(HouseInfo house)
 {
     ServerState.Houses[house.Id] = house;
 }