VOID CObject_PlayerOther::OnHideWeapon(INT nAppointedWeaponID) { if(nAppointedWeaponID != INVALID_ID) { EquipItem_BodyLocator( HEQUIP_WEAPON, nAppointedWeaponID); } else { //卸载装备 UnEquipItem(HEQUIP_WEAPON); } }
void UAREquipmentComponent::ChangeItem(FARDragDropInfo ItemIn, int32 OldItemSlotID) { bool itemRemoved = false; if (GetOwnerRole() < ROLE_Authority) { ServerChangeItem(ItemIn, OldItemSlotID); } else { //check if there is something in that particular slot for (AARItem* eqItem : EquippedItems) { if (eqItem->ItemSlotEquipped == ItemIn.ItemSlot) { FARDragDropInfo tempItem; tempItem.ItemKey = eqItem->ItemID; tempItem.ItemSlot = eqItem->ItemSlotEquipped; //if there is, Unequip it. Before we proceed. UnEquipItem(ItemIn); itemRemoved = Inventory->RemoveItemFromInventory(ItemIn.ItemKey, ItemIn.SlotIndex); Inventory->AddItemToInventoryOnSlot(tempItem, OldItemSlotID); } } switch (ItemIn.DragDropSlot) { case EDragDropSlot::Chest: { if (ChangeChestItem(ItemIn)) { if (!itemRemoved) { Inventory->RemoveItemFromInventory(ItemIn.ItemKey, ItemIn.SlotIndex); break; } } break; } case EDragDropSlot::LeftHand: { AddWeapon(ItemIn, OldItemSlotID, 0); } case EDragDropSlot::RightHand: { AddWeapon(ItemIn, OldItemSlotID, 1); } default: break; } } }
void UAREquipmentComponent::ChangeItem(FInventorySlot ItemIn, int32 OldItemSlotID) { bool itemRemoved = false; if (GetOwnerRole() < ROLE_Authority) { ServerChangeItem(ItemIn, OldItemSlotID); } else { //check if there is something in that particular slot for (AARItem* eqItem : EquippedItems) { if (eqItem->ItemSlotEquipped == ItemIn.ItemSlot) { FInventorySlot tempItem; tempItem.ItemID = eqItem->ItemID; tempItem.ItemSlot = eqItem->ItemSlotEquipped; //if there is, Unequip it. Before we proceed. UnEquipItem(ItemIn); itemRemoved = TargetController->RemoveItemFromInventory(ItemIn.ItemID, ItemIn.SlotID); TargetController->AddItemToInventoryOnSlot(tempItem, OldItemSlotID); } } switch (ItemIn.EEquipmentSlot) { case EEquipmentSlot::Item_Chest: { if (ChangeChestItem(ItemIn)) { if (!itemRemoved) { TargetController->RemoveItemFromInventory(ItemIn.ItemID, ItemIn.SlotID); break; } } break; } case EEquipmentSlot::Item_LeftHandOne: { AddLeftHandWeapon(ItemIn.ItemID); } default: break; } } }
void GStateScene::ShopInputEvent(GnInterface* pInterface, GnIInputEvent* pEvent) { if( pEvent->GetEventType() == GnIInputEvent::PUSH ) { if( pInterface->GetTegID() == GInterfaceLayer::LISTITEM_SHOP ) { if( ViewItemExplain( mpCurrentShopItem, pInterface ) ) { if( mpCurrentInvenItem ) mpCurrentInvenItem->SetVisibleExplain( false ); if( mpCurrentEquipItem ) mpCurrentEquipItem->SetVisibleExplain( false ); } } else if( pInterface->GetTegID() == GInterfaceLayer::LISTITEM_INVEN ) { if( ViewItemExplain( mpCurrentInvenItem, pInterface ) ) { if( mpCurrentShopItem ) mpCurrentShopItem->SetVisibleExplain( false ); if( mpCurrentEquipItem ) mpCurrentEquipItem->SetVisibleExplain( false ); } } else { if( ViewItemExplain( mpCurrentEquipItem, pInterface ) ) { if( mpCurrentShopItem ) mpCurrentShopItem->SetVisibleExplain( false ); if( mpCurrentInvenItem ) mpCurrentInvenItem->SetVisibleExplain( false ); } } } else if( pEvent->GetEventType() == GnIInputEvent::PUSHUP ) { GStateUILayer* interfaceLayer = (GStateUILayer*)mpInterfaceLayer; switch( pInterface->GetTegID() ) { case GInterfaceLayer::BT_BUY_ITEM: BuyItem( interfaceLayer->GetInventoryListCtrl(), interfaceLayer->GetEquipListCtrl() , interfaceLayer->GetMoneyLabel(), mpCurrentShopItem ); break; case GInterfaceLayer::BT_SELL_ITEM: if( SellItem( interfaceLayer->GetInventoryListCtrl(), interfaceLayer->GetEquipListCtrl() , interfaceLayer->GetMoneyLabel(), mpCurrentInvenItem ) == 0 ) { if( mpCurrentInvenItem ) { mpCurrentInvenItem->SetVisibleExplain( false ); mpCurrentInvenItem = NULL; } } break; case GInterfaceLayer::BT_EQUIP_ITEM: EquipItem( interfaceLayer->GetInventoryListCtrl(), interfaceLayer->GetEquipListCtrl() , mpCurrentInvenItem ); // if( mpCurrentInvenItem ) // { // mpCurrentInvenItem->SetVisibleExplain( false ); // mpCurrentInvenItem = NULL; // } break; case GInterfaceLayer::BT_UNEQUIP_ITEM: UnEquipItem( interfaceLayer->GetInventoryListCtrl(), interfaceLayer->GetEquipListCtrl() , mpCurrentEquipItem ); if( mpCurrentEquipItem ) { mpCurrentEquipItem->SetVisibleExplain( false ); mpCurrentEquipItem = NULL; } break; } } }
VOID CObject_PlayerOther::UpdateEquip(HUMAN_EQUIP point) { CCharacterData *pCharacterData = GetCharacterData(); if(pCharacterData == NULL) { return ; } if(point == HEQUIP_WEAPON && IsHideWeapon()) { return ; } if(!GetFakeObjectFlag()) { if(pCharacterData->Get_ModelID() != INVALID_ID) { return ; } } //生成一个临时的Item对象 CObject_Item_Equip *pTempEquip = NULL; INT nID = pCharacterData->Get_Equip(point); if(nID != INVALID_ID) { pTempEquip = (CObject_Item_Equip *)CObject_Item::NewItem(nID); } //如果是装备根据装配点装备物品 if(pTempEquip != NULL && ICLASS_EQUIP == pTempEquip->GetItemClass()) { switch(pTempEquip->GetItemType()) { case HEQUIP_WEAPON: //武器,挂接类装备 { EquipItem_BodyLocator(pTempEquip->GetItemType(), pTempEquip->GetVisualID()); SetWeaponType( pTempEquip->GetWeaponType() ); } break; case HEQUIP_CAP: //帽子, 身体, 手臂, 鞋, 装备类物品 case HEQUIP_ARMOR: case HEQUIP_CUFF: case HEQUIP_BOOT: { EquipItem_BodyPart(pTempEquip->GetItemType(), pTempEquip->GetVisualID()); } break; case HEQUIP_SASH: //腰带, 戒子, 项链 case HEQUIP_RING: case HEQUIP_NECKLACE: default: break; } } else { //卸载装备 UnEquipItem(point); } //如果是UI物体,重新设置VisibleFlag if(GetFakeObjectFlag()) { m_pRenderInterface->Actor_SetUIVisibleFlag(); } CObject_Item::DestroyItem(pTempEquip); }
void UAREquipmentComponent::ServerUnEquipItem_Implementation(FARDragDropInfo ItemIn) { UnEquipItem(ItemIn); }
void UAREquipmentComponent::ServerUnEquipItem_Implementation(FInventorySlot ItemIn) { UnEquipItem(ItemIn); }