use item but cooldown don't active
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using BrewMonster;
|
||||
using BrewMonster.Network;
|
||||
using BrewMonster.Scripts;
|
||||
using BrewMonster.Scripts.Managers;
|
||||
using BrewMonster.Scripts.World;
|
||||
using BrewMonster.UI;
|
||||
using CSNetwork;
|
||||
@@ -46,6 +47,8 @@ public partial class CECGameRun
|
||||
|
||||
static RoleInfo l_SelRoleInfo; // Selected character's role info.
|
||||
|
||||
private int m_iDExpEndTime = 0;
|
||||
|
||||
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
|
||||
private static void AfterSceneLoad()
|
||||
@@ -525,4 +528,179 @@ public partial class CECGameRun
|
||||
}
|
||||
return szRet;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a fixed message to chat system with optional formatting parameters
|
||||
/// 添加固定消息到聊天系统,支持可选的格式化参数
|
||||
/// </summary>
|
||||
/// <param name="iMsg">Fixed message ID / 固定消息ID</param>
|
||||
/// <param name="args">Optional formatting arguments / 可选的格式化参数</param>
|
||||
public void AddFixedMessage(int iMsg, params object[] args)
|
||||
{
|
||||
CECStringTab pStrTab = EC_Game.GetFixedMsgs();
|
||||
if (pStrTab == null)
|
||||
{
|
||||
Debug.LogWarning("[AddFixedMessage] Failed to get fixed message table");
|
||||
return;
|
||||
}
|
||||
|
||||
string szFixMsg = pStrTab.GetWideString(iMsg);
|
||||
if (string.IsNullOrEmpty(szFixMsg))
|
||||
{
|
||||
Debug.LogWarning($"[AddFixedMessage] Fixed message {iMsg} not found");
|
||||
return;
|
||||
}
|
||||
|
||||
// Format the message with provided arguments
|
||||
string szFormattedMsg;
|
||||
try
|
||||
{
|
||||
if (args != null && args.Length > 0)
|
||||
{
|
||||
szFormattedMsg = string.Format(szFixMsg, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
szFormattedMsg = szFixMsg;
|
||||
}
|
||||
}
|
||||
catch (System.FormatException ex)
|
||||
{
|
||||
Debug.LogError($"[AddFixedMessage] Format error for message {iMsg}: {ex.Message}");
|
||||
szFormattedMsg = szFixMsg; // Use unformatted message as fallback
|
||||
}
|
||||
|
||||
// Try to add to in-game UI chat
|
||||
CECGameUIMan pGameUI = m_pUIManager?.GetInGameUIMan();
|
||||
if (pGameUI != null)
|
||||
{
|
||||
//pGameUI.AddChatMessage(szFormattedMsg, (int)GP_CHAT.GP_CHAT_SYSTEM);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Fallback to debug output if UI is not available
|
||||
Debug.Log($"[System] {szFormattedMsg}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a fixed message to specific chat channel with optional formatting
|
||||
/// 添加固定消息到指定聊天频道,支持可选的格式化
|
||||
/// </summary>
|
||||
/// <param name="iMsg">Fixed message ID / 固定消息ID</param>
|
||||
/// <param name="cChannel">Chat channel ID / 聊天频道ID</param>
|
||||
/// <param name="args">Optional formatting arguments / 可选的格式化参数</param>
|
||||
public void AddFixedChannelMsg(int iMsg, int cChannel, params object[] args)
|
||||
{
|
||||
CECStringTab pStrTab = EC_Game.GetFixedMsgs();
|
||||
if (pStrTab == null)
|
||||
{
|
||||
Debug.LogWarning("[AddFixedChannelMsg] Failed to get fixed message table");
|
||||
return;
|
||||
}
|
||||
|
||||
string szFixMsg = pStrTab.GetWideString(iMsg);
|
||||
if (string.IsNullOrEmpty(szFixMsg))
|
||||
{
|
||||
Debug.LogWarning($"[AddFixedChannelMsg] Fixed message {iMsg} not found");
|
||||
return;
|
||||
}
|
||||
|
||||
// Format the message with provided arguments
|
||||
string szFormattedMsg;
|
||||
try
|
||||
{
|
||||
if (args != null && args.Length > 0)
|
||||
{
|
||||
szFormattedMsg = string.Format(szFixMsg, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
szFormattedMsg = szFixMsg;
|
||||
}
|
||||
}
|
||||
catch (System.FormatException ex)
|
||||
{
|
||||
Debug.LogError($"[AddFixedChannelMsg] Format error for message {iMsg}: {ex.Message}");
|
||||
szFormattedMsg = szFixMsg; // Use unformatted message as fallback
|
||||
}
|
||||
|
||||
// Try to add to in-game UI chat with specific channel
|
||||
CECGameUIMan pGameUI = m_pUIManager?.GetInGameUIMan();
|
||||
if (pGameUI != null)
|
||||
{
|
||||
//pGameUI.AddChatMessage(szFormattedMsg, cChannel);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Fallback to debug output if UI is not available
|
||||
Debug.Log($"[Channel {cChannel}] {szFormattedMsg}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a chat message with full parameters (matching C++ signature)
|
||||
/// 添加聊天消息(完整参数版本,匹配C++签名)
|
||||
/// </summary>
|
||||
/// <param name="pszMsg">Message text / 消息文本</param>
|
||||
/// <param name="cChannel">Chat channel / 聊天频道</param>
|
||||
/// <param name="idPlayer">Player ID (default -1) / 玩家ID</param>
|
||||
/// <param name="szName">Player name (optional) / 玩家名称</param>
|
||||
/// <param name="byFlag">Message flag (default 0) / 消息标志</param>
|
||||
/// <param name="cEmotion">Emotion ID (default 0) / 表情ID</param>
|
||||
/// <param name="pItem">Related item (optional) / 相关物品</param>
|
||||
/// <param name="pszMsgOrigion">Original message (optional) / 原始消息</param>
|
||||
public void AddChatMessage(string pszMsg, int cChannel, int idPlayer = -1,
|
||||
string szName = null, byte byFlag = 0, int cEmotion = 0,
|
||||
EC_IvtrItem pItem = null, string pszMsgOrigion = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(pszMsg))
|
||||
return;
|
||||
|
||||
CECGameUIMan pGameUI = m_pUIManager?.GetInGameUIMan();
|
||||
if (pGameUI != null)
|
||||
{
|
||||
// Call UI manager's AddChatMessage with full parameters
|
||||
//pGameUI.AddChatMessage(pszMsg, cChannel, idPlayer, szName, byFlag, cEmotion, pItem, pszMsgOrigion);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Fallback to debug output if UI is not available
|
||||
Debug.Log($"[Channel {cChannel}] {pszMsg}");
|
||||
|
||||
// Note: In C++ original, pItem is deleted here if UI is not available
|
||||
// In C#, we don't need explicit deletion due to garbage collection
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get remaining double experience time in seconds
|
||||
/// 获取剩余双倍经验时间(秒)
|
||||
/// </summary>
|
||||
public int GetRemainDblExpTime()
|
||||
{
|
||||
int iRemainTime = m_iDExpEndTime - GetServerAbsTime();
|
||||
if (iRemainTime < 0) iRemainTime = 0;
|
||||
return iRemainTime;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get server absolute time
|
||||
/// 获取服务器绝对时间
|
||||
/// </summary>
|
||||
public int GetServerAbsTime()
|
||||
{
|
||||
// TODO: Implement server time synchronization
|
||||
// This should return the synchronized server timestamp
|
||||
return (int)(System.DateTime.UtcNow.Subtract(new System.DateTime(1970, 1, 1))).TotalSeconds;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set double experience end time
|
||||
/// 设置双倍经验结束时间
|
||||
/// </summary>
|
||||
public void SetDExpEndTime(int endTime)
|
||||
{
|
||||
m_iDExpEndTime = endTime;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user