Beispiel #1
0
    public static void C_EquipItemHandler(PacketSession session, IMessage packet)
    {
        // 클라 : 이 무기를 장착/해지 하고싶어!
        C_EquipItem   equipItemPacket = packet as C_EquipItem;
        ClientSession clientSession   = session as ClientSession;

        // 게임룸
        Player player = clientSession.MyPlayer;

        if (player == null)
        {
            return;
        }

        GameRoom room = clientSession.MyPlayer.Room;

        if (room == null)
        {
            return;
        }
        // 스킬처리
        //room.HandleSkill(player, skillPacket);
        room.Push(room.HandleEquipItem, player, equipItemPacket);

        Console.WriteLine($"equipItem ({equipItemPacket.ItemDbId})");
    }
    public override void Init()
    {
        _icon.gameObject.BindEvent((e) =>
        {
            Debug.Log("Click Item");

            Data.ItemData itemData = null;
            Managers.Data.ItemDict.TryGetValue(TemplateId, out itemData);

            if (itemData == null)
            {
                return;
            }


            // TODO : C_USE_ITEM 아이템 사용 패킷
            if (itemData.itemType == ItemType.Consumable)
            {
                return;
            }

            C_EquipItem equipPacket = new C_EquipItem();
            equipPacket.ItemDbId    = ItemDbId;
            equipPacket.Equipped    = !Equipped;

            Managers.Network.Send(equipPacket);
        });
    }
        public void HandleEquipItem(Player player, C_EquipItem equipPacket)
        {
            if (player == null)
            {
                return;
            }

            player.HandleEquipItem(equipPacket);
        }
    public static void C_EquipItemHandler(PacketSession session, IMessage packet)
    {
        C_EquipItem   equipPacket   = (C_EquipItem)packet;
        ClientSession clientSession = session as ClientSession;

        Player player = clientSession.MyPlayer;

        if (player == null)
        {
            return;
        }

        GameRoom room = player.Room;

        if (room == null)
        {
            return;
        }

        room.Push(room.HandleEquipItem, player, equipPacket);
    }
    public override void Init()
    {
        // 컴포넌트 바인딩
        Bind <Image>(typeof(Images));

        _frame = GetImage((int)Images.Frame);
        _icon  = GetImage((int)Images.ItemIcon);

        _frame.gameObject.SetActive(false);
        //_icon.gameObject.SetActive(false);

        // 이벤트핸들러 등록
        _icon.gameObject.BindEvent((e) =>
        {
            // 여기서 아이템 클릭했을때 실행할 코드
            Debug.Log("Click Item");

            // 템플릿ID로 아이템 정보 조회
            Data.ItemData itemData = null;
            Managers.Data.ItemDict.TryGetValue(TemplateId, out itemData);

            if (itemData == null)
            {
                return;
            }

            // TODO 소무품 아이템 사용!
            if (itemData.itemType == ItemType.Consumable)
            {
                return;
            }

            C_EquipItem equipPacket = new C_EquipItem();
            equipPacket.ItemDbId    = ItemDbId;
            equipPacket.Equipped    = !Equipped;

            Managers.Network.Send(equipPacket);
        });
    }
Beispiel #6
0
        public void HandleEquipItem(C_EquipItem equipPacket)
        {
            Item item = Inven.Get(equipPacket.ItemDbId);

            if (item == null)
            {
                return;
            }

            if (item.ItemType == ItemType.Consumable)
            {
                return;
            }

            // 착용 요청이라면, 겹치는 부위 해제
            if (equipPacket.Equipped)
            {
                Item unequipItem = null;

                if (item.ItemType == ItemType.Weapon)
                {
                    unequipItem = Inven.Find(i => i.Equipped && i.ItemType == ItemType.Weapon);
                }
                else if (item.ItemType == ItemType.Armor)
                {
                    ArmorType armorType = ((Armor)item).ArmorType;
                    unequipItem = Inven.Find(i => i.Equipped && i.ItemType == ItemType.Armor && ((Armor)i).ArmorType == armorType);
                }

                if (unequipItem != null)
                {
                    // 메모리 선적용
                    unequipItem.Equipped = false;

                    // DB Noti
                    DbTransaction.EquipItemNoti(this, unequipItem);

                    // 클라이언트 Noti
                    S_EquipItem equipOkItem = new S_EquipItem();
                    equipOkItem.ItemDbId = unequipItem.ItemDbId;
                    equipOkItem.Equipped = unequipItem.Equipped;
                    Session.Send(equipOkItem);
                }
            }

            {
                // 메모리 선적용
                item.Equipped = equipPacket.Equipped;

                // DB Noti
                DbTransaction.EquipItemNoti(this, item);

                // 클라이언트 Noti
                S_EquipItem equipOkItem = new S_EquipItem();
                equipOkItem.ItemDbId = equipPacket.ItemDbId;
                equipOkItem.Equipped = equipPacket.Equipped;
                Session.Send(equipOkItem);
            }

            RefreshAdditionalStat();
        }
Beispiel #7
0
        public void HandleEquipItem(C_EquipItem equipPacket)
        {
            // 아이템 있나 체크
            Item item = this.Inven.Get(equipPacket.ItemDbId);

            if (item == null)
            {
                return;
            }

            if (item.ItemType == ItemType.Consumable)
            {
                return;//소모품은 장착아님
            }
            // 장착 요청이면 겹치는 부위 해제
            if (equipPacket.Equipped)
            {
                Item unequipItem = null;

                // 무기는 하나만
                if (item.ItemType == ItemType.Weapon)
                {
                    unequipItem = this.Inven.Find(
                        i => i.Equipped && i.ItemType == ItemType.Weapon);
                }
                // 방어구는 비교
                else if (item.ItemType == ItemType.Armor)
                {
                    ArmorType armorType = ((Armor)item).ArmorType;
                    unequipItem = this.Inven.Find(
                        i => i.Equipped && i.ItemType == ItemType.Armor && ((Armor)i).ArmorType == armorType);
                }
                // 겹치는 아이템 벗기
                if (unequipItem != null)
                {
                    // 메모리 선적용
                    unequipItem.Equipped = false;

                    // DB에 Noti
                    DbTransaction.EquipItemNoti(this, unequipItem);

                    // 클라에 통보
                    S_EquipItem equipOkItem = new S_EquipItem();
                    equipOkItem.ItemDbId = unequipItem.ItemDbId;
                    equipOkItem.Equipped = unequipItem.Equipped;
                    this.Session.Send(equipOkItem);
                }
            }
            // 요청사항 적용
            {
                // 메모리 선적용
                item.Equipped = equipPacket.Equipped;

                // DB에 Noti
                DbTransaction.EquipItemNoti(this, item);

                // 클라에 통보
                S_EquipItem equipOkItem = new S_EquipItem();
                equipOkItem.ItemDbId = equipPacket.ItemDbId;
                equipOkItem.Equipped = equipPacket.Equipped;
                this.Session.Send(equipOkItem);
            }
            RefreshAdditionalStat();
        }