diff --git a/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgInstall.cs b/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgInstall.cs index 7d233e6754..7d3f70bb4e 100644 --- a/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgInstall.cs +++ b/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgInstall.cs @@ -1,14 +1,9 @@ using BrewMonster.Network; using BrewMonster.Scripts.Managers; -using BrewMonster.Scripts.Task; using BrewMonster.UI; -using CSNetwork; -using ModelRenderer.Scripts.Common; using PerfectWorld.Scripts.Managers; -using PerfectWorld.Scripts.Task; using System; using System.Collections.Generic; -using System.Text; using BrewMonster.Scripts; using TMPro; using UnityEngine; @@ -25,23 +20,26 @@ namespace BrewMonster Disenchase } - [Header("Mode")] [SerializeField] private InstallMode m_Mode = InstallMode.Enchase; + [Header("Mode")][SerializeField] private InstallMode m_Mode = InstallMode.Enchase; - [Header("Slot First")] [SerializeField] + [Header("Slot First")] + [SerializeField] private Transform m_SlotFirstParent; [SerializeField] private TextMeshProUGUI m_TxtFirstName; - [Header("Slot Second")] [SerializeField] - private Transform m_SlotSecondlParent; + [Header("Slot Second")] + [SerializeField] + private Transform m_SlotSecondParent; [SerializeField] private TextMeshProUGUI m_TxtSecondName; - [Header("Buttons and Money")] [SerializeField] + [Header("Buttons and Money")] + [SerializeField] private TextMeshProUGUI m_TxtMoney; - [SerializeField] private Button m_BtnMergeOrReset; [SerializeField] private Button m_BtnCancel; + [SerializeField] private Button m_BtnClose; [SerializeField] private Sprite khung_item; [SerializeField] private Transform itemInventoryRoot; @@ -63,10 +61,10 @@ namespace BrewMonster RegisterDrop(m_SlotFirstParent, OnDropEquip); RegisterClick(m_SlotFirstParent, OnClickEquipSlot); - if (m_Mode == InstallMode.Enchase && m_SlotSecondlParent != null) + if (m_Mode == InstallMode.Enchase && m_SlotSecondParent != null) { - RegisterDrop(m_SlotSecondlParent, OnDropMaterial); - RegisterClick(m_SlotSecondlParent, OnClickMaterialSlot); + RegisterDrop(m_SlotSecondParent, OnDropMaterial); + RegisterClick(m_SlotSecondParent, OnClickMaterialSlot); } } @@ -91,23 +89,21 @@ namespace BrewMonster //todo need to set from other class // SetName("Win_Enchase"); m_BtnMergeOrReset.onClick.AddListener(OnClickedMergeOrReset); - m_BtnCancel.onClick.AddListener(OnClickedCancel); + m_BtnCancel.onClick.AddListener(OnCommandCancel); + m_BtnClose.onClick.AddListener(OnCommandCancel); m_install_price = -1; - if (m_SlotSecondlParent != null) - m_SlotSecondlParent.gameObject.SetActive(m_Mode == InstallMode.Enchase); + if (m_SlotSecondParent != null) + m_SlotSecondParent.gameObject.SetActive(m_Mode == InstallMode.Enchase); + ClearEquiment(); + ClearStone(); } public override void OnDisable() { base.OnDisable(); m_BtnMergeOrReset.onClick.RemoveListener(OnClickedMergeOrReset); - m_BtnCancel.onClick.RemoveListener(OnClickedCancel); - } - - public void CloseInstall() - { - gameObject.SetActive(false); - RestoreInventoryColors(); + m_BtnCancel.onClick.RemoveListener(OnCommandCancel); + m_BtnClose.onClick.RemoveListener(OnCommandCancel); } private void RestoreInventoryColors() @@ -190,7 +186,7 @@ namespace BrewMonster if (m_SelectedEquip != null) { ReturnItemToInventory(m_FirstInvSlot); - ClearEquipSlot(); + ClearEquiment(); } } @@ -199,7 +195,7 @@ namespace BrewMonster if (m_SelectedMaterial != null) { ReturnItemToInventory(m_SecondInvSlot); - ClearMaterialSlot(); + ClearStone(); } } @@ -242,6 +238,9 @@ namespace BrewMonster if (item == null) return; + if(!item.IsEquipment()) + return; + EC_IvtrItem detailedItem = EC_IvtrItem.CreateItem(item.m_tid, item.m_expire_date, item.m_iCount); if (item.Content != null && item.Content.Length > 0) detailedItem.SetItemInfo(item.Content, item.Content.Length); @@ -283,6 +282,9 @@ namespace BrewMonster if (item == null) return; + if (item.GetClassID() != (int)EC_IvtrEquip.EQUIP_CLASS_ID.ICID_STONE) + return; + EC_IvtrItem detailedItem = EC_IvtrItem.CreateItem(item.m_tid, item.m_expire_date, item.m_iCount); if (item.Content != null && item.Content.Length > 0) detailedItem.SetItemInfo(item.Content, item.Content.Length); @@ -301,7 +303,7 @@ namespace BrewMonster m_SecondInvSlot = slotIndex; m_TxtSecondName.text = detailedItem.GetName(); - SetSlotIcon(m_SlotSecondlParent, detailedItem); + SetSlotIcon(m_SlotSecondParent, detailedItem); SetInventorySlotGray(btn, true); @@ -359,9 +361,10 @@ namespace BrewMonster img.sprite = EC_IvtrItemUtils.Instance.ResolveItemIconSprite(item.m_tid); img.enabled = img.sprite != null; - img.color = Color.white; img.SetNativeSize(); + + // GetGameUIMan()?.PlayItemSound(item, true); } private void ReturnItemToInventory(int slotIndex) @@ -373,7 +376,7 @@ namespace BrewMonster SetInventorySlotGray(btn, false); } - private void ClearEquipSlot() + private void ClearEquiment() { if (m_FirstInvSlot >= 0) { @@ -392,7 +395,7 @@ namespace BrewMonster } } - private void ClearMaterialSlot() + private void ClearStone() { if (m_SecondInvSlot >= 0) { @@ -403,7 +406,7 @@ namespace BrewMonster m_SelectedMaterial = null; m_SecondInvSlot = -1; m_TxtSecondName.text = "___"; - ClearSlotIcon(m_SlotSecondlParent); + ClearSlotIcon(m_SlotSecondParent); m_TxtMoney.text = "0"; m_install_price = -1; } @@ -447,76 +450,76 @@ namespace BrewMonster }); return; } + EC_IvtrEquip pEquipA = (EC_IvtrEquip)pIvtrA; if (pHost != null && m_Mode == InstallMode.Enchase) { - if (m_Mode == InstallMode.Enchase) + if (pEquipA.GetEmptyHoleNum() <= 0) { - if (pEquipA.GetEmptyHoleNum() <= 0) - { - message = GetGameUIMan().GetStringFromTable(224); - CECUIManager.Instance.ShowMessageBox(new MessageBoxData() - { - Message = message, - Dlg = this - }); - return; - } - - EC_IvtrItem pIvtrB = m_SelectedMaterial; - if (pIvtrB == null || !pIvtrB.IsEmbeddable()) - { - message = GetGameUIMan().GetStringFromTable(225); - CECUIManager.Instance.ShowMessageBox(new MessageBoxData() - { - Message = message, - Dlg = this - }); - return; - } - - if (pIvtrB.GetClassID() != (int)EC_IvtrEquip.EQUIP_CLASS_ID.ICID_STONE) - return; - - int nStoneLevel = ((EC_IvtrStone)pIvtrB).GetDBEssence().level; - int nEquipLevel = -1; - switch (pEquipA.GetClassID()) - { - case (int)EC_IvtrEquip.EQUIP_CLASS_ID.ICID_WEAPON: - nEquipLevel = ((CECIvtrWeapon)pEquipA).GetDBEssence().level; - break; - case (int)EC_IvtrEquip.EQUIP_CLASS_ID.ICID_ARMOR: - nEquipLevel = ((EC_IvtrArmor)pEquipA).GetDBEssence().level; - break; - case (int)EC_IvtrEquip.EQUIP_CLASS_ID.ICID_DECORATION: - nEquipLevel = ((EC_IvtrDecoration)pEquipA).GetDBEssence().level; - break; - } - - if (nStoneLevel > nEquipLevel) - { - message = GetGameUIMan().GetStringFromTable(300); - CECUIManager.Instance.ShowMessageBox(new MessageBoxData() - { - Message = message, - Dlg = this - }); - return; - } - - //pr - UnityGameSession.c2s_CmdNPCSevEmbed( - (ushort)m_SecondInvSlot, (ushort)m_FirstInvSlot, - pIvtrB.GetTemplateID(), pIvtrA.GetTemplateID()); - pHost.GetPack(InventoryConst.IVTRTYPE_PACK).UnfreezeAllItems(); - - message = GetGameUIMan().GetStringFromTable(228); + message = GetGameUIMan().GetStringFromTable(224); CECUIManager.Instance.ShowMessageBox(new MessageBoxData() { Message = message, Dlg = this }); + return; } + + EC_IvtrItem pIvtrB = m_SelectedMaterial; + if (pIvtrB == null || !pIvtrB.IsEmbeddable()) + { + message = GetGameUIMan().GetStringFromTable(225); + CECUIManager.Instance.ShowMessageBox(new MessageBoxData() + { + Message = message, + Dlg = this + }); + return; + } + + if (pIvtrB.GetClassID() != (int)EC_IvtrEquip.EQUIP_CLASS_ID.ICID_STONE) + return; + + int nStoneLevel = ((EC_IvtrStone)pIvtrB).GetDBEssence().level; + int nEquipLevel = -1; + switch (pEquipA.GetClassID()) + { + case (int)EC_IvtrEquip.EQUIP_CLASS_ID.ICID_WEAPON: + nEquipLevel = ((CECIvtrWeapon)pEquipA).GetDBEssence().level; + break; + case (int)EC_IvtrEquip.EQUIP_CLASS_ID.ICID_ARMOR: + nEquipLevel = ((EC_IvtrArmor)pEquipA).GetDBEssence().level; + break; + case (int)EC_IvtrEquip.EQUIP_CLASS_ID.ICID_DECORATION: + nEquipLevel = ((EC_IvtrDecoration)pEquipA).GetDBEssence().level; + break; + } + + if (nStoneLevel > nEquipLevel) + { + message = GetGameUIMan().GetStringFromTable(300); + CECUIManager.Instance.ShowMessageBox(new MessageBoxData() + { + Message = message, + Dlg = this + }); + return; + } + + //pr + UnityGameSession.c2s_CmdNPCSevEmbed( + (ushort)m_SecondInvSlot, (ushort)m_FirstInvSlot, + pIvtrB.GetTemplateID(), pIvtrA.GetTemplateID()); + ClearEquiment(); + ClearStone(); + pHost.GetPack(InventoryConst.IVTRTYPE_PACK).UnfreezeAllItems(); + + message = GetGameUIMan().GetStringFromTable(228); + CECUIManager.Instance.ShowMessageBox(new MessageBoxData() + { + Message = message, + Dlg = this + }); } else if (pHost != null && m_Mode == InstallMode.Disenchase) { @@ -536,7 +539,20 @@ namespace BrewMonster { Message = message, Dlg = this, - MessageBoxType = MessageBoxType.BothYesNoButton + MessageBoxType = MessageBoxType.BothYesNoButton, + OnClickedYes = () => + { + UnityGameSession.c2s_CmdNPCSevClearEmbeddedChip((ushort)m_FirstInvSlot, pIvtrA.GetTemplateID()); + ClearEquiment(); + pHost.GetPack(InventoryConst.IVTRTYPE_PACK).UnfreezeAllItems(); + + string successMessage = GetGameUIMan().GetStringFromTable(230); + CECUIManager.Instance.ShowMessageBox(new MessageBoxData() + { + Message = successMessage, + Dlg = this + }); + } }; CECUIManager.Instance.ShowMessageBox(x); } @@ -546,35 +562,37 @@ namespace BrewMonster } } - private void OnClickedCancel() + private void OnCommandCancel() { - Show(false); - } + m_SelectedEquip?.Freeze(false); + m_SelectedMaterial?.Freeze(false); - public void ResetInstallUI() - { RestoreInventoryColors(); m_SelectedEquip = null; - if (m_Mode == InstallMode.Enchase) - { - m_SelectedMaterial = null; - m_SecondInvSlot = -1; - m_TxtSecondName.text = "___"; - ClearSlotIcon(m_SlotSecondlParent); - } - - m_FirstInvSlot = -1; + m_SelectedMaterial = null; m_TxtFirstName.text = "___"; m_TxtMoney.text = "0"; - m_install_price = -1; + + if (m_Mode == InstallMode.Enchase) + m_TxtSecondName.text = "___"; ClearSlotIcon(m_SlotFirstParent); + if (m_Mode == InstallMode.Enchase) + { + ClearSlotIcon(m_SlotSecondParent); + } + m_install_price = -1; + + var host = GetHostPlayer(); + host?.EndNPCService(); + host?.GetPack(InventoryConst.IVTRTYPE_PACK).UnfreezeAllItems(); gameObject.SetActive(false); } + private void CheckHidePanel(Vector2 screenPos) { if (!RectTransformUtility.RectangleContainsScreenPoint( @@ -596,7 +614,7 @@ namespace BrewMonster //check if material is stone and show price to merge if (m_Mode == InstallMode.Enchase) { - if (m_SelectedMaterial != null) + if (m_SelectedMaterial != null && m_SelectedMaterial is EC_IvtrStone) { stone = (EC_IvtrStone)m_SelectedMaterial; pEssence = stone.GetDBEssence(); @@ -606,6 +624,7 @@ namespace BrewMonster } else { + m_install_price = 0; m_TxtMoney.text = $"{0}"; } } @@ -622,12 +641,15 @@ namespace BrewMonster stone = (EC_IvtrStone)EC_IvtrItem.CreateItem(idItem, 0, 1); pEssence = stone.GetDBEssence(); nAmount += pEssence.uninstall_price; + stone = null; } + m_install_price = nAmount; m_TxtMoney.text = $"{nAmount}"; } else { + m_install_price = 0; m_TxtMoney.text = $"{0}"; } } diff --git a/Assets/Prefabs/UI/DlgInstall.prefab b/Assets/Prefabs/UI/DlgInstall.prefab index fd8a549ed5..6f3794f91f 100644 --- a/Assets/Prefabs/UI/DlgInstall.prefab +++ b/Assets/Prefabs/UI/DlgInstall.prefab @@ -3554,7 +3554,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 0.392} + m_Color: {r: 1, g: 1, b: 1, a: 0} m_RaycastTarget: 1 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 @@ -10541,7 +10541,7 @@ MonoBehaviour: m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 1, g: 1, b: 1, a: 0} - m_RaycastTarget: 1 + m_RaycastTarget: 0 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 m_OnCullStateChanged: @@ -10569,14 +10569,17 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 0785d9ccbdc425a44b6ae1f4a3afad06, type: 3} m_Name: m_EditorClassIdentifier: + skillNameText: {fileID: 0} + imageProgress: {fileID: 0} m_Mode: 0 m_SlotFirstParent: {fileID: 5489844476385409289} m_TxtFirstName: {fileID: 3128721472606901163} - m_SlotSecondlParent: {fileID: 7151360590639773519} + m_SlotSecondParent: {fileID: 7151360590639773519} m_TxtSecondName: {fileID: 4492084240745408081} m_TxtMoney: {fileID: 6140428454487430115} m_BtnMergeOrReset: {fileID: 8208092408021918524} m_BtnCancel: {fileID: 4503836757578509720} + m_BtnClose: {fileID: 5942200196902544367} khung_item: {fileID: 21300000, guid: a5366f3bce011c046902e39b6bd3a077, type: 3} itemInventoryRoot: {fileID: 7750009739432212686} --- !u!1 &5641506892578507279 @@ -12072,6 +12075,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 12345678901234567890123456789012, type: 3} m_Name: m_EditorClassIdentifier: + skillNameText: {fileID: 0} + imageProgress: {fileID: 0} inventoryPackButtons: - {fileID: 3263912320807982326} - {fileID: 7118617704469309534} diff --git a/Assets/Prefabs/UI/DlgUninstall.prefab b/Assets/Prefabs/UI/DlgUninstall.prefab index 7e106f1584..99616be4f8 100644 --- a/Assets/Prefabs/UI/DlgUninstall.prefab +++ b/Assets/Prefabs/UI/DlgUninstall.prefab @@ -12611,6 +12611,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 12345678901234567890123456789012, type: 3} m_Name: m_EditorClassIdentifier: + skillNameText: {fileID: 0} + imageProgress: {fileID: 0} inventoryPackButtons: - {fileID: 7349348188983894504} - {fileID: 3445126299409532821} @@ -14368,7 +14370,7 @@ MonoBehaviour: m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 1, g: 1, b: 1, a: 0} - m_RaycastTarget: 1 + m_RaycastTarget: 0 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 m_OnCullStateChanged: @@ -14396,14 +14398,17 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 0785d9ccbdc425a44b6ae1f4a3afad06, type: 3} m_Name: m_EditorClassIdentifier: + skillNameText: {fileID: 0} + imageProgress: {fileID: 0} m_Mode: 1 m_SlotFirstParent: {fileID: 7418547291555597629} m_TxtFirstName: {fileID: 8969434063030871197} - m_SlotSecondlParent: {fileID: 0} + m_SlotSecondParent: {fileID: 0} m_TxtSecondName: {fileID: 0} m_TxtMoney: {fileID: 4189875348703427985} m_BtnMergeOrReset: {fileID: 4189663341364179351} m_BtnCancel: {fileID: 5948134181014720611} + m_BtnClose: {fileID: 7824290302850289289} khung_item: {fileID: 21300000, guid: a5366f3bce011c046902e39b6bd3a077, type: 3} itemInventoryRoot: {fileID: 7451395605081796144} --- !u!1 &8698343819671822384 @@ -14744,7 +14749,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 0.392} + m_Color: {r: 1, g: 1, b: 1, a: 0} m_RaycastTarget: 1 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1