159 lines
6.5 KiB
C#
159 lines
6.5 KiB
C#
using System.Collections.Generic;
|
|
using System.Runtime.InteropServices;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
|
|
namespace BrewMonster.PerfectWorld.Scripts.Task.UI
|
|
{
|
|
|
|
/// <summary>
|
|
/// This is DlgTask.cpp
|
|
/// </summary>
|
|
public class TaskWindow : MonoBehaviour
|
|
{
|
|
// Keep original macro as constant for array sizing
|
|
public const int CDLGTASK_AWARDITEM_MAX = 8;
|
|
|
|
// ===== Nested structs (converted from C++), keep naming, public with explicit layout =====
|
|
|
|
// [中文] 任务目标位置
|
|
// [English] Task object position
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
public struct TASK_OBJECT_POS
|
|
{
|
|
public int x;
|
|
public int y;
|
|
public int z;
|
|
public int mapid;
|
|
}
|
|
|
|
// [中文] 任务完成时间
|
|
// [English] Task finished time
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
public struct TASK_FINISHED_TIME
|
|
{
|
|
public int iTaskID;
|
|
public uint dwTime; // DWORD -> uint
|
|
}
|
|
|
|
// [中文] ������������
|
|
// [English] Type grouping node
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
public struct TypeNode
|
|
{
|
|
public uint type; // DWORD -> uint
|
|
public GameObject item; // P_AUITREEVIEW_ITEM -> GameObject
|
|
}
|
|
|
|
// [中文] ��������ȼ�����
|
|
// [English] Level priority node
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
public struct LevelNode
|
|
{
|
|
public int level;
|
|
public GameObject item; // P_AUITREEVIEW_ITEM -> GameObject
|
|
}
|
|
|
|
// ===== Converted member variables (keep original naming) =====
|
|
|
|
// protected:
|
|
protected int m_idLastTask;
|
|
protected int m_idSelTask;
|
|
|
|
protected bool m_bTraceNew;
|
|
protected bool m_bShowTrace;
|
|
|
|
protected int m_iType;
|
|
|
|
[SerializeField] protected TMP_Text m_pTxt_QuestNO; // PAUILABEL -> TMP_Text
|
|
[SerializeField] protected GameObject m_pTv_Quest; // PAUITREEVIEW -> GameObject container
|
|
[SerializeField] protected TMP_Text m_pTxt_Content; // PAUITEXTAREA -> TMP_Text
|
|
[SerializeField] protected TMP_Text m_pTxt_QuestItem; // PAUITEXTAREA -> TMP_Text
|
|
[SerializeField] protected Button m_pBtn_Abandon; // PAUISTILLIMAGEBUTTON -> Button
|
|
[SerializeField] protected Button m_pBtn_MainQuest; // PAUISTILLIMAGEBUTTON -> Button
|
|
[SerializeField] protected Button m_pBtn_NormalQuest; // PAUISTILLIMAGEBUTTON -> Button
|
|
[SerializeField] protected Button m_pBtn_SearchQuest; // PAUISTILLIMAGEBUTTON -> Button
|
|
[SerializeField] protected Button m_pBtn_HaveQuest; // PAUISTILLIMAGEBUTTON -> Button
|
|
[SerializeField] protected Button m_pBtn_bShowTrace; // PAUISTILLIMAGEBUTTON -> Button
|
|
[SerializeField] protected Button m_pBtn_FinishTask; // PAUISTILLIMAGEBUTTON -> Button
|
|
[SerializeField] protected TMP_Text m_pTxt_BaseAward; // PAUILABEL -> TMP_Text
|
|
|
|
// PAUIIMAGEPICTURE m_pImg_Item[CDLGTASK_AWARDITEM_MAX];
|
|
// Use fixed-size array semantics via initialization length
|
|
// [中文] 奖励物品图片数组
|
|
// [English] Award item images array
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = CDLGTASK_AWARDITEM_MAX)]
|
|
[SerializeField] protected Image[] m_pImg_Item = new Image[CDLGTASK_AWARDITEM_MAX];
|
|
protected uint m_ImgCount; // unsigned int -> uint
|
|
|
|
[SerializeField] protected Button m_pBtn_GotoNPC; // PAUISTILLIMAGEBUTTON -> Button
|
|
[SerializeField] protected GameObject m_pQuickBuyTrigger; // CECQuickBuyPopActivityTrigger* -> GameObject
|
|
|
|
// private:
|
|
private static List<int> m_vecTasksUnFinish = new List<int>();
|
|
private static List<int> m_vecTasksCanFinish = new List<int>();
|
|
|
|
// [中文] 目标坐标集合
|
|
// [English] Target coordinates collection
|
|
private static List<Vector3> m_TargetCoord = new List<Vector3>();
|
|
|
|
private static string m_strTraceName = string.Empty; // ACString -> string
|
|
|
|
// [中文] 任务相关矿点映射
|
|
// [English] Mine map related to tasks
|
|
private static Dictionary<int, object> m_TaskMines = new Dictionary<int, object>(); // MINE_ESSENCE* -> object
|
|
|
|
// [中文] 任务跟踪计时器
|
|
// [English] Task trace counter
|
|
private CECCounter m_TaskTraceCounter; // CECCounter -> object placeholder
|
|
|
|
|
|
private bool OnInitDialog()
|
|
{
|
|
// m_pTxt_QuestNO = (PAUILABEL)GetDlgItem("Txt_QuestNO");
|
|
// m_pTv_Quest = (PAUITREEVIEW)GetDlgItem("Tv_Quest");
|
|
// m_pTxt_Content = dynamic_cast<PAUITEXTAREA>(GetDlgItem("Txt_Content"));
|
|
// m_pTxt_QuestItem = dynamic_cast<PAUITEXTAREA>(GetDlgItem("Txt_QuestItem"));
|
|
// m_pBtn_Abandon = (PAUISTILLIMAGEBUTTON)GetDlgItem("Btn_Abandon");
|
|
// m_pTxt_BaseAward = (PAUILABEL)GetDlgItem("Txt_BaseAward");
|
|
// m_pBtn_SearchQuest = (PAUISTILLIMAGEBUTTON)GetDlgItem("Btn_SearchQuest");
|
|
// m_pBtn_HaveQuest = (PAUISTILLIMAGEBUTTON)GetDlgItem("Btn_HaveQuest");
|
|
// m_pBtn_bShowTrace = (PAUISTILLIMAGEBUTTON)GetDlgItem("Btn_ShowTrace");
|
|
// m_pBtn_FinishTask = (PAUISTILLIMAGEBUTTON)GetDlgItem("Btn_FinishTask");
|
|
// m_pBtn_GotoNPC = (PAUISTILLIMAGEBUTTON)GetDlgItem("Btn_GotoNPC");
|
|
if (m_pBtn_FinishTask) m_pBtn_FinishTask.gameObject.SetActive(false);
|
|
if (m_pBtn_GotoNPC) m_pBtn_GotoNPC.gameObject.SetActive(false);
|
|
|
|
// TODO: Set button pushed state
|
|
// if (m_pBtn_HaveQuest != null) { /* set pushed state if needed */ }
|
|
|
|
GameObject pObj = GetDlgItem<GameObject>("Btn_TreasureMap");
|
|
if (pObj != null)
|
|
{
|
|
pObj.SetActive(false);
|
|
}
|
|
|
|
pObj = GetDlgItem<GameObject>("Img_New");
|
|
if (pObj != null)
|
|
{
|
|
pObj.SetActive(false);
|
|
}
|
|
|
|
if (m_pTxt_QuestNO != null)
|
|
{
|
|
m_pTxt_QuestNO.text = "0";
|
|
}
|
|
|
|
m_TaskTraceCounter.SetPeriod(950);
|
|
return true;
|
|
}
|
|
|
|
private T GetDlgItem<T>(string name)
|
|
{
|
|
var t = transform.Find(name);
|
|
if (t != null) return t.GetComponent<T>();
|
|
return default(T);
|
|
}
|
|
}
|
|
} |