private void OnItemUse(HotkeyCallback callback) { if (callback.performed) { if (OwnerView.State.GetTipData() == null) { return; } if (m_CurrentSelectedItemData != null) { if (m_CurrentItemData?.GetReference() == m_CurrentSelectedItemData.UID) //拆 { NetworkManager.Instance.GetPackageController().ReqestMove( m_CurrentItemData.GetUID(), PackageProxy.GetPackage(m_Category).UID, Parent.Data.CurrentShip.GetUID()); PlayerSound(isAdd: false, m_Category == Category.Equipment ? (m_CurrentSelectedItemData as ItemEquipmentVO).EquipmentType : 0); } else //装 { NetworkManager.Instance.GetPackageController().ReqestMove( m_CurrentSelectedItemData.UID, m_ContainerUID, m_ContainerPOS, Parent.Data.CurrentShip.GetUID()); PlayerSound(isAdd: true, m_Category == Category.Equipment ? (m_CurrentSelectedItemData as ItemEquipmentVO).EquipmentType : 0); } } } }
/// <summary> /// 更新背包大小 /// </summary> private void UpdatePackSize() { int pageIndex = State.GetPageIndex(); PackageProxy pack = GameFacade.Instance.RetrieveProxy(ProxyName.PackageProxy) as PackageProxy; ItemContainer m_Container = null; PackagePageType packType = (PackagePageType)pageIndex; switch (packType) { case PackagePageType.Consumables: m_Container = pack.GetPackage(Category.Expendable); break; case PackagePageType.Material: m_Container = pack.GetPackage(Category.Material); break; case PackagePageType.Weapons: m_Container = pack.GetPackage(Category.Weapon); break; case PackagePageType.Converters: m_Container = pack.GetPackage(Category.Reformer); break; case PackagePageType.Devices: m_Container = pack.GetPackage(Category.Equipment); break; case PackagePageType.Chips: m_Container = pack.GetPackage(Category.EquipmentMod); break; } int m_Count = m_Container != null && m_Container.Items != null ? m_Container.Items.Count : 0; int m_MaxCount = m_Container != null ? (int)m_Container.CurrentSizeMax : 100; State.SetPageLabel(State.GetPageIndex(), string.Format(GetLocalization("package_title_1008"), m_Count, m_MaxCount)); }
protected override void OnViewPartLoaded() { base.OnViewPartLoaded(); m_UIScrollRect = FindComponent <UIScrollRect>("Content/Scroller"); m_UIScrollRect.SetSelection(new Vector2Int(0, 0)); ClearData(); m_Items = new List <ItemBase>(); switch (Parent.Data.State) { case WarshipPanelState.ListWeapon: m_Category = Category.Weapon; m_CurrentItemData = Parent.Data.CurrentWeaponData.Data; m_ContainerUID = Parent.Data.CurrentWeaponData.ContainerUID; m_ContainerPOS = Parent.Data.CurrentWeaponData.ContainerPOS; break; case WarshipPanelState.ListReformer: m_Category = Category.Reformer; m_CurrentItemData = Parent.Data.CurrentReformerData.Data; m_ContainerUID = Parent.Data.CurrentReformerData.ContainerUID; m_ContainerPOS = Parent.Data.CurrentReformerData.ContainerPOS; break; case WarshipPanelState.ListEquip: m_Category = Category.Equipment; m_CurrentItemData = Parent.Data.CurrentEquipmentData.Data; m_ContainerUID = Parent.Data.CurrentEquipmentData.ContainerUID; m_ContainerPOS = Parent.Data.CurrentEquipmentData.ContainerPOS; break; case WarshipPanelState.ListMod: m_Category = Category.EquipmentMod; m_CurrentWeapon = Parent.Data.CurrentWeaponData.Data; m_CurrentWeaponContainerUID = Parent.Data.CurrentWeaponData.ContainerUID; m_CurrentWeaponContainerPOS = Parent.Data.CurrentWeaponData.ContainerPOS; m_CurrentItemData = Parent.Data.CurrentModData.Data; m_ContainerUID = Parent.Data.CurrentModData.ContainerUID; m_ContainerPOS = Parent.Data.CurrentModData.ContainerPOS; if (Parent.Data.BeforeState == WarshipPanelState.ModMainShip) { SendViewerChange(Parent.Data.CurrentShip.GetTID(), true); } else { SendViewerChange(m_CurrentWeapon.GetTID(), false); } break; } m_ItemsDic = PackageProxy.GetPackage(m_Category).Items; if (m_ItemsDic != null && m_ItemsDic.Count > 0) { foreach (var item in m_ItemsDic) { switch (m_Category) { case Category.Weapon when m_ContainerPOS == 0 && Parent.Data.CurrentShip.GetWarShipType() == WarshipL1.FightWarship && (item.Value as ItemWeaponVO).WeaponType1 == WeaponL1.Fighting: case Category.Weapon when m_ContainerPOS == 0 && Parent.Data.CurrentShip.GetWarShipType() == WarshipL1.MiningShip && (item.Value as ItemWeaponVO).WeaponType1 == WeaponL1.Mining: case Category.Weapon when m_ContainerPOS == 0 && Parent.Data.CurrentShip.GetWarShipType() == WarshipL1.SurveillanceShip && (item.Value as ItemWeaponVO).WeaponType1 == WeaponL1.Treasure: case Category.Weapon when m_ContainerPOS != 0 && (item.Value as ItemWeaponVO).WeaponType1 == WeaponL1.Fighting: case Category.Reformer: case Category.Equipment when(item.Value as ItemEquipmentVO).EquipmentType == (EquipmentL1)(m_ContainerPOS + 1): case Category.EquipmentMod when(item.Value as ItemModVO).ModType1 == Parent.Data.CurrentModData.ModType1 && (item.Value as ItemModVO).ModType2 == Parent.Data.CurrentModData.ModType2: m_Items.Add(item.Value); break; } } } AddDatas(null, m_Items.ToArray()); ShowCharacter(); }