send to server learn skill

This commit is contained in:
VDH
2026-01-13 17:58:20 +07:00
parent 6066e851a4
commit 511a833967
14 changed files with 567 additions and 644 deletions
@@ -542,7 +542,7 @@ GameObject:
- component: {fileID: 8578995796031649400}
- component: {fileID: 2243330050876855902}
- component: {fileID: 3372223705930781376}
- component: {fileID: 8056968728849250909}
- component: {fileID: 1069295583529170983}
m_Layer: 5
m_Name: MessageBox
m_TagString: Untagged
@@ -610,7 +610,7 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &8056968728849250909
--- !u!114 &1069295583529170983
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@@ -619,7 +619,7 @@ MonoBehaviour:
m_GameObject: {fileID: 5492547392745930423}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7397a97ad381b754689dee54c66ed470, type: 3}
m_Script: {fileID: 11500000, guid: 6672523dc3dacfa46b2104f504acdb6e, type: 3}
m_Name:
m_EditorClassIdentifier:
titleText: {fileID: 5031655611580643013}
@@ -148,7 +148,6 @@ namespace BrewMonster
if (m_bCooling)
{
// In cooling state
m_iCoolCnt -= tickTime;
if (m_iCoolCnt <= 0)
{
@@ -195,6 +194,7 @@ namespace BrewMonster
// iTotalTime: total cooling time, 0 means to use cooling time in database
public void StartCooling(int iTotalTime, int iStartCnt)
{
BMLogger.LogError($"StartCooling iTotalTime={iTotalTime}, iStartCnt={iStartCnt}");
m_iCoolTime = iTotalTime != 0 ? iTotalTime : GetCoreCoolingTime();
m_iCoolCnt = iStartCnt;
m_bCooling = true;
@@ -788,6 +788,7 @@ namespace CSNetwork
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_COOLTIMEDATA, MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader);
break;
case CommandID.LEARN_SKILL:
BMLogger.LogError("### GameDataSend: LEARN_SKILL");
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_LEARNSKILL, MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader);
break;
}
@@ -1312,6 +1313,8 @@ namespace CSNetwork
{
gamedatasend gamedatasend = new gamedatasend();
gamedatasend.Data = C2SCommandFactory.CreateNPCSevLearnSkillCmd(idSkill);
BMLogger.LogError("HoangDev : c2s_SendCmdNPCSevLearnSkill gamedatasend.Data : " + gamedatasend.Data.Size);
BMLogger.LogError("HoangDev : c2s_SendCmdNPCSevLearnSkill idSkill : " + idSkill);
SendProtocol(gamedatasend);
}
@@ -264,6 +264,7 @@ namespace BrewMonster.Network
}
public static void c2s_SendCmdNPCSevLearnSkill(int idSkill)
{
BMLogger.LogError("c2s_SendCmdNPCSevLearnSkill");
Instance._gameSession.c2s_SendCmdNPCSevLearnSkill(idSkill);
}
public static void c2s_CmdNPCSevHello(int nid)
@@ -248,7 +248,6 @@ namespace BrewMonster
SetServerPos(Cmd.dest);
float fDist = m_vMoveDir.Normalize();
BrewMonster.BMLogger.Log($"HoangDev : {fDist} : {MAX_LAGDIST} || {m_fMoveSpeed}");
if (fDist >= MAX_LAGDIST || m_fMoveSpeed < 0.01f)
{
@@ -5,6 +5,7 @@ using ModelRenderer.Scripts.GameData;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine;
namespace BrewMonster.Scripts.Skills
{
@@ -36,13 +37,23 @@ namespace BrewMonster.Scripts.Skills
private bool m_bInitialized;
private Octets m_npcListData;
/// <summary>
/// 获取当前职业的全部技能映射(阶位 -> 技能列表) / Get rank-to-skills map for current profession.
/// </summary>
#if UNITY_EDITOR
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
static void BeforeSceneLoad()
{
BMLogger.LogError("CECHostSkillModel BeforeSceneLoad Reset");
Instance = null;
}
#endif
public IReadOnlyDictionary<int, List<int>> GetAllRankProfSkills()
{
return m_allRankProfSkills;
}
public CECHostSkillModel()
{
m_skillLearnNPCNID = 0;
m_bInitialized = false;
}
public enumSkillLearnedState GetSkillLearnedState(int skillID)
{
CECSkill pSkill = CECGameRun.Instance.GetHostPlayer().GetNormalSkill(skillID);
@@ -71,6 +82,7 @@ namespace BrewMonster.Scripts.Skills
}
public void Initialize()
{
BMLogger.LogError("HoangDev CECHostSkillModel Initialize called");
// Çå¿ÕËùÓм¼ÄÜ£¬·ÀÖ¹ÒòΪ¶à¸ö½ÇÉ«µÇ¼µ¼ÖÂÖØ¸´¼ÓÔØ¼¼ÄÜ
Release();
@@ -87,9 +99,10 @@ namespace BrewMonster.Scripts.Skills
}
public void ProcessServiceList()
{
BMLogger.LogError("HoangDev: ProcessServiceList");
if (m_npcListData == null)
{
BMLogger.LogWarning("CECHostSkillModel::ProcessServiceList, m_npcListData is null.");
BMLogger.LogError("CECHostSkillModel::ProcessServiceList, m_npcListData is null.");
return;
}
if (m_npcListData.Size > 0)
@@ -113,14 +126,17 @@ namespace BrewMonster.Scripts.Skills
npcList.list[z] = GPDataTypeHelper.FromBytes<cmd_scene_service_npc_list.NpcEntry>(bodyBytes, offset);
offset += NpcEntrySize;
}
BMLogger.LogError("ProcessServiceList npcList.count:" + npcList.count);
BMLogger.LogError("ProcessServiceList m_allProfNPCs.count:" + m_allProfNPCs.Count);
int i;
for (i = 0; i < npcList.count; i++)
{
int tid = npcList.list[i].tid;
BMLogger.LogError("ProcessServiceList tid:" + tid);
if (m_allProfNPCs.Contains(tid))
{
BMLogger.LogError("m_skillLearnNPCNID : " + m_skillLearnNPCNID);
BMLogger.LogError("npcList.list[i].nid : " + npcList.list[i].nid);
if (m_skillLearnNPCNID != npcList.list[i].nid)
{
m_skillLearnNPCNID = npcList.list[i].nid;
@@ -139,9 +155,10 @@ namespace BrewMonster.Scripts.Skills
var change = new CECSkillPanelChange(CECSkillPanelChange.enumChangeMask.CHANGE_SKILL_NPC, 0, 0);
//NotifyObservers(change);
}
m_npcListData.Clear();
}
BMLogger.LogError("HoangDev: m_npcListData.Size :"+ m_npcListData.Size);
}
private readonly HashSet<int> m_curServiceSkills = new HashSet<int>();
public string GetSkillIcon(int skillID)
@@ -151,6 +168,7 @@ namespace BrewMonster.Scripts.Skills
}
public void SetCurServiceSkills(int tid)
{
BMLogger.LogError("SetCurServiceSkills " + tid);
m_curServiceSkills.Clear();
if (tid == 0)
return;
@@ -164,7 +182,6 @@ namespace BrewMonster.Scripts.Skills
return;
var npcEssence = (NPC_ESSENCE)dataprt;
// Get skill service block from id_skill_service
var dataprt2 = pDB.get_data_ptr(npcEssence.id_skill_service, ID_SPACE.ID_SPACE_ESSENCE, ref dt);
if (dataprt2 == null)
return;
@@ -174,8 +191,10 @@ namespace BrewMonster.Scripts.Skills
foreach (int skillId in skillService.id_skills)
{
if (skillId != 0)
m_curServiceSkills.Add(skillId);
{ m_curServiceSkills.Add(skillId); }
}
BMLogger.LogError("SetCurServiceSkills m_curServiceSkills count:" + m_curServiceSkills.Count);
BMLogger.LogError("SetCurServiceSkills skillService.id_skills count:" + skillService.id_skills.Length);
}
public enumSkillFitLevelState GetSkillFitLevel(int skillID)
{
@@ -370,6 +389,8 @@ namespace BrewMonster.Scripts.Skills
DATA_TYPE dt = DATA_TYPE.DT_NPC_ESSENCE;
elementdataman pDB = ElementDataManProvider.GetElementDataMan();
var map = pDB.GetAllDataTypeWithType(ID_SPACE.ID_SPACE_ESSENCE, dt);
BMLogger.LogError("Hoang Dev map Count :" + map.Length);
foreach (var obj in map)
{
NPC_ESSENCE npcEssence = (NPC_ESSENCE)obj;
@@ -384,7 +405,12 @@ namespace BrewMonster.Scripts.Skills
{
ElementSkill pSkill = ElementSkill.Create(skillService.id_skills[i], 1);
if (pSkill == null) return;
if (pSkill == null)
{
BMLogger.LogError("Hoang Dev pSkill is null for skill id :" + skillService.id_skills[i]);
return;
}
if (pSkill.GetCls() == CECGameRun.Instance.GetHostPlayer().GetProfession())
{
@@ -396,11 +422,12 @@ namespace BrewMonster.Scripts.Skills
}
if (profCorrect)
{
BMLogger.LogError("m_allProfNPCs.Add " + (int)npcEssence.id);
m_allProfNPCs.Add((int)npcEssence.id);
}
BMLogger.LogError("Hoang Dev skillService.id_skills.Length :" + skillService.id_skills.Length);
}
}
}
public void InitAllSkillsOfCurProf()
{
@@ -453,8 +480,7 @@ namespace BrewMonster.Scripts.Skills
m_allRankProfSkills[pSkill.GetRank()].Add((int)curID);
}
}
BMLogger.LogError("CECHostSkillModel::InitAllSkillsOfCurProf: total prof skills = " + m_allRankProfSkills.Count);
// --- B3: Sắp xếp skill trong từng rank theo thứ tự hiển thị ---
foreach (var kvp in m_allRankProfSkills)
{
kvp.Value.Sort((lhs, rhs) =>
@@ -486,6 +512,7 @@ namespace BrewMonster.Scripts.Skills
private void Release()
{
BMLogger.LogError("HoangDev CECHostSkillModel Release called");
m_allProfSkills.Clear();
// Dọn sạch tất cả dictionary / map
@@ -26,16 +26,16 @@ namespace BrewMonster.UI
}
public bool SetName(string pszName)
{
if (m_pAUIManager.m_DlgName[pszName])
if (m_pAUIManager.m_DlgName.ContainsKey(pszName))
return false;
m_pAUIManager.m_DlgName.Remove(m_szName);
//m_pAUIManager.m_DlgName.Remove(m_szName);
m_szName = pszName;
m_pAUIManager.m_DlgName[m_szName] = this;
return true;
}
public void SetData(uint dwData, string strName)
public void SetData(uint dwData, string strName = "")
{
m_strDataName = strName;
m_dwData = dwData;
@@ -108,7 +108,7 @@ namespace BrewMonster.UI
public virtual void Awake()
{
m_szName = "Dialog_";
}
public virtual void Start()
@@ -163,6 +163,7 @@ namespace BrewMonster.UI
taoistRank != CECTaoistRank.GetBaseRankEnd();
taoistRank = taoistRank.GetNext())
{
BMLogger.LogError ("ResetDialog base rank " + taoistRank.GetName());
AddDlgsOfOneRank(taoistRank);
}
@@ -170,6 +171,7 @@ namespace BrewMonster.UI
taoistRank != CECTaoistRank.GetGodRankEnd();
taoistRank = taoistRank.GetNext())
{
BMLogger.LogError("ResetDialog base rank " + taoistRank.GetName());
AddDlgsOfOneRank(taoistRank);
}
@@ -199,6 +201,7 @@ namespace BrewMonster.UI
// ޸ijһ״̬ / Refresh a single skill sub dialog
private void UpdateOneSubDlg(int skillID)
{
BMLogger.LogError("UpdateOneSubDlg");
if (!m_skillSubDialogsMap.TryGetValue(skillID, out var pSub))
{
return;
@@ -32,6 +32,7 @@ namespace BrewMonster
private void UpdateClockIcon()
{
float progress = (float)(m_iMax - m_iPos) / (m_iMax - m_iMin);
//BMLogger.LogError($"UpdateClockIcon progress:{progress}, m_iMax:{m_iMax}, m_iPos:{m_iPos}, m_iMin:{m_iMin}" );
m_ClockIcon.fillAmount = progress;
}
@@ -94,7 +94,8 @@ namespace BrewMonster
string str = string.Format(GetStringFromTable(11326), needMoney, needSp);
uiManager.ShowMessageBox("Game_LearnSkill", str);
var messagebox = uiManager.ShowMessageBox("Game_LearnSkill", str);
messagebox.SetData((uint)m_skillID);
//GetGameUIMan()->MessageBox("Game_LearnSkill", str, //GetGameUIMan()->GetStringFromTable(231),
// MB_OKCANCEL, A3DCOLORRGBA(255, 255, 255, 160), &pMsgBox);
//pMsgBox->SetData(m_skillID);
@@ -115,6 +116,7 @@ namespace BrewMonster
public void UpdateSkill(int skillID)
{
BMLogger.LogError("HoangDev: CDlgSkillSubListItem UpdateSkill skillID " + skillID);
CECHostSkillModel model = CECHostSkillModel.Instance;
m_skillID = skillID;
m_curLevel = model.GetSkillCurrentLevel(m_skillID);
@@ -169,6 +171,7 @@ namespace BrewMonster
enumSkillLearnedState learnedState = model.GetSkillLearnedState(m_skillID);
int requiredItem = model.GetRequiredBook(m_skillID, m_curLevel + 1);
BMLogger.LogError($"UpdateUpgradeBtn learnedState:{learnedState}, fitLevel={fitLevel}, requiredItem:{requiredItem}, model.CheckPreItem(requiredItem):{model.CheckPreItem(requiredItem)}");
if (enumSkillLearnedState.SKILL_FULL != learnedState &&
enumSkillFitLevelState.SKILL_FIT_LEVEL == fitLevel &&
(requiredItem == 0 || model.CheckPreItem(requiredItem)))
@@ -199,6 +202,7 @@ namespace BrewMonster
}
}
}
BMLogger.LogError($"HoangDev: UpdateUpgradeBtn m_skillID:{m_skillID} spOK=" + spOK + ", moneyOK=" + moneyOK + ", preSkillOK=" + preSkillOK);
if (spOK && moneyOK && preSkillOK)
{
m_upgradeBtn.interactable = true;
@@ -241,6 +245,7 @@ namespace BrewMonster
}
else
{
BMLogger.LogError("HoangDev: UpdateUpgradeBtn Skill is not served by NPC m_skillID:" + m_skillID);
str = string.Format(GetStringFromTable(11321));
// m_upgradeBtn.SetHint(str);
m_upgradeBtn.interactable = false;
+2 -2
View File
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2e061f4870d980f3ea929a34fa1dc95ea640cd5d8071ed5638bcdd9a7ac5461c
size 200797970
oid sha256:d638d3483a375bc3a8f2c7cc7530d3aad5948ba82c3678f3936ac7e2d052015b
size 200798907
+4 -11
View File
@@ -290,6 +290,7 @@ namespace BrewMonster
public bool LoadResources()
{
BMLogger.LogError("HoangDev: CECHostPlayer::LoadResources");
RoleInfo RoleInfo = UnityGameSession.Instance.GetRoleInfo();
m_iProfession = RoleInfo.occupation;
m_iGender = RoleInfo.gender;
@@ -2516,8 +2517,9 @@ namespace BrewMonster
// roleName = Encoding.UTF8.GetString(role.name.ByteArray, 0, role.name.Length);
//}
SetPlayerInfor(new INFO(role.cid, role.crc_e, role.crc_c));
LoadResources();
await SetPlayerModel(UnityGameSession.Instance.GetRoleInfo().occupation,
UnityGameSession.Instance.GetRoleInfo().gender);
UnityGameSession.Instance.GetRoleInfo().gender);
Vector3 pos = new Vector3(role.pos.x, role.pos.y, role.pos.z);
string roleName = Encoding.Unicode.GetString(UnityGameSession.Instance.GetRoleInfo().name.ByteArray);
@@ -2590,12 +2592,11 @@ namespace BrewMonster
m_pWorkMan.StartWork_p1(pWork);
}*/
//m_GndInfo.bOnGround = GroundCheck(out lastGroundHit);
LoadResources();
if (m_pWorkMan == null)
{
return;
}
LoadGfx();
}
@@ -3097,8 +3098,6 @@ namespace BrewMonster
{
if (cooldown_index < 0)
{
// 更新所有装备技能
// Update all equipment skills
for (int i = 0; i < GetEquipSkillNum(); ++i)
{
@@ -3130,8 +3129,6 @@ namespace BrewMonster
}
else
{
// 更新指定技能
// Update specified skill
if (cooldown_index > (int)CoolTimeIndex.GP_CT_SKILL_START)
{
int idSkill = cooldown_index - (int)CoolTimeIndex.GP_CT_SKILL_START;
@@ -6467,10 +6464,6 @@ namespace BrewMonster
return ElementSkill.LearnCondition((uint)idSkill, Info, iLevel);
}
}
}
private void OnMsgHstPressCancel(ECMSG Msg)
{
CECHPWork pCurWork = null;
+5 -3
View File
@@ -58,8 +58,7 @@ public class CECUIManager : MonoSingleton<CECUIManager>
{
EventBus.Unsubscribe<CECHostPlayer.NPCINFO>(ShowUINPC);
EventBus.Unsubscribe<NPCDiedEvent>(TryHideUINPC);
EventBus.Subscribe<MessageBoxEvent>(OnMessageBox);
EventBus.Unsubscribe<MessageBoxEvent>(OnMessageBox);
}
private void ShowUINPC(CECHostPlayer.NPCINFO obj)
@@ -103,21 +102,24 @@ public class CECUIManager : MonoSingleton<CECUIManager>
Debug.LogWarning($"Không tìm thấy UI {componentName} đã spawn trong canvasDlg. Type found: {(type != null ? type.FullName : "null")}");
}
public void ShowMessageBox(string title, string message)
public CDlgMessageBox ShowMessageBox(string title, string message)
{
var msgBox = GetInGameUIMan().GetDialog("DlgMessageBox") as CDlgMessageBox;
if (msgBox != null)
{
msgBox.ShowMessageBox(title, message);
return msgBox;
}
else
{
Debug.LogError("DlgMessageBox not found in InGameUIMan");
}
return null;
}
private void OnMessageBox(MessageBoxEvent messageBoxEvent)
{
BMLogger.LogError("CECUIManager OnMessageBox called");
int iRetVal = messageBoxEvent.iRetVal;
AUIDialog pDlg = messageBoxEvent.pDlg;
File diff suppressed because one or more lines are too long