diff --git a/Assets/PerfectWorld/Resources/UI/DialogScriptTableObject.asset b/Assets/PerfectWorld/Resources/UI/DialogScriptTableObject.asset index 24be82aded..294dfb24bf 100644 --- a/Assets/PerfectWorld/Resources/UI/DialogScriptTableObject.asset +++ b/Assets/PerfectWorld/Resources/UI/DialogScriptTableObject.asset @@ -17,3 +17,5 @@ MonoBehaviour: prefab: {fileID: 8237288432181259026, guid: 7653e7e64393ec24c903f0606499b8c4, type: 3} - id: DialogNPCShop prefab: {fileID: 8237288432181259026, guid: eaeb778b6aab3d74299373b3a96b72c4, type: 3} + - id: Win_Award + prefab: {fileID: 903595479696773158, guid: cf26d96ae7d984ba8a5b6cef44adffeb, type: 3} diff --git a/Assets/PerfectWorld/Scene/TaskTest.unity b/Assets/PerfectWorld/Scene/TaskTest.unity index 4b95fd26fc..79f0527a85 100644 --- a/Assets/PerfectWorld/Scene/TaskTest.unity +++ b/Assets/PerfectWorld/Scene/TaskTest.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:79aee339596409d8a47e0a553b1257768bd84fa0e0d6261052b33c1077658ab0 -size 41493 +oid sha256:013ea9a5ad664a8ed7ae162ffb1f16e0da6571fb6660ad5b4f1736197f8e3fd4 +size 41531 diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommandFactory.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommandFactory.cs index 45825038c8..efcdc4e9fb 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommandFactory.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommandFactory.cs @@ -24,7 +24,7 @@ namespace CSNetwork.C2SCommand } // Generic command serializationw - public static Octets SerializeCommand(CommandID cmdId, T command) + public static Octets SerializeCommand(CommandID cmdId, T command, bool writeLength = true) where T : struct { var octets = new Octets(); @@ -33,7 +33,7 @@ namespace CSNetwork.C2SCommand WriteBasicValue(octets, (ushort)cmdId); // Write command body - WriteStruct(octets, command); + WriteStruct(octets, command, writeLength); return octets; } @@ -76,7 +76,7 @@ namespace CSNetwork.C2SCommand return octets; } - private static void WriteStruct(Octets octets, T value) + private static void WriteStruct(Octets octets, T value, bool writeLength=true) where T : struct { // Get fields of the struct @@ -103,7 +103,7 @@ namespace CSNetwork.C2SCommand } else if (fieldType.IsArray) { - WriteArray(octets, (Array)fieldValue); + WriteArray(octets, (Array)fieldValue, writeLength); } } else if (fieldType.IsEnum) @@ -191,7 +191,7 @@ namespace CSNetwork.C2SCommand octets.Insert(octets.Size, strBytes.AsSpan(0, length).ToArray()); } - private static void WriteArray(Octets octets, Array array) + private static void WriteArray(Octets octets, Array array, bool writeLength) { if (octets == null) return; @@ -201,7 +201,7 @@ namespace CSNetwork.C2SCommand return; } - if (array.Length != 1 ) + if (array.Length != 1 && writeLength) { WriteBasicValue(octets, array.Length); } @@ -666,7 +666,7 @@ namespace CSNetwork.C2SCommand size = dwDataSize, placeholder = pData }; - return SerializeCommand(CommandID.TASK_NOTIFY, cmd); + return SerializeCommand( CommandID.TASK_NOTIFY, cmd, false); } } } diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs index dfd8303375..ac2baea4cb 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs @@ -1818,5 +1818,16 @@ namespace CSNetwork.GPDataType public int vigour; public ROLEEXTPROP prop; }; + + [ StructLayout(LayoutKind.Sequential, Pack = 1)] + struct cmd_task_deliver_item + { + public int type; + public int expire_date; + public uint amount; + public uint slot_amount; + public byte where; //���ĸ���������0 ��׼��2 ����1 װ�� + public byte index; //��󲿷ַ����ĸ�λ�� + }; } diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs index 5fe6264a21..c5548dce06 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs @@ -503,6 +503,8 @@ namespace CSNetwork break; case CommandID.PICKUP_ITEM: case CommandID.HOST_OBTAIN_ITEM: + // case CommandID.PRODUCE_ONCE: + case CommandID.TASK_DELIVER_ITEM: EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_PICKUPITEM, (int)MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader); break; @@ -1283,7 +1285,7 @@ namespace CSNetwork gamedatasend gamedatasend = new gamedatasend(); gamedatasend.Data = C2SCommandFactory.CreateTaskNotifyCmd( pData, dwDataSize); //todo send data curent get error message 3 - // SendProtocol(gamedatasend); + SendProtocol(gamedatasend); } public void c2s_SendCmdStandUp() diff --git a/Assets/PerfectWorld/Scripts/Task/ATaskTemplMan.cs b/Assets/PerfectWorld/Scripts/Task/ATaskTemplMan.cs index b57e757c38..2f183be64f 100644 --- a/Assets/PerfectWorld/Scripts/Task/ATaskTemplMan.cs +++ b/Assets/PerfectWorld/Scripts/Task/ATaskTemplMan.cs @@ -674,7 +674,20 @@ namespace BrewMonster.Scripts.Task // void ForceRemoveFinishTask(TaskInterface* pTask, unsigned long ulTask); public bool IsDynTasksVerified() { return m_bDynTasksVerified; } void SetDynTasksVerified(bool b) { m_bDynTasksVerified = b; } - // void OnDynTasksTimeMark(TaskInterface* pTask, unsigned long ulTimeMark, unsigned short version); + public void OnDynTasksTimeMark(TaskInterface pTask, uint ulTimeMark, ushort version) + { + if (version != DYN_TASK_CUR_VERSION) + return; + + if (m_ulDynTasksTimeMark == ulTimeMark && LoadDynTasksFromPack(m_szDynPackPath)) + { + SetDynTasksVerified(true); + pTask.InitActiveTaskList(); + UpdateDynDataNPCService(); + } + else + _notify_svr(pTask, ClientNotificationConstants.TASK_CLT_NOTIFY_DYN_DATA, 0); + } public void OnDynTasksData(TaskInterface pTask, byte[] data, int sz, bool ended) { if (m_bDynTasksVerified) @@ -968,6 +981,57 @@ namespace BrewMonster.Scripts.Task child = child.m_pNextSibling; } } + + bool LoadDynTasksFromPack(string szPath) + { + // TaskInterface::WriteLog(0, 0, 2, "LoadDynPack begin"); + + // FILE* fp = fopen(szPath, "rb"); + FileStream fp = new FileStream(szPath, FileMode.Open, FileAccess.Read); + if (fp == null) + { + // TaskInterface::WriteLog(0, 0, 0, "LoadDynTasksFromPack, no such file"); + BMLogger.LogError("[ATaskTemplMan] LoadDynTasksFromPack, no such file"); + return false; + } + + // fseek(fp, 0, SEEK_END); + // size_t sz = ftell(fp); + // fseek(fp, 0, SEEK_SET); + + long sz = fp.Length; + + + if (sz == 0) + { + fp.Close(); + return false; + } + + // char* buf = new char[sz]; + byte[] buf = new byte[sz]; + g_ulNewCount++; + // fread(buf, 1, sz, fp); + long offset = 0; + buf = AAssit.ReadArrayFromBinary( fp, (int)sz, ref offset); + fp.Close(); + + if (!UnmarshalDynTasks(buf, (int)sz, false)) + { + // LOG_DELETE_ARR(buf); + return false; + } + +#if _TASK_CLIENT + // LOG_DELETE_ARR(buf); +#else + m_pDynTasksData = buf; + m_ulDynTasksDataSize = sz; + UpdateDynDataNPCService(); +#endif + + return true; + } } [ StructLayout(LayoutKind.Sequential, Pack = 1) ] diff --git a/Assets/PerfectWorld/Scripts/Task/CECTaskInterface.cs b/Assets/PerfectWorld/Scripts/Task/CECTaskInterface.cs index b8dd0447e1..d60122cf27 100644 --- a/Assets/PerfectWorld/Scripts/Task/CECTaskInterface.cs +++ b/Assets/PerfectWorld/Scripts/Task/CECTaskInterface.cs @@ -4,6 +4,7 @@ using PerfectWorld.Scripts.Task; using System.Collections.Generic; using System.IO; using System.Runtime.InteropServices; +using BrewMonster.UI; using CSNetwork; using UnityEngine; @@ -1613,11 +1614,11 @@ namespace BrewMonster.Scripts.Task public void UpdateTaskUI(uint idTask, int reason) { // TODO: update task UI - // CECGameUIMan* pGameUI = g_pGame->GetGameRun()->GetUIManager()->GetInGameUIMan(); - // if (pGameUI) - // { - // pGameUI->UpdateTask(idTask, reason); - // } + CECGameUIMan pGameUI = CECUIManager.Instance.GetInGameUIMan(); + if (pGameUI != null ) + { + pGameUI.UpdateTask(idTask, reason); + } } public bool IsTitleDataReady() diff --git a/Assets/PerfectWorld/Scripts/Task/TaskClient.cs b/Assets/PerfectWorld/Scripts/Task/TaskClient.cs index 4bf6ebe2a9..b7b328db7f 100644 --- a/Assets/PerfectWorld/Scripts/Task/TaskClient.cs +++ b/Assets/PerfectWorld/Scripts/Task/TaskClient.cs @@ -356,14 +356,14 @@ namespace BrewMonster.Scripts.Task else if (pNotify.reason == TaskTemplConstants.TASK_SVR_NOTIFY_DYN_TIME_MARK) { // TODO: svr_task_dyn_time_mark struct not defined; need to define or use alternative - // if (sz != Marshal.SizeOf()) return; + if (sz != Marshal.SizeOf()) return; // TODO: OnDynTasksTimeMark method not found in ATaskTemplMan; implement if needed - // ATaskTemplMan pMan = GetTaskTemplMan(pTask); - // if (pMan != null) - // { - // svr_task_dyn_time_mark dynMark = Marshal.PtrToStructure(handle.AddrOfPinnedObject()); - // pMan.OnDynTasksTimeMark(pTask, dynMark.time_mark, dynMark.version); - // } + ATaskTemplMan pMan = GetTaskTemplMan(); + if (pMan != null) + { + svr_task_dyn_time_mark dynMark = GPDataTypeHelper.FromBytes(pBuf); + pMan.OnDynTasksTimeMark(pTask, dynMark.time_mark, dynMark.version); + } return; } // Handle dynamic task data notification diff --git a/Assets/PerfectWorld/Scripts/Task/TaskTempl.Struct.cs b/Assets/PerfectWorld/Scripts/Task/TaskTempl.Struct.cs index 8ae2907f7d..483bc4b218 100644 --- a/Assets/PerfectWorld/Scripts/Task/TaskTempl.Struct.cs +++ b/Assets/PerfectWorld/Scripts/Task/TaskTempl.Struct.cs @@ -597,5 +597,17 @@ namespace BrewMonster.Scripts.Task m_Buf = new byte[TaskInterfaceConstants.TASK_FINISHED_LIST_BUF_SIZE]; Array.Copy(data, m_Buf, TaskInterfaceConstants.TASK_FINISHED_LIST_BUF_SIZE_OLD); } + + + }; + + [ StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct svr_task_dyn_time_mark + { + public task_notify_base baseObj; + public uint time_mark; + public ushort version; + + } } \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/Task/TaskTempl.cs b/Assets/PerfectWorld/Scripts/Task/TaskTempl.cs index 23320eb30f..c2c56a698d 100644 --- a/Assets/PerfectWorld/Scripts/Task/TaskTempl.cs +++ b/Assets/PerfectWorld/Scripts/Task/TaskTempl.cs @@ -1419,19 +1419,20 @@ namespace BrewMonster.Scripts.Task /* ÈÎÎñ½áÊøºóµÄ½±Àø */ - uint m_ulAwardType_S; - uint m_ulAwardType_F; + uint m_ulAwardType_S => m_FixedData.m_ulAwardType_S; + uint m_ulAwardType_F => m_FixedData.m_ulAwardType_F; // ʱ¼äÏÞÖÆ - uint m_ulTimeLimit; + uint m_ulTimeLimit => m_FixedData.m_ulTimeLimit; + /* ÆÕͨºÍ°´Ã¿¸ö·½Ê½ */ - AWARD_DATA m_Award_S = new AWARD_DATA(); /* ³É¹¦ */ - AWARD_DATA m_Award_F = new AWARD_DATA(); /* ʧ°Ü */ + AWARD_DATA m_Award_S => m_FixedData.m_Award_S; /* ³É¹¦ */ + AWARD_DATA m_Award_F => m_FixedData.m_Award_F; /* ʧ°Ü */ /* ʱ¼ä±ÈÀý·½Ê½ */ - AWARD_RATIO_SCALE m_AwByRatio_S; - AWARD_RATIO_SCALE m_AwByRatio_F; + AWARD_RATIO_SCALE m_AwByRatio_S => m_FixedData.m_AwByRatio_S; + AWARD_RATIO_SCALE m_AwByRatio_F => m_FixedData.m_AwByRatio_F; /* °´»ñµÃÎï±ÈÀý·½Ê½ */ - AWARD_ITEMS_SCALE m_AwByItems_S; - AWARD_ITEMS_SCALE m_AwByItems_F; + AWARD_ITEMS_SCALE m_AwByItems_S => m_FixedData.m_AwByItems_S; + AWARD_ITEMS_SCALE m_AwByItems_F => m_FixedData.m_AwByItems_F; uint g_ulNewCount = 0; @@ -4776,7 +4777,7 @@ namespace BrewMonster.Scripts.Task // 0: time limit if (((1 << token_count++) & token_mask1) != 0) { - m_ulTimeLimit = GPDataTypeHelper.FromBytes(pData, ref p); + m_FixedData.m_ulTimeLimit = GPDataTypeHelper.FromBytes(pData, ref p); } // 1: reputation diff --git a/Assets/PerfectWorld/Scripts/Task/TaskTest.cs b/Assets/PerfectWorld/Scripts/Task/TaskTest.cs index 429e68496a..b10a8dc566 100644 --- a/Assets/PerfectWorld/Scripts/Task/TaskTest.cs +++ b/Assets/PerfectWorld/Scripts/Task/TaskTest.cs @@ -4,6 +4,8 @@ using System.IO; using System.Reflection; using System.Runtime.InteropServices; using BrewMonster.Scripts.Task.UI; +using BrewMonster.Scripts.UI; +using BrewMonster.UI; using CSNetwork.Common; using ModelRenderer.Scripts.Common; using PerfectWorld.Scripts.Task; @@ -17,6 +19,10 @@ namespace BrewMonster.Scripts.Task public GameObject m_pTaskDlg; public static ATaskTemplMan m_pTaskMan; // use static to store loaded data across instances public bool WasLoadTaskData = false; + + [Header("Test Dlg Award Options")] + [SerializeField] private uint _awardItemID = 1001; + [SerializeField] private KeyCode _awardkey = KeyCode.A; private void OnValidate() { @@ -30,6 +36,21 @@ namespace BrewMonster.Scripts.Task { m_pTaskDlg.SetActive(!m_pTaskDlg.activeInHierarchy); } + + if (Input.GetKeyDown(_awardkey)) + { + var pShow1 = CECUIManager.Instance.GetInGameUIMan().GetDialog("Win_Award"); + CDlgAward pAward = (pShow1) as CDlgAward; + if (pAward && !pAward.gameObject.activeInHierarchy) + { + pAward.UpdateAwardItem((ushort)_awardItemID, true); + pAward.Show(true); + } + else + { + pAward.Show(false); + } + } #endif } diff --git a/Assets/PerfectWorld/Scripts/UI/Dialogs/AUIDialog.cs b/Assets/PerfectWorld/Scripts/UI/Dialogs/AUIDialog.cs index 186994bfbb..014e50b7a8 100644 --- a/Assets/PerfectWorld/Scripts/UI/Dialogs/AUIDialog.cs +++ b/Assets/PerfectWorld/Scripts/UI/Dialogs/AUIDialog.cs @@ -99,5 +99,6 @@ namespace BrewMonster.UI { } + } } diff --git a/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs b/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs index bf41c0f1f2..ee6feccc66 100644 --- a/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs +++ b/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs @@ -3374,6 +3374,7 @@ namespace BrewMonster.UI CECTaskInterface pTask = GetHostPlayer().GetTaskInterface(); pTask.GetAwardCandidates(opt.param, ref ad); + if (ad.m_ulCandItems > 1) { pShow1 = m_pAUIManager.GetDialog("Win_Award"); diff --git a/Assets/PerfectWorld/Scripts/UI/DlgAward/AwardItem.cs b/Assets/PerfectWorld/Scripts/UI/DlgAward/AwardItem.cs index 871742e81c..6754b86008 100644 --- a/Assets/PerfectWorld/Scripts/UI/DlgAward/AwardItem.cs +++ b/Assets/PerfectWorld/Scripts/UI/DlgAward/AwardItem.cs @@ -48,5 +48,6 @@ namespace BrewMonster.Scripts.UI { gameObject.SetActive(show); } + } } \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/UI/DlgAward/CDlgAward.cs b/Assets/PerfectWorld/Scripts/UI/DlgAward/CDlgAward.cs index 2cf20ea2c5..1e3bfcf743 100644 --- a/Assets/PerfectWorld/Scripts/UI/DlgAward/CDlgAward.cs +++ b/Assets/PerfectWorld/Scripts/UI/DlgAward/CDlgAward.cs @@ -1,3 +1,5 @@ +using System; +using BrewMonster.Network; using BrewMonster.Scripts.Managers; using BrewMonster.Scripts.Task; using BrewMonster.UI; @@ -17,6 +19,7 @@ namespace BrewMonster.Scripts.UI [SerializeField] private Button m_pBtn_Confirm; [SerializeField] private Vector2Int _itemSize = new Vector2Int(50, 50); [SerializeField] private AwardItem _awardItemPrefab; + [SerializeField] private Transform _itemsParent; [SerializeField] private Toggle[] _radioButtons; [Header("DEBUG")] @@ -35,20 +38,34 @@ namespace BrewMonster.Scripts.UI void Awake() { SpawnItems(); + InitRadioBtns(); + + m_pBtn_Confirm.onClick.AddListener(OnCommand_confirm); } + private void InitRadioBtns() + { + for (int i = 0; i < _radioButtons.Length; i++) + { + _radioButtons[i].isOn = false; + _radioButtons[i].onValueChanged.AddListener( OnCommand_select ); + } + + } + private void SpawnItems() { for (int i = 1; i <= _rowCount; i++) { for (int j = 1; j <= _columnCount; j++) { - AwardItem item = Instantiate(_awardItemPrefab, this.transform); + AwardItem item = Instantiate(_awardItemPrefab ,_itemsParent); item.SetPositionIndex(i, j); // Positioning logic can be added here } } - + _awardItems = new AwardItem[_rowCount]; + _awardItems = GetComponentsInChildren(); _awardItemPrefab.gameObject.SetActive(false); } @@ -82,10 +99,10 @@ namespace BrewMonster.Scripts.UI AwardItem pImage; // Using AwardItem instead of Image SetData(idTask, ""); - // CheckRadioButton(1, 0); // TODO: - // GetDlgItem("Btn_Confirm")->Enable(false); + // CheckRadioButton(1, 0); // TODO: maybe dont need this + m_pBtn_Confirm.gameObject.SetActive(false); - for (int i=1; i < _rowCount; i++) + for (int i=1; i <= _rowCount; i++) { // sprintf(out szName, "Item_%02d01", i); // pImage = (PAUIIMAGEPICTURE)GetDlgItem(szName); @@ -94,8 +111,9 @@ namespace BrewMonster.Scripts.UI // TODO: Show/Hide radio button // sprintf(out szName, "Rdo_Award%d", i); // GetDlgItem(szName)->Show(false); - _radioButtons[i].gameObject.SetActive(false); - + // _radioButtons[i-1].gameObject.SetActive(false); + GetToggleBtnAt(i).gameObject.SetActive(false); + // for (j = 1;; j++) for (int j=1; j < _columnCount; j++) { @@ -128,19 +146,21 @@ namespace BrewMonster.Scripts.UI // TODO: Set the image cover here // pImage.SetCover(GetGameUIMan().m_pA2DSpriteIcons[CECGameUIMan::ICONS_INVENTORY], // GetGameUIMan().m_IconMap[CECGameUIMan::ICONS_INVENTORY][strFile]); - - EC_IvtrEquip pEquip = new EC_IvtrEquip(pItem.m_tid, pItem.m_expire_date); - pImage.SetColor( - (pItem.IsEquipment() && pEquip.IsDestroying()) - ? new Color32(128, 128, 128, 255) - : new Color32(255, 255, 255, 255)); + var sprite = EC_IvtrItemUtils.Instance.ResolveItemIconSprite(pItem.m_tid); + pImage.SetImage(sprite); + + EC_IvtrEquip pEquip = new EC_IvtrEquip(pItem.m_tid, pItem.m_expire_date); + pImage.SetColor( + (pItem.IsEquipment() && pEquip.IsDestroying()) + ? new Color32(128, 128, 128, 255) + : new Color32(255, 255, 255, 255)); // delete pItem; pItem = null; // sprintf(out szName, "Rdo_Award%d", i); // GetDlgItem(szName)->Show(true); - _radioButtons[i].gameObject.SetActive(true); + GetToggleBtnAt(i).gameObject.SetActive(true); } else { @@ -166,7 +186,7 @@ namespace BrewMonster.Scripts.UI // sprintf(out szName, "Rdo_Award%d", i); // GetDlgItem(szName)->Show(false); - _radioButtons[i].gameObject.SetActive(false); + GetToggleBtnAt(i).gameObject.SetActive(false); for (int j = 1; j < _columnCount; j++) { @@ -209,7 +229,7 @@ namespace BrewMonster.Scripts.UI { // sprintf(out szName, "Rdo_Award%d", i); // GetDlgItem(szName)->Show(true); - _radioButtons[i].gameObject.SetActive(true); + GetToggleBtnAt(i).gameObject.SetActive(true); } for (int j = 1; j < _columnCount; j++) @@ -299,6 +319,57 @@ namespace BrewMonster.Scripts.UI } return null; } + + Toggle GetToggleBtnAt(int row) + { + int index = row - 1; + if( index < 0 || index >= _radioButtons.Length) + return null; + return _radioButtons[index]; + } + + void OnCommand_select(bool toggleValue) + { + if(toggleValue) m_pBtn_Confirm.gameObject.SetActive(true); + } + + void OnCommand_confirm() + { + // int i; + string szName; + Toggle pRadio; + uint idTask = GetData(); + + for( int i = 1; i < _rowCount ; i++ ) + { + // sprintf(szName, "Rdo_Award%d", i); + // pRadio = (PAUIRADIOBUTTON)GetDlgItem(szName); + // if( !pRadio || !pRadio->IsShow() ) break; + pRadio = GetToggleBtnAt(i); + if(!pRadio || !pRadio.gameObject.activeInHierarchy) return; + + // if( pRadio.IsChecked() ) + if( pRadio.isOn ) + { + if (m_bThroughNPC) { + // GetGameSession().c2s_CmdNPCSevReturnTask(idTask, i - 1); + UnityGameSession.c2s_CmdNPCSevReturnTask((int)idTask, i - 1); + GetGameUIMan().EndNPCService(); + } else if (m_bSpendContribution) { + // TODO: Implement spend contribution logic + // CECTaskInterface pTask = GetHostPlayer().GetTaskInterface(); + // pTask.FinishTaskSpendingWorldContribution(idTask, i - 1); + } else { + // TODO: Implement choose award logic + // CECTaskInterface pTask = GetHostPlayer().GetTaskInterface(); + // pTask.ChooseAward(idTask, i - 1); + } + Show(false); + break; + } + } + } + } } \ No newline at end of file diff --git a/Assets/PerfectWorld/UI/Award/DlgAward.prefab b/Assets/PerfectWorld/UI/Award/DlgAward.prefab index 6286daa5d3..3a24f98a6b 100644 --- a/Assets/PerfectWorld/UI/Award/DlgAward.prefab +++ b/Assets/PerfectWorld/UI/Award/DlgAward.prefab @@ -80,7 +80,7 @@ MonoBehaviour: m_TargetGraphic: {fileID: 4376062802034248599} toggleTransition: 1 graphic: {fileID: 2531169264107607804} - m_Group: {fileID: 0} + m_Group: {fileID: 8788665475006443126} onValueChanged: m_PersistentCalls: m_Calls: [] @@ -421,8 +421,9 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_pBtn_Confirm: {fileID: 2022223185403607436} - _itemSize: {x: 6, y: 10} + _itemSize: {x: 6, y: 6} _awardItemPrefab: {fileID: 421596072721705907} + _itemsParent: {fileID: 1558872982091896349} _radioButtons: - {fileID: 2958213901730883256} - {fileID: 733246749774266009} @@ -511,7 +512,7 @@ MonoBehaviour: m_TargetGraphic: {fileID: 3354338157638316856} toggleTransition: 1 graphic: {fileID: 6225229690304520632} - m_Group: {fileID: 0} + m_Group: {fileID: 8788665475006443126} onValueChanged: m_PersistentCalls: m_Calls: [] @@ -1017,7 +1018,7 @@ MonoBehaviour: m_CellSize: {x: 100, y: 100} m_Spacing: {x: 10, y: 10} m_Constraint: 1 - m_ConstraintCount: 10 + m_ConstraintCount: 6 --- !u!1 &3565430854526106865 GameObject: m_ObjectHideFlags: 0 @@ -1098,7 +1099,7 @@ MonoBehaviour: m_TargetGraphic: {fileID: 5045479894881455806} toggleTransition: 1 graphic: {fileID: 7207637042536033371} - m_Group: {fileID: 0} + m_Group: {fileID: 8788665475006443126} onValueChanged: m_PersistentCalls: m_Calls: [] @@ -1183,7 +1184,7 @@ MonoBehaviour: m_TargetGraphic: {fileID: 6245175927925089128} toggleTransition: 1 graphic: {fileID: 126544343920740120} - m_Group: {fileID: 0} + m_Group: {fileID: 8788665475006443126} onValueChanged: m_PersistentCalls: m_Calls: [] @@ -1240,7 +1241,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 9d87c7b8ac564f919171a5173812980e, type: 3} m_Name: m_EditorClassIdentifier: - img: {fileID: 0} + img: {fileID: 5798109676702798723} btn: {fileID: 5829300517807457460} --- !u!222 &1897581106405175503 CanvasRenderer: @@ -1410,6 +1411,7 @@ GameObject: m_Component: - component: {fileID: 2450815123296561302} - component: {fileID: 1430101278767489564} + - component: {fileID: 8788665475006443126} m_Layer: 5 m_Name: RadioBtnGroup m_TagString: Untagged @@ -1468,6 +1470,19 @@ MonoBehaviour: m_ChildScaleWidth: 0 m_ChildScaleHeight: 0 m_ReverseArrangement: 0 +--- !u!114 &8788665475006443126 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4660714409237943125} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2fafe2cfe61f6974895a912c3755e8f1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_AllowSwitchOff: 0 --- !u!1 &5325640235670539457 GameObject: m_ObjectHideFlags: 0 @@ -2001,7 +2016,7 @@ MonoBehaviour: m_TargetGraphic: {fileID: 4503678912350313887} toggleTransition: 1 graphic: {fileID: 7848180479837842084} - m_Group: {fileID: 0} + m_Group: {fileID: 8788665475006443126} onValueChanged: m_PersistentCalls: m_Calls: [] @@ -2162,7 +2177,7 @@ MonoBehaviour: m_TargetGraphic: {fileID: 5687745320305579942} toggleTransition: 1 graphic: {fileID: 6219347094978315234} - m_Group: {fileID: 0} + m_Group: {fileID: 8788665475006443126} onValueChanged: m_PersistentCalls: m_Calls: [] diff --git a/Assets/Scripts/CECHostPlayer.cs b/Assets/Scripts/CECHostPlayer.cs index 01da1934b8..0a5721e60c 100644 --- a/Assets/Scripts/CECHostPlayer.cs +++ b/Assets/Scripts/CECHostPlayer.cs @@ -714,6 +714,10 @@ namespace BrewMonster { var data = Msg.dwParam1 as byte[]; int cmd = Convert.ToInt32(Msg.dwParam2); + + bool bDoOther = false; + int idItem, iExpireDate=0, iAmount, iCmdLastSlot, iCmdSlotAmount, iPack, iMsg=-1; + switch (cmd) { case CommandID.HOST_OBTAIN_ITEM: @@ -755,61 +759,105 @@ namespace BrewMonster } break; case CommandID.PICKUP_ITEM: - { - int tid = BitConverter.ToInt32(data, 0); - int expire_date = BitConverter.ToInt32(data, 4); - uint iAmount = BitConverter.ToUInt32(data, 8); - uint iSlotAmount = BitConverter.ToUInt32(data, 12); - byte byPackage = data[16]; - byte bySlot = data[17]; + { + int tid = BitConverter.ToInt32(data, 0); + int expire_date = BitConverter.ToInt32(data, 4); + iAmount = (int)BitConverter.ToUInt32(data, 8); + uint iSlotAmount = BitConverter.ToUInt32(data, 12); + byte byPackage = data[16]; + byte bySlot = data[17]; + //Debug.Log($"[Inventory] PICKUP_ITEM: tid={tid}, expire_date={expire_date}, iAmount={iAmount}, iSlotAmount={iSlotAmount}, byPackage={byPackage}, bySlot={bySlot}"); + + // Notify pickupItem script about successful pickup + pickupItem pickupScript = pickupItem.Instance; + if (pickupScript != null) + { //Debug.Log($"[Inventory] PICKUP_ITEM: tid={tid}, expire_date={expire_date}, iAmount={iAmount}, iSlotAmount={iSlotAmount}, byPackage={byPackage}, bySlot={bySlot}"); // Notify pickupItem script about successful pickup - pickupItem pickupScript = pickupItem.Instance; + pickupScript = UnityEngine.Object.FindFirstObjectByType(); if (pickupScript != null) { - //Debug.Log($"[Inventory] PICKUP_ITEM: tid={tid}, expire_date={expire_date}, iAmount={iAmount}, iSlotAmount={iSlotAmount}, byPackage={byPackage}, bySlot={bySlot}"); - - // Notify pickupItem script about successful pickup - pickupScript = UnityEngine.Object.FindFirstObjectByType(); - if (pickupScript != null) - { - pickupScript.OnPickupSuccess(tid); - } - - // Create new inventory item data - var newItem = new EC_IvtrItem - { - Package = byPackage, - Slot = bySlot, - m_tid = tid, - m_expire_date = expire_date, - State = 0, - m_iCount = (int)iAmount, - Crc = 0, - Content = null - }; - - // Add item to inventory - var ivt = GetInventory(byPackage); - ivt.SetItem(bySlot, newItem); - - //Debug.Log($"[Inventory] Successfully added item {tid} to package {byPackage}, slot {bySlot} with count {iAmount}"); - - // Trigger UI refresh if an EC_InventoryUI is present in scene - var ui = GameObject.FindFirstObjectByType(); - if (ui != null) - { - ui.RefreshAll(); - } + pickupScript.OnPickupSuccess(tid); } - else + + // Create new inventory item data + var newItem = new EC_IvtrItem { - Debug.LogWarning("[Inventory] PICKUP_ITEM: Invalid data length"); + Package = byPackage, + Slot = bySlot, + m_tid = tid, + m_expire_date = expire_date, + State = 0, + m_iCount = (int)iAmount, + Crc = 0, + Content = null + }; + + // Add item to inventory + var ivt = GetInventory(byPackage); + ivt.SetItem(bySlot, newItem); + + //Debug.Log($"[Inventory] Successfully added item {tid} to package {byPackage}, slot {bySlot} with count {iAmount}"); + + // Trigger UI refresh if an EC_InventoryUI is present in scene + var ui = GameObject.FindFirstObjectByType(); + if (ui != null) + { + ui.RefreshAll(); } - break; } + else + { + Debug.LogWarning("[Inventory] PICKUP_ITEM: Invalid data length"); + } + break; + } + case CommandID.TASK_DELIVER_ITEM: + cmd_task_deliver_item pCmd = GPDataTypeHelper.FromBytes(data); + // ASSERT(pCmd); + + idItem = pCmd.type; + iExpireDate = pCmd.expire_date; + iAmount = (int)pCmd.amount; + iCmdLastSlot = pCmd.index; + iCmdSlotAmount = (int)pCmd.slot_amount; + iPack = pCmd.where; + iMsg = (int)FixedMsg.FIXMSG_GAINITEM; + bDoOther = true; + + + // Create new inventory item data + var taskNewItem = new EC_IvtrItem + { + Package = (byte)iPack, + Slot = iCmdLastSlot, + m_tid = idItem, + m_expire_date = iExpireDate, + State = 0, + m_iCount = (int)iAmount, + Crc = 0, + Content = null + }; + + // Add item to inventory + var task_ivt = GetInventory((byte)iPack); + task_ivt.SetItem(iCmdLastSlot, taskNewItem); + + //Debug.Log($"[Inventory] Successfully added item {tid} to package {byPackage}, slot {bySlot} with count {iAmount}"); + + // Trigger UI refresh if an EC_InventoryUI is present in scene + var task_ui = GameObject.FindFirstObjectByType(); + if (task_ui != null) + { + task_ui.RefreshAll(); + } + break; + + + // TODO: Handle other pickup item commands if necessary + } } public void OnMsgHstItemOperation(ECMSG Msg)