Ejemplo n.º 1
0
        public static void HandlePacket(object session, string packet)
        {
            string[] packetSplit = packet.Split(' ');
            if (packetSplit.Length < 3)
            {
                return;
            }
            MinilandRemoveObject packetDefinition = new MinilandRemoveObject();

            if (short.TryParse(packetSplit[2], out short slot))
            {
                packetDefinition.Slot = slot;
                packetDefinition.ExecuteHandler(session as ClientSession);
            }
        }
Ejemplo n.º 2
0
        private void ExecuteHandler(ClientSession session)
        {
            ItemInstance minilandobject =
                session.Character.Inventory.LoadBySlotAndType <ItemInstance>(Slot, InventoryType.Miniland);

            if (minilandobject != null)
            {
                if (session.Character.MinilandObjects.All(s => s.ItemInstanceId != minilandobject.Id))
                {
                    if (session.Character.MinilandState == MinilandState.Lock)
                    {
                        MinilandObject minilandobj = new MinilandObject
                        {
                            CharacterId     = session.Character.CharacterId,
                            ItemInstance    = minilandobject,
                            ItemInstanceId  = minilandobject.Id,
                            MapX            = PositionX,
                            MapY            = 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;
                            }

                            MinilandObject min = session.Character.MinilandObjects.Find(s =>
                                                                                        s.ItemInstance.Item.ItemType == ItemType.House && s.ItemInstance.Item.ItemSubType
                                                                                        == minilandobject.Item.ItemSubType);
                            if (min != null)
                            {
                                MinilandRemoveObject.HandlePacket(session, $"1 rmobj {Slot}");
                            }
                        }

                        if (minilandobject.Item.IsMinilandObject)
                        {
                            session.Character.WareHouseSize = minilandobject.Item.MinilandObjectPoint;
                        }

                        session.Character.MinilandObjects.Add(minilandobj);
                        session.SendPacket(minilandobj.GenerateMinilandEffect(false));
                        session.SendPacket(session.Character.GenerateMinilandPoint());
                        session.SendPacket(minilandobj.GenerateMinilandObject(false));
                    }
                    else
                    {
                        session.SendPacket(
                            UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("MINILAND_NEED_LOCK"),
                                                            0));
                    }
                }
                else
                {
                    session.SendPacket(
                        UserInterfaceHelper.GenerateMsg(
                            Language.Instance.GetMessageFromKey("ALREADY_THIS_MINILANDOBJECT"), 0));
                }
            }
        }