diff --git a/Assets/AddressableAssetsData/AddressableAssetSettings.asset b/Assets/AddressableAssetsData/AddressableAssetSettings.asset index 8b396d98ce..6580a711c4 100644 --- a/Assets/AddressableAssetsData/AddressableAssetSettings.asset +++ b/Assets/AddressableAssetsData/AddressableAssetSettings.asset @@ -15,7 +15,7 @@ MonoBehaviour: m_DefaultGroup: 712e3991f28e549e7a56ee582a977810 m_currentHash: serializedVersion: 2 - Hash: 00000000000000000000000000000000 + Hash: 1a24bf14330c3dc4032d1cb56ad49cf2 m_OptimizeCatalogSize: 0 m_BuildRemoteCatalog: 0 m_CatalogRequestsTimeout: 0 diff --git a/Assets/PerfectWorld/Scripts/GameData/ExpTypes.cs b/Assets/PerfectWorld/Scripts/GameData/ExpTypes.cs index aa4482b4b9..f0d47051ee 100644 --- a/Assets/PerfectWorld/Scripts/GameData/ExpTypes.cs +++ b/Assets/PerfectWorld/Scripts/GameData/ExpTypes.cs @@ -4988,7 +4988,7 @@ namespace BrewMonster public int[] num_evolve; // evolution items [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] - public int[,] num_inherit; // inheritance parameters + public int[] num_inherit; // inheritance parameters [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] public int[] num_rand_skill; // random skill parameters diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_HPWork.cs b/Assets/PerfectWorld/Scripts/Managers/EC_HPWork.cs index 74af8952da..d96195517b 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_HPWork.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_HPWork.cs @@ -608,7 +608,7 @@ namespace BrewMonster.Scripts case CECHPWork.Host_work_ID.WORK_FREEFALL: pWork = new CECHPWorkFall(this); break; //case CECHPWork.Host_work_ID.WORK_SIT: pWork = new CECHPWorkSit(this); break; case CECHPWork.Host_work_ID.WORK_PICKUP: pWork = new EC_HPWorkPick(this); break; - //case CECHPWork.Host_work_ID.WORK_CONCENTRATE: pWork = new CECHPWorkConcentrate(this); break; + case CECHPWork.Host_work_ID.WORK_CONCENTRATE: pWork = new CECHPWorkConcentrate(this); break; //case CECHPWork.Host_work_ID.WORK_REVIVE: pWork = new CECHPWorkRevive(this); break; case CECHPWork.Host_work_ID.WORK_FLASHMOVE: pWork = new CECHPWorkFMove(this); break; //case CECHPWork.Host_work_ID.WORK_BEBOUND: pWork = new CECHPWorkBeBound(this); break; diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_HPWorkConcentrate.cs b/Assets/PerfectWorld/Scripts/Managers/EC_HPWorkConcentrate.cs new file mode 100644 index 0000000000..c3c170549f --- /dev/null +++ b/Assets/PerfectWorld/Scripts/Managers/EC_HPWorkConcentrate.cs @@ -0,0 +1,60 @@ +using BrewMonster.Scripts; +using UnityEngine; + +namespace BrewMonster.Scripts +{ + public class CECHPWorkConcentrate : CECHPWork + { + int m_iDoWhat; + + public CECHPWorkConcentrate(int iWorkID, CECHPWorkMan pWorkMan) : base(Host_work_ID.WORK_CONCENTRATE, pWorkMan) + { + m_dwMask = Work_mask.MASK_CONCENTRATE; + m_dwTransMask = Work_mask.MASK_STAND; + m_iDoWhat = (int)eDO_PET.DO_SUMMONPET; + + Reset(); + } + + public override bool CopyData(CECHPWork pWork) + { + if (base.CopyData(pWork)) + { + return false; + } + CECHPWorkConcentrate pSrc = (CECHPWorkConcentrate)pWork; + m_iDoWhat = pSrc.m_iDoWhat; + + return true; + } + + public override void Reset() + { + base.Reset(); + } + + public override bool Tick(float dwDeltaTime) + { + base.Tick(Time.fixedUnscaledTime); + return true; + } + + protected override void OnFirstTick() + { + + } + + public enum eDO_PET + { + DO_SUMMONPET = 0, // Summon pet + DO_RECALLPET, + DO_BANISHPET, + DO_RESTOREPET, + DO_UNKNOWN, + }; + + // Set / Get do what flag + public void SetDoWhat(int iDoWhat) { m_iDoWhat = iDoWhat; } + public int GetDoWhat() { return m_iDoWhat; } + } +} diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_HPWorkConcentrate.cs.meta b/Assets/PerfectWorld/Scripts/Managers/EC_HPWorkConcentrate.cs.meta new file mode 100644 index 0000000000..6d4e7c1a5d --- /dev/null +++ b/Assets/PerfectWorld/Scripts/Managers/EC_HPWorkConcentrate.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 126c0de4ea802b14fa540a689899e007 \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs index 1e90bc32f8..45600ccafb 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs @@ -2275,5 +2275,34 @@ namespace CSNetwork.GPDataType public int idSkill; public byte byPVPMask; }; + + // Pet type + public enum ePet_type + { + GP_PET_CLASS_INVALID = -1, + GP_PET_CLASS_MOUNT = 0, // Æï³è + GP_PET_CLASS_COMBAT, // Õ½¶·³èÎï + GP_PET_CLASS_FOLLOW, // ¸úËæ³èÎï + GP_PET_CLASS_SUMMON, // ÕÙ»½³èÎï + GP_PET_CLASS_PLANT, // Ö²ÎֻÊÇΪÁ˺ͷþÎñÆ÷µÄÖµ±£³ÖÒ»Ö£¬¿Í»§¶ËûÓÐÓõ½ + GP_PET_CLASS_EVOLUTION, // ½ø»¯³è + GP_PET_CLASS_MAX, + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct cmd_pet_room + { + public ushort count; + // ÖØ¸´ count ´Î + // int index; + // info_pet data; + }; + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct cmd_plant_pet_disapper + { + public int plant_nid; + public char reason; // 0 ËÀÍö£¬1 ÊÙÃüµ½£¬2 ³¬³ö·¶Î§£¬3 ×Ô±¬£¬4 ÊýÁ¿³¬³ö×éÉÏÏÞ + }; } diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs index 79a939192b..7a1c16de60 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs @@ -1520,7 +1520,7 @@ namespace CSNetwork public void SendCmdPetCtrl(int idTarget, int cmd, object pParamBuf, int iParamLen) { - m_CmdCache.SendCmdPetCtrl(idTarget, cmd, pParamBuf, iParamLen); + m_CmdCache.SendCmdPetCtrl(idTarget, cmd, (byte[])pParamBuf, iParamLen); } } } \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/Pet/EC_PetCorral.cs b/Assets/PerfectWorld/Scripts/Pet/EC_PetCorral.cs index 9f3dfbb162..7055f94b85 100644 --- a/Assets/PerfectWorld/Scripts/Pet/EC_PetCorral.cs +++ b/Assets/PerfectWorld/Scripts/Pet/EC_PetCorral.cs @@ -1,5 +1,7 @@ using BrewMonster.Network; +using BrewMonster.Scripts.Managers; using BrewMonster.Scripts.Skills; +using BrewMonster.UI; using CSNetwork.GPDataType; using ModelRenderer.Scripts.GameData; using System; @@ -47,7 +49,7 @@ namespace BrewMonster.Scripts.Pet int GetLifeTimeLeft() { return m_lifeTimeLeft; } // ʣʱ䣨룩 int m_tid; // ģID - int m_nid; // ID + public int m_nid; // ID int m_lifeTime; // ʱ䣨0Ϊ int m_lifeTimeLeft; // ʱ䵹ʱ float m_HPFactor; // ǰ HP ռ HP ı @@ -107,8 +109,376 @@ namespace BrewMonster.Scripts.Pet PET_EVOLVE_CONFIG m_pDBEvoConfig; + public CECPetCorral() + { + m_iActivePet = -1; + m_iPetSlotNum = 1; + m_iMoveMode = (int)ePet_MovingMode.MOVE_FOLLOW; + m_iAttackMode = (int)ePet_AttackingMode.ATK_DEFENSE; + m_nidPet = 0; + m_iPetLifeTime = 0; + m_bHasInit = false; + + elementdataman pDB = ElementDataManProvider.GetElementDataMan(); + DATA_TYPE DataType = new DATA_TYPE(); + int index = 0; + uint id = pDB.get_data_id(ID_SPACE.ID_SPACE_CONFIG, index, ref DataType); + while(id != 0) + { + if(DataType == DATA_TYPE.DT_PET_EVOLVE_CONFIG) + { + m_pDBEvoConfig = (PET_EVOLVE_CONFIG)pDB.get_data_ptr(id, ID_SPACE.ID_SPACE_CONFIG, ref DataType); + break; + } + index += 1; + id = pDB.get_data_id(ID_SPACE.ID_SPACE_CONFIG, index, ref DataType); + } + } + + public bool Tick(float dwDeltaTime) + { + for (int i = 0; i < m_iPetSlotNum; i++) + { + if (m_aPetSlots[i] != null) + m_aPetSlots[i].Tick(dwDeltaTime); + } + + for (int j = (int)ePet_MaxSlot.MAX_SLOTNUM; j < (int)ePet_MaxSlot.MAX_SLOTNUM2; ++j) + { + if (m_aPetSlots[j] != null) + m_aPetSlots[j].Tick(dwDeltaTime); + } + + for (int k = 0; k < GetPlantCount(); ++k) + { + CECPlantPetData? pPlant = GetPlant(k); + if (pPlant != null) + pPlant?.Tick(dwDeltaTime); + } + + return true; + } + + public int GetPlantCount() + { + return m_Plants.Count; + } + + CECPlantPetData? GetPlant(int index) + { + CECPlantPetData? pPlant = GetPlantImpl(index); + return pPlant; + } + + CECPlantPetData? GetPlantImpl(int index) + { + if (index >= 0 && index= m_iPetSlotNum && (iSlot < (int)ePet_MaxSlot.MAX_SLOTNUM || iSlot >= (int)ePet_MaxSlot.MAX_SLOTNUM2)) + { + //ASSERT(iSlot >= 0 && iSlot < m_iPetSlotNum); + return false; + } + + if (m_aPetSlots[iSlot] != null) + { + //ASSERT(!m_aPetSlots[iSlot]); + //delete m_aPetSlots[iSlot]; + m_aPetSlots[iSlot] = null; + } + + CECPetData pPet = new CECPetData(); + if (pPet == null) + { + //glb_ErrorOutput(ECERR_NOTENOUGHMEMORY, "CECPetCorral::AddPet", __LINE__); + return false; + } + + pPet.Init(Info); + + m_aPetSlots[iSlot] = pPet; + + return true; + } + + // Free a pet + void FreePet(int iSlot, int idPet) + { + if (iSlot < 0 || iSlot >= m_iPetSlotNum && (iSlot < (int)ePet_MaxSlot.MAX_SLOTNUM || iSlot >= (int)ePet_MaxSlot.MAX_SLOTNUM2)) + { + //ASSERT(iSlot >= 0 && iSlot < m_iPetSlotNum); + return; + } + + CECPetData pPet = m_aPetSlots[iSlot]; + if (pPet != null) + { + //ASSERT(pPet.GetTemplateID() == idPet); + //delete pPet; + m_aPetSlots[iSlot] = null; + } + } + + // Remove all pets + void RemoveAll() + { + for (int i = 0; i < (int)ePet_MaxSlot.MAX_SLOTNUM2; i++) + { + if (m_aPetSlots[i] != null) + { + //delete m_aPetSlots[i]; + m_aPetSlots[i] = null; + } + } + + m_Plants.Clear(); + } + // Update pets data in corral + void UpdatePets(cmd_pet_room cmd, byte[] data) + { + byte[] pData = new byte[data.Length - Marshal.SizeOf(cmd)]; + Buffer.BlockCopy(data, (Marshal.SizeOf(cmd)), pData, 0, pData.Length); + int idx = Marshal.SizeOf(cmd); + int iSlot = 0; + byte[] tempBuffer = null; + info_pet pInfo; + for (int i = 0; i < cmd.count; i++) + { + tempBuffer = new byte[Marshal.SizeOf()]; + Buffer.BlockCopy(pData, idx, tempBuffer, 0, Marshal.SizeOf()); + iSlot = BitConverter.ToInt32(tempBuffer); + //pData += sizeof(int); + idx += Marshal.SizeOf(); + + tempBuffer = new byte[Marshal.SizeOf()]; + Buffer.BlockCopy(pData, idx, tempBuffer, 0, Marshal.SizeOf()); + //const info_pet* pInfo = (const info_pet*)pData; + pInfo = GPDataTypeHelper.FromBytes(tempBuffer); + //pData += sizeof(info_pet); + idx += Marshal.SizeOf(); + + if (iSlot < 0 || iSlot >= m_iPetSlotNum && (iSlot < (int)ePet_MaxSlot.MAX_SLOTNUM || iSlot >= (int)ePet_MaxSlot.MAX_SLOTNUM2)) + { + if(iSlot >= 0 && iSlot < m_iPetSlotNum) + { + //TODO: print out + + } + continue; + } + + // Free old pet + if (m_aPetSlots[iSlot] != null) + { + m_aPetSlots[iSlot] = null; + } + + AddPet(iSlot, pInfo); + } + } + + // Magnify pet slots + void MagnifyPetSlots(int iNewNum) + { + if (iNewNum > (int)ePet_MaxSlot.MAX_SLOTNUM || m_iPetSlotNum > iNewNum) + { + //ASSERT(iNewNum <= MAX_SLOTNUM && m_iPetSlotNum <= iNewNum); + return; + } + + m_iPetSlotNum = iNewNum; + } + // Check whether corral has empty slots + int GetEmptySlotNum() + { + int iCount = 0; + + for (int i = 0; i < m_iPetSlotNum; i++) + { + if (m_aPetSlots[i] == null) + iCount++; + } + + return iCount; + } + // Get number of current active pet slots + public int GetPetSlotNum() { return m_iPetSlotNum; } + // Get pet data of specified slot + public CECPetData GetPetData(int iSlot) + { + if (iSlot < 0 || iSlot >= (int)ePet_MaxSlot.MAX_SLOTNUM2) + { + //ASSERT(iSlot >= 0 && iSlot < MAX_SLOTNUM2); + return null; + } + + return m_aPetSlots[iSlot]; + } + + // Get current active pet's index + public int GetActivePetIndex() { return m_iActivePet; } + // Set current active pet's index + void SetActivePetIndex(int iIndex) { m_iActivePet = iIndex; } + // Get current active pet's data + CECPetData GetActivePet() + { + if (m_iActivePet >= 0 && m_iActivePet < (int)ePet_MaxSlot.MAX_SLOTNUM2) + return m_aPetSlots[m_iActivePet]; + else + return null; + } + + void SetActivePetNPCID(int nid) { m_nidPet = nid; } + + // ѯõǰʱ + int GetActivePetLifeTime() { return m_iPetLifeTime; } + void SetActivePetLifetime(int lifetime) { m_iPetLifeTime = lifetime; } + + // Get / Set moving mode + int GetMoveMode() { return m_iMoveMode; } + void SetMoveMode(int iMode) { m_iMoveMode = iMode; } + // Get / Set attacking mode + int GetAttackMode() { return m_iAttackMode; } + void SetAttackMode(int iMode) { m_iAttackMode = iMode; } + // Get / Set init flag + bool HasInit() { return m_bHasInit; } + void SetHasInit(bool bFlag) { m_bHasInit = bFlag; } + + void PlantPetEnter(cmd_summon_plant_pet rhs) + { + CECPlantPetData plant = new CECPlantPetData(); + plant.Init(rhs); + m_Plants.Add(plant); + } + void PlantPetDisappear(cmd_plant_pet_disapper rhs) + { + CECPlantPetData? pPlant = GetPlantByID(rhs.plant_nid); + if (pPlant != null) + m_Plants.Remove(pPlant.Value); + } + void PlantPetInfo(cmd_plant_pet_hp_notify rhs) + { + CECPlantPetData? pPlant = GetPlantByID(rhs.plant_nid); + if (pPlant != null) + pPlant.Value.Info(rhs); + } + + int GetPlantIndexByID(int nid) + { + for (int i = 0; i < (int)m_Plants.Count; ++i) + { + CECPlantPetData plant = m_Plants[i]; + if (plant.m_nid == nid) + return i; + } + return -1; + } + + CECPlantPetData? GetPlantByID(int nid) + { + return GetPlantByIDImpl(nid); + } + + PET_EVOLVE_CONFIG GetPetEvoConfig() + { + return m_pDBEvoConfig; + } + + bool CheckRebuildPetItemCond(int iPetIndex, int iSel, int type) // ѡƷţtype0(),1(Ը),2(ϴϵ) + { + CECPetData pPet = GetPetData(iPetIndex); + if (pPet == null) return false; + + //int(*p)[2] = NULL; + int[,] p = null; + if (type == 0) // + { + if(pPet.GetPetEssence() != null) + { + p = new int[3, 2]; + var num_evolve = GetPetEvoConfig().cost[pPet.GetPetEssence().Value.cost_index].num_evolve; + for(int r = 0; r < p.GetLength(0); r++) + { + for(int c = 0; c < p.GetLength(1); c++) + { + p[r, c] = num_evolve[r * p.GetLength(1) + c]; + } + } + } + } + else if (type == 1) // Ը + { + if (pPet.GetPetEssence() != null) + { + p = new int[3, 2]; + var num_rand_skill = GetPetEvoConfig().cost[pPet.GetPetEssence().Value.cost_index].num_rand_skill; + for (int r = 0; r < p.GetLength(0); r++) + { + for (int c = 0; c < p.GetLength(1); c++) + { + p[r, c] = num_rand_skill[r * p.GetLength(1) + c]; + } + } + } + } + else if (type == 2) // ϴ + { + if (pPet.GetPetEssence() != null) + { + p = new int[3, 2]; + var num_inherit = GetPetEvoConfig().cost[pPet.GetPetEssence().Value.cost_index].num_inherit; + for (int r = 0; r < p.GetLength(0); r++) + { + for (int c = 0; c < p.GetLength(1); c++) + { + p[r, c] = num_inherit[r * p.GetLength(1) + c]; + } + } + } + } + else + { + return false; + } + + CECGameUIMan pGameUI = EC_Game.GetGameRun().GetUIManager().GetInGameUIMan(); + if (pGameUI == null) return false; + + EC_Inventory pack = EC_Game.GetGameRun().GetHostPlayer().GetPack(); + if (pack.GetItemTotalNum(37401) < p[iSel,0]) + { + // TO DO: fix later + //pGameUI.MessageBox("", pGameUI.GetStringFromTable(10110), MB_OK, A3DCOLORRGBA(255, 255, 255, 160)); + return false; // 鲻 + } + if (pack.GetItemTotalNum(12980) < p[iSel,1]) + { + // TO DO: fix later + //pGameUI.MessageBox("", pGameUI.GetStringFromTable(10111), MB_OK, A3DCOLORRGBA(255, 255, 255, 160)); + return false; // Ǭʯ + } + + return true; + } + + CECPlantPetData? GetPlantByIDImpl(int nid) + { + foreach (var plant in m_Plants) + { + if (plant.m_nid == nid) + return plant; + } + return null; + } } public class CECPetData @@ -207,7 +577,7 @@ namespace BrewMonster.Scripts.Pet m_tid = 0; m_tidVis = 0; m_idEgg = 0; - m_iClass = GP_PET_CLASS_INVALID; + m_iClass = (int)ePet_type.GP_PET_CLASS_INVALID; m_fHPFactor = 0.0f; m_fMPFactor = 0.0f; m_iLevel = 0; @@ -235,7 +605,7 @@ namespace BrewMonster.Scripts.Pet } // Initialize object - bool Init(info_pet Info) + public bool Init(info_pet Info) { m_iIntimacy = Info.honor_point; m_iHunger = Info.hunger; @@ -258,7 +628,7 @@ namespace BrewMonster.Scripts.Pet DATA_TYPE DataType = new DATA_TYPE(); if (m_strName.Length == 0) { - object pe = pDB.get_data_ptr((uint)m_tid, ID_SPACE.ID_SPACE_ESSENCE,ref DataType); + object pe = pDB.get_data_ptr((uint)m_tid, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); if (pe != null) { PET_ESSENCE petEs = (PET_ESSENCE)pe; @@ -307,7 +677,7 @@ namespace BrewMonster.Scripts.Pet if (m_pDBEssence != null && (skill_id > 0)) { - if(skill_id == m_pDBEssence.Value.specific_skill) + if (skill_id == m_pDBEssence.Value.specific_skill) { m_iSpecialSkillIndex = i; continue; @@ -341,8 +711,8 @@ namespace BrewMonster.Scripts.Pet return true; } - // Add experience - public int AddExp(int iExp) + // Add experience + public int AddExp(int iExp) { m_iExp += iExp; return m_iExp; @@ -357,7 +727,7 @@ namespace BrewMonster.Scripts.Pet // Get properties public int GetIntimacy() { return m_iIntimacy; } - public void SetIntimacy(int iValue) { m_iIntimacy = iValue; } + public void SetIntimacy(int iValue) { m_iIntimacy = iValue; } public int GetHunger() { return m_iHunger; } public void SetHunger(int iValue) { m_iHunger = iValue; } public int GetTemplateID() { return m_tid; } @@ -367,7 +737,7 @@ namespace BrewMonster.Scripts.Pet public int GetLevel() { return m_iLevel; } public ushort GetColor() { return m_color; } public bool IsBind() { return m_isBind; } - public bool CanWebTrade(){ return m_canWebTrade; } + public bool CanWebTrade() { return m_canWebTrade; } public int GetExp() { return m_iExp; } public int GetSkillPt() { return m_iSkillPt; } public string GetName() { return m_strName; } @@ -535,11 +905,11 @@ namespace BrewMonster.Scripts.Pet // ȡʾ public ROLEEXTPROP GetExtendProps() { return m_ExtProps; } - public void SetExtendProps(ROLEEXTPROP prop) { m_ExtProps = prop; } + public void SetExtendProps(ROLEEXTPROP prop) { m_ExtProps = prop; } public bool IsFollowPet() { - if(m_pDBEssence == null) + if (m_pDBEssence == null) { return false; } @@ -586,13 +956,13 @@ namespace BrewMonster.Scripts.Pet return m_pDBEssence?.id_type == 37698; } - public int GetAtkRation() {return m_iAtkRation;} - int GetDefRation() { return m_iDefRation;} - int GetHpRation() { return m_iHpRation;} - int GetAtkLvlRation() { return m_iAtkLvlRation;} - int GetDefLvlRation() { return m_iDefLvlRation;} - int GetNatureID() { return m_iNature;} - public string GetNature() + public int GetAtkRation() { return m_iAtkRation; } + int GetDefRation() { return m_iDefRation; } + int GetHpRation() { return m_iHpRation; } + int GetAtkLvlRation() { return m_iAtkLvlRation; } + int GetDefLvlRation() { return m_iDefLvlRation; } + int GetNatureID() { return m_iNature; } + public string GetNature() { elementdataman pDB = ElementDataManProvider.GetElementDataMan(); DATA_TYPE DataType = new DATA_TYPE(); @@ -653,20 +1023,94 @@ namespace BrewMonster.Scripts.Pet UnityGameSession.c2s_CmdPetCtrl(idTarget, 4, param, Marshal.SizeOf(param)); } -void OnAutoCastOver(int skill_id); -void OnPetDead(); -bool CanEvolution()const ; -int GetEvolutionID() const ; -static int GetEvolutionID(int pet_tid); + public void OnAutoCastOver(int skill_id) + { + int index = m_aAutoSkills.IndexOf(skill_id); + if (index != -1) + m_aAutoSkills.RemoveAt(index); + } + public void OnPetDead() + { + m_aAutoSkills.Clear(); + } -PET_ESSENCE* GetPetEssence() { return m_pDBEssence; } + public bool CanEvolution() + { + if (m_pDBEssence == null) + { + return false; + } + return m_pDBEssence?.id_pet_egg_evolved != 0; + } + public int GetEvolutionID() + { + if (m_pDBEssence == null) return 0; -int GetMaxExp(); + DATA_TYPE DataType = new DATA_TYPE(); + object pDB = ElementDataManProvider.GetElementDataMan().get_data_ptr((uint)m_pDBEssence?.id_pet_egg_evolved, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + if (pDB == null) + { + return 0; + } + PET_EGG_ESSENCE pet = (PET_EGG_ESSENCE)pDB; + return pet.id_pet; + } + public static int GetEvolutionID(int pet_tid) + { + elementdataman pDB = ElementDataManProvider.GetElementDataMan(); + DATA_TYPE DataType = new DATA_TYPE(); + object pet = pDB.get_data_ptr((uint)pet_tid, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + if (pet != null) + { + PET_ESSENCE pESS = (PET_ESSENCE)pet; + pet = pDB.get_data_ptr(pESS.id_pet_egg_evolved, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + if (pet != null) + { + PET_EGG_ESSENCE pEgg = (PET_EGG_ESSENCE)pet; + return pEgg.id_pet; + } + } + return 0; + } + public PET_ESSENCE? GetPetEssence() { return m_pDBEssence; } + public int GetMaxExp() + { + DATA_TYPE DataType = new DATA_TYPE(); + object pDB = ElementDataManProvider.GetElementDataMan().get_data_ptr(592, ID_SPACE.ID_SPACE_CONFIG, ref DataType); + if (pDB == null) + { + return 0; + } + PLAYER_LEVELEXP_CONFIG PetLevelUpExp = (PLAYER_LEVELEXP_CONFIG)pDB; + return PetLevelUpExp.exp[m_iLevel - 1]; + } -bool Tick(DWORD dwDeltaTime); -}; + public bool Tick(float dwDeltaTime) + { + // Update cool time + int i = 0; + for (i = 0; i < (int)eGP_PET_SKILL.GP_PET_SKILL_NUM; i++) + { + PETSKILL s = m_aSkills[i]; + if (s.idSkill != 0 && s.iCoolMax != 0 && s.iCoolCnt != 0) + { + s.iCoolCnt -= (int)(dwDeltaTime * 1000); + AAssist.a_ClampFloor(ref s.iCoolCnt, 0); + } + } + + // Auto cast skill + if (m_cntAutoSkill.IncCounter(dwDeltaTime)) + { + CastAutoSkill(); + m_cntAutoSkill.Reset(); + } + + return true; + } + } } diff --git a/Assets/PerfectWorld/Scripts/UI/Dialogs/CDlgPetList.cs b/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgPetList.cs similarity index 51% rename from Assets/PerfectWorld/Scripts/UI/Dialogs/CDlgPetList.cs rename to Assets/PerfectWorld/Scripts/UI/Dialogs/DlgPetList.cs index 3c475b9c95..c341480815 100644 --- a/Assets/PerfectWorld/Scripts/UI/Dialogs/CDlgPetList.cs +++ b/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgPetList.cs @@ -1,3 +1,6 @@ +using BrewMonster.Scripts.Pet; +using CSNetwork.GPDataType; +using ModelRenderer.Scripts.GameData; using System; using TMPro; using UnityEngine; @@ -20,7 +23,7 @@ namespace BrewMonster.UI [SerializeField] private TextMeshProUGUI[] m_pLab_Level = new TextMeshProUGUI[CDLGPETLIST_SLOT_MAX]; [SerializeField] private TextMeshProUGUI[] m_pTxt_Name = new TextMeshProUGUI[CDLGPETLIST_SLOT_MAX]; [SerializeField] private TextMeshProUGUI[] m_pTxt_Level = new TextMeshProUGUI[CDLGPETLIST_SLOT_MAX]; - + int m_nPageIndex; public void OnInitDialog() { @@ -53,86 +56,93 @@ namespace BrewMonster.UI //{ // m_pBtn_Page[i] = NULL; // DDX_Control(AString().Format("Btn_Page%d", i + 1), m_pBtn_Page[i]); - // m_pBtn_Page[i]->SetPushed(false); + // m_pBtn_Page[i].SetPushed(false); //} //m_nPageIndex = 0; - //m_pBtn_Page[0]->SetPushed(true); + //m_pBtn_Page[0].SetPushed(true); //return true; } + bool IsPetDye(int nSlot) + { + return nSlot >= 0 + && GetGameUIMan().m_pDlgPetDye.IsShow() + && GetGameUIMan().m_pDlgPetDye.GetPetSlot() == nSlot; + } + void UpdateList() { string strText = ""; - CECPetCorral pPetCorral = GetHostPlayer()->GetPetCorral(); - elementdataman* pDB = GetGame()->GetElementDataMan(); - DATA_TYPE DataType; + CECPetCorral pPetCorral = GetHostPlayer().GetPetCorral(); + elementdataman pDB = ElementDataManProvider.GetElementDataMan(); + DATA_TYPE DataType = new DATA_TYPE(); int i; for (i = 0; i < CDLGPETLIST_SLOT_MAX; i++) { int nPetSlot = i + m_nPageIndex * CDLGPETLIST_SLOT_MAX; - if (nPetSlot < pPetCorral->GetPetSlotNum()) + if (nPetSlot < pPetCorral.GetPetSlotNum()) { - m_pLab_Level[i]->SetColor(A3DCOLORRGB(255, 203, 74)); - m_pLab_Name[i]->SetColor(A3DCOLORRGB(255, 203, 74)); + m_pLab_Level[i].color = new Color(255f / 255f, 203f / 255f, 74f / 255f); + m_pLab_Name[i].color = new Color(255f / 255f, 203f / 255f, 74f / 255f); } else { - m_pLab_Level[i]->SetColor(A3DCOLORRGB(128, 128, 128)); - m_pLab_Name[i]->SetColor(A3DCOLORRGB(128, 128, 128)); + m_pLab_Level[i].color = new Color(128f / 128f, 128f / 128f, 128f / 128f); + m_pLab_Name[i].color = new Color(128f / 128f, 128f / 128f, 128f / 128f); } - CECPetData* pPet = pPetCorral->GetPetData(nPetSlot); - if (pPet) + CECPetData pPet = pPetCorral.GetPetData(nPetSlot); + if (pPet != null) { - bool bEnable = (pPetCorral->GetActivePetIndex() == nPetSlot && GetHostPlayer()->IsOperatingPet() == 0); - m_pBtn_Recall[i]->Enable(bEnable); + bool bEnable = (pPetCorral.GetActivePetIndex() == nPetSlot && GetHostPlayer().IsOperatingPet() == 0); + m_pBtn_Recall[i].enabled = (bEnable); - bEnable = (pPetCorral->GetActivePetIndex() != nPetSlot && GetHostPlayer()->IsOperatingPet() == 0); - m_pBtn_Summon[i]->Enable(bEnable); + bEnable = (pPetCorral.GetActivePetIndex() != nPetSlot && GetHostPlayer().IsOperatingPet() == 0); + m_pBtn_Summon[i].gameObject.SetActive(bEnable); - m_pBtn_Detail[i]->Enable(true); + m_pBtn_Detail[i].gameObject.SetActive(true); - strText.Format(GetStringFromTable(801), pPet->GetLevel()); - m_pTxt_Level[i]->SetText(strText); - m_pTxt_Name[i]->SetText(pPet->GetName()); - if ((pPet->GetClass() == GP_PET_CLASS_COMBAT || pPet->GetClass() == GP_PET_CLASS_EVOLUTION) && pPet->GetHPFactor() == 0.0f || IsPetDye(nPetSlot)) - m_pImg_Icon[i]->SetColor(A3DCOLORRGB(128, 128, 128)); + strText = string.Format(GetStringFromTable(801).Replace("%d", "{0}"), pPet.GetLevel()); + m_pTxt_Level[i].SetText(strText); + m_pTxt_Name[i].SetText(pPet.GetName()); + if ((pPet.GetClass() == (int)ePet_type.GP_PET_CLASS_COMBAT || pPet.GetClass() == (int)ePet_type.GP_PET_CLASS_EVOLUTION) && pPet.GetHPFactor() == 0.0f || IsPetDye(nPetSlot)) + m_pImg_Icon[i].color = new Color(128f/ 255f, 128f / 255f, 128f / 255f); else - m_pImg_Icon[i]->SetColor(A3DCOLORRGB(255, 255, 255)); - m_pImg_Icon[i]->SetData(1); - m_pImg_Icon[i]->SetDataPtr((void*)1); - PET_ESSENCE* pDBEssence = (PET_ESSENCE*)pDB->get_data_ptr(pPet->GetTemplateID(), + m_pImg_Icon[i].SetColor(A3DCOLORRGB(255, 255, 255)); + m_pImg_Icon[i].SetData(1); + m_pImg_Icon[i].SetDataPtr((void*)1); + PET_ESSENCE* pDBEssence = (PET_ESSENCE*)pDB.get_data_ptr(pPet.GetTemplateID(), ID_SPACE_ESSENCE, DataType); if (pDBEssence) { AString strFile; - af_GetFileTitle(pDBEssence->file_icon, strFile); + af_GetFileTitle(pDBEssence.file_icon, strFile); strFile.MakeLower(); - m_pImg_Icon[i]->SetCover(GetGameUIMan()->m_pA2DSpriteIcons[CECGameUIMan::ICONS_INVENTORY], - GetGameUIMan()->m_IconMap[CECGameUIMan::ICONS_INVENTORY][strFile]); + m_pImg_Icon[i].SetCover(GetGameUIMan().m_pA2DSpriteIcons[CECGameUIMan::ICONS_INVENTORY], + GetGameUIMan().m_IconMap[CECGameUIMan::ICONS_INVENTORY][strFile]); } else { - m_pImg_Icon[i]->ClearCover(); - m_pImg_Icon[i]->SetHint(_AL("")); + m_pImg_Icon[i].ClearCover(); + m_pImg_Icon[i].SetHint(_AL("")); } - m_pBtn_Evolution[i]->Show(pPet->GetClass() == GP_PET_CLASS_COMBAT || pPet->GetClass() == GP_PET_CLASS_EVOLUTION); + m_pBtn_Evolution[i].Show(pPet.GetClass() == GP_PET_CLASS_COMBAT || pPet.GetClass() == GP_PET_CLASS_EVOLUTION); } else { - m_pBtn_Summon[i]->Enable(false); - m_pBtn_Recall[i]->Enable(false); - m_pBtn_Detail[i]->Enable(false); - m_pBtn_Evolution[i]->Show(false); - // m_pBtn_Banish[i]->Enable(false); - m_pImg_Icon[i]->SetDataPtr(NULL); - m_pTxt_Level[i]->SetText(_AL("")); - m_pTxt_Name[i]->SetText(_AL("")); - m_pImg_Icon[i]->ClearCover(); - m_pImg_Icon[i]->SetHint(_AL("")); - m_pImg_Icon[i]->SetData(0); + m_pBtn_Summon[i].gameObject.SetActive(false); + m_pBtn_Recall[i].gameObject.SetActive(false); + m_pBtn_Detail[i].gameObject.SetActive(false); + m_pBtn_Evolution[i].Show(false); + // m_pBtn_Banish[i].Enable(false); + m_pImg_Icon[i].SetDataPtr(NULL); + m_pTxt_Level[i].SetText(_AL("")); + m_pTxt_Name[i].SetText(_AL("")); + m_pImg_Icon[i].ClearCover(); + m_pImg_Icon[i].SetHint(_AL("")); + m_pImg_Icon[i].SetData(0); } } } diff --git a/Assets/PerfectWorld/Scripts/UI/Dialogs/CDlgPetList.cs.meta b/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgPetList.cs.meta similarity index 100% rename from Assets/PerfectWorld/Scripts/UI/Dialogs/CDlgPetList.cs.meta rename to Assets/PerfectWorld/Scripts/UI/Dialogs/DlgPetList.cs.meta diff --git a/Assets/Scripts/CECHostPlayer.cs b/Assets/Scripts/CECHostPlayer.cs index 201b41ea80..d0a4f406e0 100644 --- a/Assets/Scripts/CECHostPlayer.cs +++ b/Assets/Scripts/CECHostPlayer.cs @@ -22,6 +22,7 @@ using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; +using UnityEditor.Experimental.GraphView; using UnityEngine; using UnityEngine.UI; using static BrewMonster.Scripts.Managers.EC_Inventory; @@ -681,15 +682,15 @@ namespace BrewMonster // 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)); + 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 (pSkill && (pSkill.GetCommonCoolDown() & (1 << (pCmd.cooldown_index - GP_CT_SKILLCOMMONCOOLDOWN0)))) + pSkill.StartCooling(GetCoolTime(pCmd.cooldown_index), GetCoolTime(pCmd.cooldown_index)); }*/ } @@ -734,7 +735,7 @@ namespace BrewMonster } /* else if (pSkill = CECComboSkillState::Instance().GetInherentSkillByID(idSkill)) { - pSkill->StartCooling(pCmd->cooldown_time, pCmd->cooldown_time); + pSkill.StartCooling(pCmd.cooldown_time, pCmd.cooldown_time); }*/ else if (GetEquipSkillByID(idSkill) == null) { @@ -6885,5 +6886,30 @@ namespace BrewMonster // Get pet corral object public CECPetCorral GetPetCorral() { return m_pPetCorral; } + + /* Is host operating pet ? + return value: + + 0: host doesn't operating pet. + 1: host is summoning pet. + 2: host is recalling pet. + 3: host is banishing pet. + */ + public int IsOperatingPet() + { + CECHPWorkConcentrate pWork = (m_pWorkMan.GetRunningWork(CECHPWork.Host_work_ID.WORK_CONCENTRATE)) as CECHPWorkConcentrate; + if (pWork != null) + { + if (pWork.GetDoWhat() == (int)CECHPWorkConcentrate.eDO_PET.DO_SUMMONPET) + return 1; + else if (pWork.GetDoWhat() == (int)CECHPWorkConcentrate.eDO_PET.DO_RECALLPET) + return 2; + else if (pWork.GetDoWhat() == (int)CECHPWorkConcentrate.eDO_PET.DO_BANISHPET) + return 3; + else if (pWork.GetDoWhat() == (int)CECHPWorkConcentrate.eDO_PET.DO_RESTOREPET) + return 4; + } + return 0; + } } }