Merge branch 'develop' into feature/gfx-action

This commit is contained in:
vuong dinh hoang
2026-05-06 11:35:24 +07:00
4 changed files with 130 additions and 120 deletions
@@ -14,6 +14,7 @@ namespace BrewMonster.Network
private static bool m_bServerTimeInited;
private static float m_dwTickTime; // Logic time of current tick
private static float m_dwRealTickTime; // Real tick time
public static int GetTimeZoneBias() { return m_iTimeZoneBias; }
// 设置时间误差 // Set time error
public static void SetServerTime(int iSevTime, int iTimeZoneBias)
@@ -71,14 +72,13 @@ namespace BrewMonster.Network
return m_AbsTimeStart + (int)sec;
}
}
// Get real tick time of current frame
public static float GetRealTickTime()
{
// return m_dwRealTickTime;
return (uint)(Time.deltaTime * 1000f);
return Mathf.Abs(m_dwRealTickTime);
// return Time.realtimeSinceStartup;
// 0.018f is value to make mining process run fit with player animation. if have any issue => discussing with Mr. Drimdar
return Mathf.Abs(Time.unscaledDeltaTime - 0.018f) * 1000f;//-0.001f
}
}
}
}
@@ -5,10 +5,6 @@ namespace BrewMonster.UI
//Win_Hpmpxp
public class DlgHost : AUIDialog
{
public const int AUIPROGRESS_MAX = 100;
private DlgWinPrgs2 _dlgWinPrgs;
private CECHostPlayer _pHost;
public override bool Render()
{
// if( m_szName == "Win_Hpmpxp" )
@@ -16,114 +12,10 @@ namespace BrewMonster.UI
// else if (m_szName == "Win_HideHP")
// {
// a_LogOutput(1,"[Dat Mine] Win_HideHP");
RefreshStatusBar();
// RefreshStatusBar();
// }
return base.Render();
}
public void RefreshStatusBar()
{
bool bActive = true;
// if( GetGameUIMan()->GetActiveDialog() &&
// GetGameUIMan()->GetActiveDialog()->GetFocus() &&
// GetGameUIMan()->GetActiveDialog()->GetFocus()->GetType() == AUIOBJECT_TYPE_EDITBOX )
// bActive = false;
//
// // Flight bar.
// RefreshFlightBar(bActive);
//
// // Oxigen bar.
// RefreshOxigenBar(bActive);
// Gather bar.
RefreshGatherBar(bActive);
// // group these bars, show only one at one time
// bool bShow = false;
// // Power bar.
// bShow |= RefreshPowerBar(bShow, bActive);
// // Array bar.
// bShow |= RefreshArrayBar(bShow, bActive);
// // Incant bar.
// bShow |= RefreshIncantBar(bShow, bActive);
//
// if (GetHostPlayer()->GetCurSkill() && !bShow)
// {
// // ´«Ë͵ȷ½Ê½µ¼ÖÂλÖÃÇл»¡¢¼¼ÄÜ£¨Õó¼¼ÄÜ£©ÈÔÈ»ÔÚÊÍ·Å״̬
// //
// GetGameSession()->c2s_CmdCancelAction();
// }
//
// // AutoHP bar.
// RefreshAutoHPBar(bActive);
//
// // AutoMP bar.
// RefreshAutoMPBar(bActive);
//
// // pet status
// RefreshPetStatus();
//
// //ELF status
// RefreshElfStatus();
}
private bool RefreshGatherBar(bool bActive)
{
if (_dlgWinPrgs == null)
{
var pDlg = GetGameUIMan().GetDialog("Win_Prgs2");
if (pDlg == null)
{
BMLogger.LogError("Null Win_Prgs2");
return false;
}
if (pDlg is not DlgWinPrgs2 dlgWinPrgs)
{
BMLogger.LogError("Can not cast Win_Prgs2");
return false;
}
_dlgWinPrgs = dlgWinPrgs;
}
if (_pHost == null)
{
_pHost = GetHostPlayer();
if (_pHost == null) return false;
}
CECCounter counter = _pHost.GetGatherCnt();
if (_pHost.IsGathering())
{
int nCur = (int)counter.GetCounter();
int nMax = Mathf.Max((int)counter.GetPeriod(), 1);
if (!_dlgWinPrgs.IsShow())
_dlgWinPrgs.Show(bActive);//true, false, bActive
// PAUIPROGRESS pProgress = (PAUIPROGRESS)pDlg.GetDlgItem("Prgs");
// PAUILABEL pLabel = (PAUILABEL)pDlg.GetDlgItem("1");
var percent = AUIPROGRESS_MAX * nCur / nMax;
_dlgWinPrgs.SetProgressAndText(percent*1.0f/100.0f,$"{percent}%");
// pLabel.SetText(percent);
// pProgress.SetProgress(AUIPROGRESS_MAX * nCur / nMax);
if (percent < 100)
{
_dlgWinPrgs.SetActiveProgress(true);
}
}
else
{
if (_dlgWinPrgs.IsShow())
{
_dlgWinPrgs.Show(false);
_dlgWinPrgs.SetActiveProgress(false);
}
}
return _dlgWinPrgs.IsShow();
}
}
}
@@ -1,5 +1,6 @@
using System;
using BrewMonster.Network;
using BrewMonster.UI;
using UnityEngine;
using UnityEngine.UI;
@@ -17,6 +18,10 @@ namespace BrewMonster
[SerializeField]private Transform _taskTraceParent;
[SerializeField]private Button _btnTeamList;
public const int AUIPROGRESS_MAX = 100;
private DlgWinPrgs2 _dlgWinPrgs;
private CECHostPlayer _pHost;
#endregion
private void OnEnable()
@@ -27,8 +32,8 @@ namespace BrewMonster
_btnTeam.onValueChanged.AddListener(OnTeamClicked);
_btnTaskTrace.onValueChanged.AddListener(OnTaskTraceClicked);
_btnTeamList.onClick.AddListener(OnTeamListClicked);
EventBus.Unsubscribe<UIEvent>(OnUIEvent);
EventBus.Subscribe<UIEvent>(OnUIEvent);
EventBus.Unsubscribe<UIEvent>(OnUIEvent);
EventBus.Subscribe<UIEvent>(OnUIEvent);
}
private void OnDisable()
@@ -42,6 +47,11 @@ namespace BrewMonster
EventBus.Unsubscribe<UIEvent>(OnUIEvent);
}
private void Update()
{
RefreshStatusBar();
}
private void OnUIEvent(UIEvent uiEvent)
{
switch(uiEvent.EventType)
@@ -127,13 +137,121 @@ namespace BrewMonster
private void OnEscapeClicked()
{
// Open the exit dialog , not directly exit the game
// return;
if(EC_Game.GetGameRun()?.GetHostPlayer() != null)
{
EC_Game.GetGameRun()?.GetHostPlayer().OnClickBtnEscape();
}
}
#region Progress Bar
public void RefreshStatusBar()
{
bool bActive = true;
// if( GetGameUIMan()->GetActiveDialog() &&
// GetGameUIMan()->GetActiveDialog()->GetFocus() &&
// GetGameUIMan()->GetActiveDialog()->GetFocus()->GetType() == AUIOBJECT_TYPE_EDITBOX )
// bActive = false;
//
// // Flight bar.
// RefreshFlightBar(bActive);
//
// // Oxigen bar.
// RefreshOxigenBar(bActive);
// Gather bar.
RefreshGatherBar(bActive);
// // group these bars, show only one at one time
// bool bShow = false;
// // Power bar.
// bShow |= RefreshPowerBar(bShow, bActive);
// // Array bar.
// bShow |= RefreshArrayBar(bShow, bActive);
// // Incant bar.
// bShow |= RefreshIncantBar(bShow, bActive);
//
// if (GetHostPlayer()->GetCurSkill() && !bShow)
// {
// // ´«Ë͵ȷ½Ê½µ¼ÖÂλÖÃÇл»¡¢¼¼ÄÜ£¨Õó¼¼ÄÜ£©ÈÔÈ»ÔÚÊÍ·Å״̬
// //
// GetGameSession()->c2s_CmdCancelAction();
// }
//
// // AutoHP bar.
// RefreshAutoHPBar(bActive);
//
// // AutoMP bar.
// RefreshAutoMPBar(bActive);
//
// // pet status
// RefreshPetStatus();
//
// //ELF status
// RefreshElfStatus();
}
private bool RefreshGatherBar(bool bActive)
{
if (_dlgWinPrgs == null)
{
var pDlg = EC_Game.GetGameRun().GetUIManager().GetInGameUIMan().GetDialog("Win_Prgs2");
if (pDlg == null)
{
BMLogger.LogError("Null Win_Prgs2");
return false;
}
if (pDlg is not DlgWinPrgs2 dlgWinPrgs)
{
BMLogger.LogError("Can not cast Win_Prgs2");
return false;
}
_dlgWinPrgs = dlgWinPrgs;
}
if (_pHost == null)
{
_pHost = EC_Game.GetGameRun().GetHostPlayer();
if (_pHost == null) return false;
}
CECCounter counter = _pHost.GetGatherCnt();
if (_pHost.IsGathering())
{
int nCur = (int)counter.GetCounter();
int nMax = Mathf.Max((int)counter.GetPeriod(), 1);
if (!_dlgWinPrgs.IsShow())
_dlgWinPrgs.Show(bActive);//true, false, bActive
// PAUIPROGRESS pProgress = (PAUIPROGRESS)pDlg.GetDlgItem("Prgs");
// PAUILABEL pLabel = (PAUILABEL)pDlg.GetDlgItem("1");
var percent = AUIPROGRESS_MAX * nCur / nMax;
_dlgWinPrgs.SetProgressAndText(percent*1.0f/100.0f,$"{percent}%");
// pLabel.SetText(percent);
// pProgress.SetProgress(AUIPROGRESS_MAX * nCur / nMax);
if (percent < 100)
{
_dlgWinPrgs.SetActiveProgress(true);
}
}
else
{
if (_dlgWinPrgs.IsShow())
{
_dlgWinPrgs.Show(false);
_dlgWinPrgs.SetActiveProgress(false);
}
}
return _dlgWinPrgs.IsShow();
}
#endregion
}
public enum UIEventType
{
@@ -144,7 +262,7 @@ namespace BrewMonster
}
public struct UIEvent
{
public UIEventType EventType;
public UIEvent(UIEventType eventType)
{
+1 -1
View File
@@ -3641,7 +3641,7 @@ namespace BrewMonster
}
// Gather time counter
if (m_GatherCnt.IncCounter(iRealTime * 1000))
if (m_GatherCnt.IncCounter(iRealTime))
m_GatherCnt.Reset(true);
// Incant time counter