Files
test/Assets/PerfectWorld/Scripts/UI/GamePlay/EC_GameUIMan.cs
T
2026-01-29 17:42:34 +07:00

184 lines
6.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using BrewMonster.Assets.PerfectWorld.Scripts.UI.GamePlay;
using BrewMonster.Common;
using BrewMonster.Managers;
using BrewMonster.Network;
using BrewMonster.Scripts.Task;
using BrewMonster.Scripts.Task.UI;
using BrewMonster.Scripts.UI;
using ModelRenderer.Scripts.Common;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
namespace BrewMonster.UI
{
public class CECGameUIMan : AUIManager
{
DlgNPC m_pDlgNPC;
public NPC_ESSENCE? m_pCurNPCEssence;
public int m_idCurFinishTask = -1;
private DlgTask m_pDlgTask;
private Dictionary<byte, (string, Sprite[])> m_IconMap;
private const string SKILL_ICONLIST_NAME = "iconlist_skill_multisprite";
public static bool TALKPROC_IS_TERMINAL(uint id)
{
return ((id & 0x80000000u) != 0) && ((id & 0x40000000u) != 0);
}
public static bool TALKPROC_IS_FUNCTION(uint id)
{
return ((id) & 0x80000000) != 0;
}
public static uint TALKPROC_GET_FUNCTION_ID(uint id)
{
return ((id) & 0x7FFFFFFF);
}
public void PopupNPCDialog(NPC_ESSENCE pEssence)
{
if (m_pDlgNPC == null)
{
GameObject ob = m_dialogResouce.GetPrefabDialog("DialogNPC");
m_pDlgNPC = GameObject.Instantiate(ob, m_canvas.transform).GetComponent<DlgNPC>();
m_pDlgNPC.SetAUIManager(this);
}
m_pDlgNPC.PopupDialog(pEssence);
}
public void PopupNPCDialog(talk_proc pTalk)
{
if (m_pDlgNPC == null)
{
GameObject ob = m_dialogResouce.GetPrefabDialog("DialogNPC");
m_pDlgNPC = GameObject.Instantiate(ob, m_canvas.transform).GetComponent<DlgNPC>();
m_pDlgNPC.SetAUIManager(this);
}
m_pDlgNPC.PopupNPCDialog(pTalk);
}
// 弹出任务完成对话框(到达/离开地点等触发) // Popup task-finish dialog (reach/leave site, etc.)
// C++: pTask->PopupTaskFinishDialog(taskId, &awardTalk); then OnUIDialogEnd() notifies server.
public bool PopupTaskFinishDialog(uint taskId, talk_proc pTalk)
{
if (pTalk.num_window == 0) return false;
if (m_pDlgNPC == null)
{
GameObject ob = m_dialogResouce.GetPrefabDialog("DialogNPC");
m_pDlgNPC = GameObject.Instantiate(ob, m_canvas.transform).GetComponent<DlgNPC>();
m_pDlgNPC.SetAUIManager(this);
}
m_idCurFinishTask = (int)taskId;
m_pDlgNPC.PopupNPCDialog(pTalk);
m_pDlgNPC.SetData(DlgNPC.NPC_DIALOG.NPC_DIALOG_TASK_TALK, "");
return true;
}
public void EndNPCService()
{
m_pCurNPCEssence = null;
//EC_Game.GetGameRun().GetHostPlayer().EndNPCService();
EC_ManMessageMono.Instance.EC_ManPlayer.GetHostPlayer().EndNPCService();
}
public bool UpdateTask(uint idTask, int reason)
{
Debug.Log($"[EC_GameUIMan] UpdateTask: idTask={idTask}, reason={reason}");
DlgTaskTrace pDlg = GetDialog("Win_QuestMinion").GetComponent<DlgTaskTrace>();
if (pDlg) {
//pDlg->SetBtnUnTraceY(-1, 0);
pDlg.UpdateContributionTask();
if (reason == TaskTemplConstants.TASK_SVR_NOTIFY_NEW)
pDlg.OnTaskNew(idTask);
}
// TODO
// ´
// if (reason == TaskTemplConstants.TASK_SVR_NOTIFY_NEW)
// {
// m_pDlgQuestionTask.AddQuestionTask(idTask);
// }
// else if (reason == TaskTemplConstants.TASK_SVR_NOTIFY_COMPLETE || reason == TaskTemplConstants.TASK_SVR_NOTIFY_GIVE_UP)
// {
// m_pDlgQuestionTask.RemoveQuestionTask(idTask);
// }
if (reason == TaskTemplConstants.TASK_SVR_NOTIFY_STORAGE)
{
// TODO
// CDlgTaskList* pDlg = (CDlgTaskList*)GetDialog("Win_QuestList");
// if (pDlg && pDlg.IsShow())
// {
// // refresh data in OnShow()
// pDlg.RefreshTaskList();
// }
return true;
}
else
{
// zhangyitian 20140521
// ʱɽбҲҪ£˿ɽбµ
return m_pDlgTask.UpdateQuestView();
}
}
public DialogScriptTableObject GetDialogResource()
{
return m_dialogResouce;
}
public Canvas GetCanvas()
{
return m_canvas;
}
public void EnableUI(bool bEnable)
{
}
public override void Init()
{
base.Init();
m_IconMap = new Dictionary<byte, (string, Sprite[])>();
m_pDlgTask = GetDialog(CECUIHelper.DlgTaskName).GetComponent<DlgTask>();
m_pDlgTask.Show(false);
m_IconMap[(byte)EC_GAMEUI_ICONS.ICONS_SKILL] =("iconlist_skill_multisprite", Resources.LoadAll<Sprite>("iconlist_skill_multisprite"));
}
public void SetCover(AUIImagePicture pImgPic, string nameImage, EC_GAMEUI_ICONS iCONS_SKILL)
{
pImgPic.SetImage(m_IconMap[(byte)iCONS_SKILL].Item2.FirstOrDefault(s => s.name == nameImage));
}
public string GetRealmName(int realmLevel)
{
string strRealm = string.Empty;
if (realmLevel > 0){
int layer = CECHostPlayer.GetRealmLayer(realmLevel);
int subLevel = CECHostPlayer.GetRealmSubLevel(realmLevel);
strRealm = string.Format(GetStringFromTable(11100), GetStringFromTable(11100+layer), GetStringFromTable(11120+subLevel));
}
return strRealm;
}
}
public enum EC_GAMEUI_ICONS : byte
{
ICONS_ACTION = 0,
ICONS_SKILL,
ICONS_INVENTORY,
ICONS_STATE,
ICONS_SKILLGRP,
ICONS_GUILD,
ICONS_PET,
ICONS_ELF,
ICONS_SUITE,
ICONS_CALENDAR,
ICONS_PQ,
ICONS_MAX
};
}