feat: add manager dialog npc.
This commit is contained in:
+126
-61
@@ -5,23 +5,15 @@ using BrewMonster.Scripts;
|
||||
using BrewMonster.Scripts.Managers;
|
||||
using BrewMonster.Scripts.Player;
|
||||
using CSNetwork;
|
||||
using CSNetwork.Common;
|
||||
using CSNetwork.GPDataType;
|
||||
using CSNetwork.Protocols;
|
||||
using CSNetwork.Protocols.RPCData;
|
||||
using NUnit.Framework;
|
||||
using PerfectWorld.Scripts.Managers;
|
||||
using PerfectWorld.Scripts.Managers.BrewMonster.Managers;
|
||||
using PerfectWorld.Scripts.Player;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using TMPro;
|
||||
using UnityEditor.Experimental.GraphView;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
using Scene = UnityEngine.SceneManagement.Scene;
|
||||
@@ -65,6 +57,9 @@ public class CECHostPlayer : CECPlayer
|
||||
public GNDINFO m_GndInfo;
|
||||
int m_idUCSelTarget; // Uncertificately selected object's ID
|
||||
public float m_fVertSpeed = 0f;
|
||||
int m_idSevNPC = 0; // Current service NPC
|
||||
bool m_bTalkWithNPC = false; // true, is talking with NPC
|
||||
List<ushort> m_aWayPoints = new List<ushort>(); // Active way points
|
||||
|
||||
// ====== Ground cast config ======
|
||||
[Header("Ground Cast")]
|
||||
@@ -394,6 +389,7 @@ public class CECHostPlayer : CECPlayer
|
||||
case int value when value == EC_MsgDef.MSG_HST_HURTRESULT: OnMsgHstHurtResult(Msg); break;
|
||||
case int value when value == EC_MsgDef.MSG_HST_INFO00: OnMsgHstInfo00(Msg); break;
|
||||
case int value when value == EC_MsgDef.MSG_HST_NPCGREETING: OnMsgHstNPCGreeting(Msg); break;
|
||||
case int value when value == EC_MsgDef.MSG_HST_WAYPOINT: OnMsgHstWayPoint(Msg); break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1796,69 +1792,138 @@ public class CECHostPlayer : CECPlayer
|
||||
{
|
||||
cmd_npc_greeting pCmd = GPDataTypeHelper.FromBytes<cmd_npc_greeting>((byte[])Msg.dwParam1);
|
||||
|
||||
//if (GPDataTypeHelper.ISNPCID(pCmd.idObject))
|
||||
//{
|
||||
// // רÃÅ´¦Àíѧϰ¼¼ÄܵÄÒþ²ØNPC
|
||||
// if (CECHostSkillModel::Instance().IsSkillLearnNPC(pCmd.idObject))
|
||||
// {
|
||||
// CECGameUIMan* pGameUI = g_pGame.GetGameRun().GetUIManager().GetInGameUIMan();
|
||||
// //m_idSevNPC = pCmd.idObject;
|
||||
// //m_bTalkWithNPC = true;
|
||||
// //pGameUI.GetDialog("Win_SkillAction").Show(true);
|
||||
// //CDlgSkillAction* dlg = dynamic_cast<CDlgSkillAction*>(pGameUI.GetDialog("Win_SkillAction"));
|
||||
// //dlg.ForceShowDialog();
|
||||
// CDlgSkillAction* dlg = dynamic_cast<CDlgSkillAction*>(pGameUI.GetDialog("Win_SkillAction"));
|
||||
// dlg.SetReceivedNPCGreeting(true);
|
||||
// return;
|
||||
// }
|
||||
if (GPDataTypeHelper.ISNPCID(pCmd.idObject))
|
||||
{
|
||||
// רÃÅ´¦Àíѧϰ¼¼ÄܵÄÒþ²ØNPC
|
||||
//if (CECHostSkillModel::Instance().IsSkillLearnNPC(pCmd.idObject))
|
||||
//{
|
||||
// CECGameUIMan* pGameUI = g_pGame.GetGameRun().GetUIManager().GetInGameUIMan();
|
||||
// //m_idSevNPC = pCmd.idObject;
|
||||
// //m_bTalkWithNPC = true;
|
||||
// //pGameUI.GetDialog("Win_SkillAction").Show(true);
|
||||
// //CDlgSkillAction* dlg = dynamic_cast<CDlgSkillAction*>(pGameUI.GetDialog("Win_SkillAction"));
|
||||
// //dlg.ForceShowDialog();
|
||||
// CDlgSkillAction* dlg = dynamic_cast<CDlgSkillAction*>(pGameUI.GetDialog("Win_SkillAction"));
|
||||
// dlg.SetReceivedNPCGreeting(true);
|
||||
// return;
|
||||
//}
|
||||
|
||||
// CECNPC* pNPC = g_pGame.GetGameRun().GetWorld().GetNPCMan().GetNPC(pCmd.idObject);
|
||||
// if (!pNPC || !pNPC.IsServerNPC())
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
CECNPC pNPC = EC_ManMessageMono.Instance._CECNPCMan.GetNPC(pCmd.idObject);
|
||||
if (!pNPC || !pNPC.IsServerNPC())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// // Check distance again
|
||||
// if (!CanTouchTarget(pNPC.GetPos(), pNPC.GetTouchRadius(), 3))
|
||||
// return;
|
||||
// Check distance again
|
||||
if (!CanTouchTarget(pNPC.GetPos(), pNPC.GetTouchRadius(), 3))
|
||||
return;
|
||||
|
||||
// m_idSevNPC = pCmd.idObject;
|
||||
// m_bTalkWithNPC = true;
|
||||
m_idSevNPC = pCmd.idObject;
|
||||
m_bTalkWithNPC = true;
|
||||
|
||||
// // Check way point service on NPC
|
||||
// DWORD dwID = ((CECNPCServer*)pNPC).GetWayPointID();
|
||||
// if (dwID && !HasWayPoint((WORD)dwID))
|
||||
// g_pGame.GetGameSession().c2s_CmdNPCSevWaypoint();
|
||||
// Check way point service on NPC
|
||||
var dwID = (pNPC as CECNPCServer).GetWayPointID();
|
||||
if (dwID != null && !HasWayPoint(dwID))
|
||||
UnityGameSession.c2s_CmdNPCSevWaypoint();
|
||||
//g_pGame.GetGameSession().c2s_CmdNPCSevWaypoint();
|
||||
|
||||
// CECGameUIMan* pGameUI = g_pGame.GetGameRun().GetUIManager().GetInGameUIMan();
|
||||
// pGameUI.PopupNPCDialog(((CECNPCServer*)pNPC).GetDBEssence());
|
||||
//}
|
||||
//else if (ISPLAYERID(pCmd.idObject))
|
||||
//{
|
||||
// CECElsePlayer* pPlayer = m_pPlayerMan.GetElsePlayer(pCmd.idObject);
|
||||
CECGameUIMan pGameUI = EC_Game.GetGameRun().GetUIManager().GetInGameUIMan();
|
||||
pGameUI.PopupNPCDialog(((CECNPCServer*)pNPC).GetDBEssence());
|
||||
}
|
||||
else if (GPDataTypeHelper.ISPLAYERID(pCmd.idObject))
|
||||
{
|
||||
CECElsePlayer* pPlayer = m_pPlayerMan.GetElsePlayer(pCmd.idObject);
|
||||
|
||||
// // Check distance again
|
||||
// if (!pPlayer || !CanTouchTarget(pPlayer.GetPos(), 0.0f, 3))
|
||||
// return;
|
||||
// Check distance again
|
||||
if (!pPlayer || !CanTouchTarget(pPlayer.GetPos(), 0.0f, 3))
|
||||
return;
|
||||
|
||||
// m_idSevNPC = pCmd.idObject;
|
||||
// m_bTalkWithNPC = true;
|
||||
// m_iBoothState = 3;
|
||||
m_idSevNPC = pCmd.idObject;
|
||||
m_bTalkWithNPC = true;
|
||||
m_iBoothState = 3;
|
||||
|
||||
// g_pGame.GetGameSession().c2s_CmdNPCSevGetContent(GP_NPCSEV_BOOTHSELL);
|
||||
g_pGame.GetGameSession().c2s_CmdNPCSevGetContent(GP_NPCSEV_BOOTHSELL);
|
||||
|
||||
// m_pBuyPack.RemoveAllItems();
|
||||
// m_pSellPack.RemoveAllItems();
|
||||
// m_pEPBoothBPack.RemoveAllItems();
|
||||
// m_pEPBoothSPack.RemoveAllItems();
|
||||
m_pBuyPack.RemoveAllItems();
|
||||
m_pSellPack.RemoveAllItems();
|
||||
m_pEPBoothBPack.RemoveAllItems();
|
||||
m_pEPBoothSPack.RemoveAllItems();
|
||||
|
||||
// CECGameUIMan* pGameUI = g_pGame.GetGameRun().GetUIManager().GetInGameUIMan();
|
||||
// pGameUI.PopupBoothDialog(true, false, pCmd.idObject);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
CECGameUIMan* pGameUI = g_pGame.GetGameRun().GetUIManager().GetInGameUIMan();
|
||||
pGameUI.PopupBoothDialog(true, false, pCmd.idObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Does host player have specified way point ?
|
||||
bool HasWayPoint(uint? wID)
|
||||
{
|
||||
if (wID == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < m_aWayPoints.Count; i++)
|
||||
{
|
||||
if (m_aWayPoints[i] == wID)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void OnMsgHstWayPoint(ECMSG Msg)
|
||||
{
|
||||
CECGameUIMan pGameUI = g_pGame.GetGameRun().GetUIManager().GetInGameUIMan();
|
||||
|
||||
if (Convert.ToInt32(Msg.dwParam2) == CommandID.ACTIVATE_WAYPOINT)
|
||||
{
|
||||
cmd_activate_waypoint* pCmd = (cmd_activate_waypoint*)Msg.dwParam1;
|
||||
m_aWayPoints.Add(pCmd.waypoint);
|
||||
|
||||
// add to waypoints array
|
||||
pGameUI.GetMapDlgsMgr().UpdateWayPoints(&pCmd.waypoint, 1, false);
|
||||
|
||||
// Print a notify message
|
||||
const CECMapDlgsMgr::PointMap& aWayPoints = pGameUI.GetMapDlgsMgr().GetTransPoint();
|
||||
CECMapDlgsMgr::PointMap::const_iterator itr = aWayPoints.find(pCmd.waypoint);
|
||||
if(itr != aWayPoints.end())
|
||||
{
|
||||
g_pGame.GetGameRun().AddFixedMessage(FIXMSG_NEWWAYPOINT, (itr.second).strName);
|
||||
|
||||
bool bCanPopUITips = true;
|
||||
int count = CECUIConfig::Instance().GetGameUI().GetTaskIDDisableWayPointsUITipsCount();
|
||||
// ¼ì²éÉíÉÏÊÇ·ñÓнûÖ¹µ¯³ötipsµÄÈÎÎñ
|
||||
for (int i=0;i<count;i++){
|
||||
int taskID = CECUIConfig::Instance().GetGameUI().GetTaskIDDisableWayPointsUITips(i);
|
||||
if(GetTaskInterface() && GetTaskInterface().HasTask(taskID)){
|
||||
bCanPopUITips = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// µ¯³ötips
|
||||
CECScriptMan* pScriptMan = g_pGame.GetGameRun().GetUIManager().GetScriptMan();
|
||||
if (pScriptMan && bCanPopUITips)
|
||||
{
|
||||
pScriptMan.GetContext().GetUI().SetTipDialogTitleAndContent(AC2AS_CP(CP_UTF8, pGameUI.GetStringFromTable(11350)), AC2AS_CP(CP_UTF8, (itr.second).strName));
|
||||
pScriptMan.GetContext().GetUI().ShowTip(500, 500, 5000, 300);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (Msg.dwParam2 == WAYPOINT_LIST)
|
||||
{
|
||||
cmd_waypoint_list* pCmd = (cmd_waypoint_list*)Msg.dwParam1;
|
||||
|
||||
m_aWayPoints.SetSize(pCmd.count, 16);
|
||||
for (size_t i = 0; i < pCmd.count; i++)
|
||||
m_aWayPoints[i] = pCmd.list[i];
|
||||
|
||||
// update the whole list
|
||||
pGameUI.GetMapDlgsMgr().UpdateWayPoints(pCmd.list, pCmd.count, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ public class CECUIManager : MonoSingleton<CECUIManager>
|
||||
|
||||
[SerializeField] private HUDNPC npsUI;
|
||||
|
||||
CECGameUIMan gameUI;
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
@@ -96,4 +98,14 @@ public class CECUIManager : MonoSingleton<CECUIManager>
|
||||
kv.Value.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
// If current UI manager is INGAME manager, this function return it's interface
|
||||
public CECGameUIMan GetInGameUIMan()
|
||||
{
|
||||
if(gameUI == null)
|
||||
{
|
||||
gameUI = new CECGameUIMan();
|
||||
}
|
||||
return gameUI;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user