coool down ui

This commit is contained in:
VDH
2026-01-05 18:25:27 +07:00
parent 18b0dc0c0e
commit 7e83b578fe
12 changed files with 144 additions and 256 deletions
@@ -87,7 +87,7 @@ GameObject:
- component: {fileID: 2690941580050673919}
- component: {fileID: 4280331804577109228}
m_Layer: 5
m_Name: Image
m_Name: ImageLock
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@@ -170,7 +170,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &5717981154351234976
RectTransform:
m_ObjectHideFlags: 0
@@ -221,6 +221,9 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_ClockIcon: {fileID: 4280331804577109228}
m_iMin: 0
m_iMax: 0
m_iPos: 0
--- !u!222 &1012268097730980895
CanvasRenderer:
m_ObjectHideFlags: 0
@@ -143,6 +143,7 @@ namespace BrewMonster
// Tick routine
public void Tick(float deltaTime)
{
BMLogger.LogError($"CECSkill Tick m_bCooling: = {m_bCooling}, m_iCoolCnt={m_iCoolCnt}" );
// Convert deltaTime (seconds) to milliseconds
int tickTime = (int)(deltaTime * 1000f);
@@ -321,7 +322,6 @@ namespace BrewMonster
public float GetCastRange(float fAtkDist, float fPrayDistancePlus)
{
BMLogger.LogError($"HoangDev: GetCastRange {m_pSkillCore}");
return m_pSkillCore != null ? m_pSkillCore.GetPrayRange(fAtkDist, fPrayDistancePlus) : 0f;
}
public string GetEffect()
@@ -1728,6 +1728,11 @@ namespace CSNetwork.GPDataType
public int cooldown;
public int max_cooltime;
}
public struct cmd_set_cooldown
{
public int cooldown_index;
public int cooldown_time;
};
[StructLayout(LayoutKind.Sequential, Pack = 1)] // sizeof = 36 với padding 1 byte sau dir
public struct cmd_npc_info_00
@@ -367,6 +367,7 @@ namespace CSNetwork
// pAutoTeam.OnPrtcAutoTeamSetGoalRe((AutoTeamSetGoal_Re)protocol);
}
break;
default:
_logger.Log(LogType.Warning, $"Received unhandled protocol type: {protocol.GetPType()}");
break;
@@ -783,6 +784,9 @@ namespace CSNetwork
case CommandID.MINE_GATHERED:
EC_ManMessage.PostMessage(EC_MsgDef.MSG_PM_PLAYERGATHER, MANAGER_INDEX.MAN_PLAYER, -1, pDataBuf, pCmdHeader);
break;
case CommandID.COOLTIME_DATA:
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_COOLTIMEDATA, MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader);
break;
}
}
@@ -100,11 +100,9 @@ namespace BrewMonster.Scripts.Skills
player.SetPrayrangeplus(prayplus);
if (stub.type == (int)skill_type.TYPE_ATTACK || stub.type == (int)skill_type.TYPE_CURSE)
{
BMLogger.LogError($"HoangDev: GetPrayRange AutoAttack {stub.auto_attack}");
if (stub.auto_attack)
{
float r = 0.3f * stub.GetPraydistance(this);
BMLogger.LogError($"HoangDev: r={r} ");
if (r >= 1.0)
return stub.GetPraydistance(this) - 1.0f;
@@ -10,7 +10,7 @@ using UnityEngine.UI;
namespace BrewMonster
{
public class CdlgQuickBar : MonoBehaviour
public class CDlgQuickBar : MonoBehaviour
{
//[SerializeField] List<Image> m_aSkillImage = new List<Image>();
//[SerializeField] List<Button> m_aSkillButton = new List<Button>();
@@ -34,6 +34,7 @@ namespace BrewMonster
int nCurPanel8 = GetCurPanel2();
CECHostPlayer pHost = EC_Game.GetGameRun().GetHostPlayer();
if(pHost == null) return false;
var a_pSCS = new List<CECShortcutSet>();
var a_pszPanel = new List<string>();
GetQuickBarNameAndSC(pHost, a_pszPanel, a_pSCS, nCurPanel9, nCurPanel8);
@@ -103,7 +104,9 @@ namespace BrewMonster
if (pHost.GetPrepSkill() == pSkill)
pClock.SetProgressPos(0);
else
pClock.SetProgressPos(pSkill.GetCoolingTime() - pSkill.GetCoolingCnt());
{
BMLogger.LogError($"HoangDev: GetCoolingTime:{pSkill.GetCoolingTime()}, GetCoolingCnt: {pSkill.GetCoolingCnt()} ");
pClock.SetProgressPos(pSkill.GetCoolingTime() - pSkill.GetCoolingCnt()); }
}
}
}
@@ -33,10 +33,10 @@ namespace BrewMonster
}
private void Update()
{
if (m_iPos != m_iMin)
/* if (m_iPos >= m_iMin)
{
UpdateClockIcon();
}
}*/
}
private void UpdateClockIcon()
{
+2 -2
View File
@@ -202,7 +202,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 11414302, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_Value
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11490438, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_IgnoreReversedGraphics
@@ -210,7 +210,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 22400762, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchoredPosition.y
value: -0.000061035156
value: 0.000061035156
objectReference: {fileID: 0}
- target: {fileID: 22426080, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchorMax.x
+2 -2
View File
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:dfacfe7598c13b74bf00df392384c4c626d00ac99325d3db2353f0e31cc8a414
size 200761977
oid sha256:733ae9a8b796ba7d65c4cd6a2164189f914379d0c4cb23a4b6bb0eaa0cc9249c
size 200761813
+93 -7
View File
@@ -1,4 +1,5 @@
using BrewMonster.Assets.PerfectWorld.Scripts.Players;
using BrewMonster;
using BrewMonster.Assets.PerfectWorld.Scripts.Players;
using BrewMonster.Managers;
using BrewMonster.Network;
using BrewMonster.PerfectWorld.Scripts.Vfx;
@@ -493,7 +494,7 @@ namespace BrewMonster
case int value when value == EC_MsgDef.MSG_HST_TARGETISFAR: OnMsgHstTargetIsFar(Msg); break;
case int value when value == EC_MsgDef.MSG_PM_PLAYERGATHER: OnMsgPlayerGather(Msg); break;
case int value when value == EC_MsgDef.MSG_HST_COOLTIMEDATA: OnMsgHstCoolTimeData(Msg); break;
case int value when value == EC_MsgDef.MSG_HST_SETCOOLTIME: OnMsgHstSetCoolTime(Msg); break;
}
@@ -517,8 +518,97 @@ namespace BrewMonster
}*/
}
private void OnMsgHstSetCoolTime(ECMSG Msg)
{
BMLogger.LogError("HoangDev : OnMsgHstSetCoolTime ");
cmd_set_cooldown pCmd = GPDataTypeHelper.FromBytes<cmd_set_cooldown>((byte[])Msg.dwParam1);
if (pCmd.cooldown_index < 0)
{
BMLogger.LogError("pCmd.cooldown_index >= 0 :" + (pCmd.cooldown_index >= 0));
return;
}
if (pCmd.cooldown_index < (int)CoolTimeIndex.GP_CT_MAX)
{
COOLTIME ct = m_aCoolTimes[pCmd.cooldown_index];
ct.iCurTime = pCmd.cooldown_time;
ct.iMaxTime = pCmd.cooldown_time;
Math.Min(ct.iCurTime, ct.iMaxTime);
if (pCmd.cooldown_index == (int)CoolTimeIndex.GP_CT_CAST_ELF_SKILL)
{
int i;
// other goblin skills should be set public cool down, 1 second
/* for (i = 0; i < m_aGoblinSkills.GetSize(); i++)
{
if (m_aGoblinSkills[i] && m_aGoblinSkills[i]->GetCoolingCnt() == 0)
m_aGoblinSkills[i]->StartCooling(GetCoolTime(GP_CT_CAST_ELF_SKILL), GetCoolTime(GP_CT_CAST_ELF_SKILL));
}*/
/* for (i = 0; i < m_aPsSkills.Count; i++)
{
CECSkill pSkill = GetPassiveSkillByIndex(i);
if (pSkill && (pSkill->GetCommonCoolDown() & (1 << (pCmd->cooldown_index - GP_CT_SKILLCOMMONCOOLDOWN0))))
pSkill->StartCooling(GetCoolTime(pCmd->cooldown_index), GetCoolTime(pCmd->cooldown_index));
}*/
}
if (pCmd.cooldown_index >= (int)CoolTimeIndex.GP_CT_SKILLCOMMONCOOLDOWN0 && pCmd.cooldown_index <= (int)CoolTimeIndex.GP_CT_SKILLCOMMONCOOLDOWN4)
{
// other player skills should be set public cool down too.
uint mask = (uint)( 1 << (pCmd.cooldown_index - (int)CoolTimeIndex.GP_CT_SKILLCOMMONCOOLDOWN0));
for (int i = 0; i < GetPositiveSkillNum(); i++)
{
CECSkill pSkill = GetPositiveSkillByIndex(i);
int fakeRef = 0;
if (pSkill != null && (pSkill.GetCommonCoolDown() & mask) != 0)
pSkill.StartCooling(GetCoolTime(pCmd.cooldown_index,ref fakeRef), GetCoolTime(pCmd.cooldown_index, ref fakeRef));
}
/*const std::map<unsigned int, CECSkill*>&inherentSkillMap = CECComboSkillState::Instance().GetInherentSkillMap();
std::map < unsigned int, CECSkill*>::const_iterator it;
for (it = inherentSkillMap.begin(); it != inherentSkillMap.end(); ++it)
{
it->second->StartCooling(GetCoolTime(pCmd->cooldown_index), GetCoolTime(pCmd->cooldown_index));
}*/
}
}
else if (pCmd.cooldown_index > (int)CoolTimeIndex.GP_CT_SKILL_START)
{
int idSkill = pCmd.cooldown_index - (int)CoolTimeIndex.GP_CT_SKILL_START;
COOLTIME ct = m_skillCoolTime[idSkill];
ct.iCurTime = pCmd.cooldown_time;
ct.iMaxTime = pCmd.cooldown_time;
Math.Clamp(ct.iCurTime, 0, ct.iMaxTime);
CECSkill pSkill = GetNormalSkill(idSkill);
if (pSkill != null)
{
pSkill.StartCooling(pCmd.cooldown_time, pCmd.cooldown_time);
}
/* else if (pSkill = CECComboSkillState::Instance().GetInherentSkillByID(idSkill))
{
pSkill->StartCooling(pCmd->cooldown_time, pCmd->cooldown_time);
}*/
else if (GetEquipSkillByID(idSkill) == null)
{
BMLogger.LogError ("HoangDev: pSkill " + pSkill);
}
}
else
{
// This is a annoying assert and mean nothing, so we ignore it.
// ASSERT(0);
}
UpdateEquipSkillCoolDown(pCmd.cooldown_index);
}
private void OnMsgHstCoolTimeData(ECMSG Msg)
{
BMLogger.LogError("HoangDev : OnMsgHstCoolTimeData ");
cmd_cooltime_data pCmd = default;
var data = (byte[])Msg.dwParam1;
pCmd.count = GPDataTypeHelper.FromBytes<ushort>(data, 0);
@@ -648,7 +738,6 @@ namespace BrewMonster
// 对目标对象施法
cmd_object_cast_skill pCmd =
GPDataTypeHelper.FromBytes<cmd_object_cast_skill>((byte[])Msg.dwParam1);
BMLogger.LogError("pCmd.caster == m_PlayerInfo.cid =" + (pCmd.caster == m_PlayerInfo.cid));
if (m_pCurSkill != null)
{
@@ -713,7 +802,6 @@ namespace BrewMonster
if (m_pCurSkill != null && m_pCurSkill.IsDurative())
m_bSpellDSkill = true;
Debug.Log($"SKILL_PERFORM)");
break;
}
@@ -2776,7 +2864,6 @@ namespace BrewMonster
float fMaxCut = 1.0f)
{
float fDist = A3d_Magnitude(vTargetPos - vHostPos);
BMLogger.LogError($"CanTouchTarget iReason={iReason} , m_pPrepSkill={m_pPrepSkill}");
switch (iReason)
{
case 1: // melee
@@ -2807,7 +2894,6 @@ namespace BrewMonster
//TODO : Check this function GetCastRange
float fRange = m_pPrepSkill.GetCastRange(m_ExtProps.ak.AttackRange, GetPrayDistancePlus());
BMLogger.LogError($"HoangDev: CanTouchTarget fDist= {fDist}, fRange={fRange}, fDist - fTargetRad={fDist - fTargetRad}, m_ExtProps.ak.AttackRange ={m_ExtProps.ak.AttackRange}, GetPrayDistancePlus()={GetPrayDistancePlus()}");
if (fRange > 0.0f)
{
@@ -5193,7 +5279,7 @@ namespace BrewMonster
// Is gathering resources
public bool IsGathering()
{
if(m_pWorkMan == null) return false;
if (m_pWorkMan == null) return false;
CECHPWork pWork = m_pWorkMan.GetRunningWork(Host_work_ID.WORK_PICKUP);
if (pWork != null)
return ((EC_HPWorkPick)pWork).IsGather();
+16 -15
View File
@@ -21,19 +21,20 @@ public class CECUIManager : MonoSingleton<CECUIManager>
[SerializeField] private DialogScriptTableObject dialogResouce;
[SerializeField] private Canvas canvasDlg;
[SerializeField] private CdlgQuickBar cDlgQuickBar;
[SerializeField] private Button skillButton;
[SerializeField] private Button btnSecondClick; // Button for second-click action (attack/move to NPC)
[SerializeField] private CDlgQuickBar cDlgQuickBar;
[SerializeField] private Button btnSecondClick;
[SerializeField] CDlgQuickBar m_pDlgQuickBar1;
protected override void Awake()
{
base.Awake();
EventBus.Subscribe<CECHostPlayer.NPCINFO>(ShowUINPC);
EventBus.Subscribe<NPCDiedEvent>(TryHideUINPC);
gameUI = new CECGameUIMan();
gameUI.SetDependency(dialogResouce, canvasDlg);
gameUI.Init();
// Wire up second-click button / 连接第二次点击按钮
if (btnSecondClick != null)
{
@@ -42,6 +43,10 @@ public class CECUIManager : MonoSingleton<CECUIManager>
ShowUI("Win_Hpmpxp");
}
private void Update()
{
m_pDlgQuickBar1.UpdateShortcuts();
}
private void OnDestroy()
{
@@ -57,11 +62,7 @@ public class CECUIManager : MonoSingleton<CECUIManager>
npsUI.SetHealthImage((float)obj.CurrentHealth / (float)obj.MaxHealth);
currentTargetNPCID = obj.IDNPC;
}
public void SetSkillButton()
{
}
public CdlgQuickBar GetCDlgQuickBar()
public CDlgQuickBar GetCDlgQuickBar()
{
return cDlgQuickBar;
}
@@ -88,7 +89,7 @@ public class CECUIManager : MonoSingleton<CECUIManager>
return;
var type = FindTypeByName(componentName);
if (TryShowCachedUI(type)) return;
if (FindUIByName(componentName, type)) return;
if (FindUIByType(type)) return;
@@ -119,7 +120,7 @@ public class CECUIManager : MonoSingleton<CECUIManager>
{
var type = assembly.GetType(componentName);
if (type != null) return type;
foreach (var prefix in namespacePrefixes)
{
if (string.IsNullOrEmpty(prefix)) continue;
@@ -157,7 +158,7 @@ public class CECUIManager : MonoSingleton<CECUIManager>
return true;
}
}
ActivateAndCacheUI(child.gameObject, type);
return true;
}
@@ -167,7 +168,7 @@ public class CECUIManager : MonoSingleton<CECUIManager>
private bool FindUIByType(System.Type type)
{
if (type == null) return false;
var foundComponent = canvasDlg.GetComponentInChildren(type, true);
if (foundComponent != null)
{
@@ -234,7 +235,7 @@ public class CECUIManager : MonoSingleton<CECUIManager>
{
return currentTargetNPCID;
}
//todo: change this code to other place
private int slot = 0;
public void OnClickedWaveHand()
File diff suppressed because one or more lines are too long