예제 #1
0
        /// <summary>
        /// rmvobj packet
        /// </summary>
        /// <param name="packet"></param>
        public void MinilandRemoveObject(RmvobjPacket packet)
        {
            ItemInstance minilandobject = Session.Character.Inventory.LoadBySlotAndType <ItemInstance>(packet.Slot, InventoryType.Miniland);

            if (minilandobject == null)
            {
                return;
            }
            if (Session.Character.MinilandState == MinilandState.LOCK)
            {
                MapDesignObject minilandObject = Session.Character.MapInstance.MapDesignObjects.FirstOrDefault(s => s.ItemInstanceId == minilandobject.Id);
                if (minilandObject == null)
                {
                    return;
                }
                if (minilandobject.Item.IsWarehouse)
                {
                    Session.Character.WareHouseSize = 0;
                }
                Session.Character.MapInstance.MapDesignObjects = Session.Character.MapInstance.MapDesignObjects.Where(s => s != minilandObject);
                Session.SendPacket(minilandObject.GenerateEffect(true));
                Session.SendPacket(Session.Character.GenerateMinilandPoint());
                Session.SendPacket(minilandObject.GenerateMapDesignObject(true));
            }
            else
            {
                Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("MINILAND_NEED_LOCK"), 0));
            }
        }
예제 #2
0
        /// <summary>
        /// addobj packet
        /// </summary>
        /// <param name="packet"></param>
        public void MinilandAddObject(AddobjPacket packet)
        {
            ItemInstance minilandobject = Session.Character.Inventory.LoadBySlotAndType <ItemInstance>(packet.Slot, InventoryType.Miniland);

            if (minilandobject != null)
            {
                if (Session.Character.MapInstance.MapDesignObjects.All(s => s.ItemInstanceId != minilandobject.Id))
                {
                    if (Session.Character.MinilandState == MinilandState.LOCK)
                    {
                        MapDesignObject minilandobj = new MapDesignObject
                        {
                            CharacterId     = Session.Character.CharacterId,
                            ItemInstance    = minilandobject,
                            ItemInstanceId  = minilandobject.Id,
                            MapX            = packet.PositionX,
                            MapY            = packet.PositionY,
                            Level1BoxAmount = 0,
                            Level2BoxAmount = 0,
                            Level3BoxAmount = 0,
                            Level4BoxAmount = 0,
                            Level5BoxAmount = 0
                        };

                        if (minilandobject.Item.ItemType == ItemType.House)
                        {
                            switch (minilandobject.Item.ItemSubType)
                            {
                            case 2:
                                minilandobj.MapX = 31;
                                minilandobj.MapY = 3;
                                break;

                            case 0:
                                minilandobj.MapX = 24;
                                minilandobj.MapY = 7;
                                break;

                            case 1:
                                minilandobj.MapX = 21;
                                minilandobj.MapY = 4;
                                break;
                            }

                            MapDesignObject min = Session.Character.MapInstance.MapDesignObjects.FirstOrDefault(s => s.ItemInstance.Item.ItemType == ItemType.House && s.ItemInstance.Item.ItemSubType == minilandobject.Item.ItemSubType);
                            if (min != null)
                            {
                                MinilandRemoveObject(new RmvobjPacket {
                                    Slot = min.ItemInstance.Slot
                                });
                            }
                        }

                        if (minilandobject.Item.IsWarehouse)
                        {
                            Session.Character.WareHouseSize = minilandobject.Item.MinilandObjectPoint;
                        }
                        Session.Character.MapInstance.MapDesignObjects.Add(minilandobj);
                        Session.SendPacket(minilandobj.GenerateEffect(false));
                        Session.SendPacket(Session.Character.GenerateMinilandPoint());
                        Session.SendPacket(minilandobj.GenerateMapDesignObject(false));
                    }
                    else
                    {
                        Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("MINILAND_NEED_LOCK"), 0));
                    }
                }
                else
                {
                    Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("ALREADY_THIS_MINILANDOBJECT"), 0));
                }
            }
        }
예제 #3
0
        public override async Task ExecuteAsync(AddobjPacket addobjPacket, ClientSession clientSession)
        {
            var minilandobject =
                clientSession.Character.InventoryService.LoadBySlotAndType(addobjPacket.Slot, NoscorePocketType.Miniland);

            if (minilandobject == null)
            {
                return;
            }

            if (clientSession.Character.MapInstance.MapDesignObjects.ContainsKey(minilandobject.Id))
            {
                await clientSession.SendPacketAsync(new MsgPacket
                {
                    Message = GameLanguage.Instance.GetMessageFromKey(LanguageKey.ALREADY_THIS_MINILANDOBJECT,
                                                                      clientSession.Account.Language)
                }).ConfigureAwait(false);

                return;
            }

            if (_minilandProvider.GetMiniland(clientSession.Character.CharacterId).State != MinilandState.Lock)
            {
                await clientSession.SendPacketAsync(new MsgPacket
                {
                    Message = GameLanguage.Instance.GetMessageFromKey(LanguageKey.MINILAND_NEED_LOCK,
                                                                      clientSession.Account.Language)
                }).ConfigureAwait(false);

                return;
            }

            var minilandobj = new MapDesignObject
            {
                MinilandObjectId = Guid.NewGuid(),
                MapX             = addobjPacket.PositionX,
                MapY             = addobjPacket.PositionY,
                Level1BoxAmount  = 0,
                Level2BoxAmount  = 0,
                Level3BoxAmount  = 0,
                Level4BoxAmount  = 0,
                Level5BoxAmount  = 0
            };


            if (minilandobject.ItemInstance?.Item?.ItemType == ItemType.House)
            {
                var min = clientSession.Character.MapInstance.MapDesignObjects
                          .FirstOrDefault(s => (s.Value.InventoryItemInstance?.ItemInstance?.Item?.ItemType == ItemType.House) &&
                                          (s.Value.InventoryItemInstance.ItemInstance.Item.ItemSubType ==
                                           minilandobject.ItemInstance.Item.ItemSubType)).Value;
                if (min != null)
                {
                    await clientSession.HandlePacketsAsync(new[] { new RmvobjPacket {
                                                                       Slot = min.InventoryItemInstance?.Slot ?? 0
                                                                   } }).ConfigureAwait(false);
                }
            }

            _minilandProvider.AddMinilandObject(minilandobj, clientSession.Character.CharacterId, minilandobject);

            await clientSession.SendPacketAsync(minilandobj.GenerateEffect()).ConfigureAwait(false);

            await clientSession.SendPacketAsync(new MinilandPointPacket
                                                { MinilandPoint = minilandobject.ItemInstance?.Item?.MinilandObjectPoint ?? 0, Unknown = 100 }).ConfigureAwait(false);

            await clientSession.SendPacketAsync(minilandobj.GenerateMapDesignObject()).ConfigureAwait(false);
        }