using Game; using ProtoCSStruct; using Sog; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Game { public class RolePropUtil { private static void RecalRoleProp(ref DBRoleData roleData, RoleProp roleProp) { roleProp.Clear(); var mgr = GameServerUtils.GetEventHandlerMgr(); if (mgr.TriggerGetPlayerModuleProps != null) { mgr.TriggerGetPlayerModuleProps(ref roleData, roleProp); } roleProp.CalcFinal(); roleProp.ToPropView(ref roleData.Knight.PropView); } public static void RecalRoleProp(PlayerOnGame player, bool sendNotify= false) { RoleProp heroProp = player.knight.props; if (heroProp == null) { heroProp = new RoleProp(); player.knight.props = heroProp; } RolePropUtil.RecalRoleProp(ref player.RoleData, heroProp); if (sendNotify) { ref var notify = ref CSHeroPropChgNotify.Parser.GetMessage(); notify.Clear(); notify.DescId = player.RoleData.Knight.DbHero.DescId; //var notify = new CSHeroPropChgNotify { DescId = player.RoleData.Knight.DbHero.DescId }; heroProp.ToClienNotify(ref notify); player.SendToClient((int)CSGameMsgID.HeroPropChgNotify, ref notify); } CalcPower(player); } public static long CalcPower(RoleProp cprop) { //计算战斗力 cprop.CalcFinal(true); cprop.SetDefaultValue(); long atk = cprop.GetPropFinal(PropertyDef.AtkFixedIncrease); int k1 = CommParamDescMgr.Instance.CombatK1.int_val; long power = cprop.CalcPower(atk, CommParamDescMgr.Instance.CombatB1.int_val, CommParamDescMgr.Instance.CombatB2.int_val, CommParamDescMgr.Instance.CombatB3.int_val, k1, CommParamDescMgr.Instance.CombatK2.int_val, CommParamDescMgr.Instance.CombatK3.int_val, CommParamDescMgr.Instance.CombatK4.int_val, CommParamDescMgr.Instance.CombatK5.int_val, CommParamDescMgr.Instance.CombatK6.int_val, CommParamDescMgr.Instance.CombatK7.int_val, CommParamDescMgr.Instance.CombatK8.int_val, CommParamDescMgr.Instance.CombatK9.int_val, CommParamDescMgr.Instance.CombatK10.int_val, CommParamDescMgr.Instance.CombatK11.int_val, CommParamDescMgr.Instance.CombatB4.int_val, CommParamDescMgr.Instance.CombatB5.int_val); return power; } public static void CalcPower(PlayerOnGame player) { //计算战斗力 long opwer = player.RoleBase.Power; RoleProp cprop = new RoleProp(player.knight.props); long power = CalcPower(cprop); player.RoleBase.Power = power; if (opwer != power) { PlayerNotify.NotifyPlayerPowerChange(player, 0, power - opwer); PopPackageSvc.TriggerPopPackage(player,PackPopType.CombatPower); } } public static int GetWeaponK(WeaponType type) { switch (type) { case WeaponType.SMG: return CommParamDescMgr.Instance.CombatK1SMG.int_val; case WeaponType.AR: return CommParamDescMgr.Instance.CombatK1AR.int_val; case WeaponType.LMG: return CommParamDescMgr.Instance.CombatK1LMG.int_val; case WeaponType.SG: return CommParamDescMgr.Instance.CombatK1SG.int_val; case WeaponType.SR: return CommParamDescMgr.Instance.CombatK1SR.int_val; case WeaponType.RPG: return CommParamDescMgr.Instance.CombatK1RPG.int_val; } return 0; } } }