//using System; //using Sog; //using ProtoCSStruct; //using System.Linq; //namespace Battle //{ // public static class BattleHeroExt // { // // 是否可行动状态 // public static bool IsActiveState(this BattleHero hero) // { // return ! hero.isDead && ! hero.IsStun(); // } // // 是否行动过 // public static bool IsActed(this BattleHero hero) // { // return hero.actionRound >= hero.Battle.round; // } // public static bool IsStun(this BattleHero hero) // { // return hero.stunRound > 0 && hero.stunRound >= hero.Battle.round; // } // public static int GetHpRate(this BattleHero hero) // { // long nowHp = hero.prop.GetValueNoCheck(CSPropIDType.Hp); // long maxHp = hero.prop.GetValueNoCheck(CSPropIDType.HpMax); // return (int)(nowHp * 1000 / maxHp); // } // public static int GetHpLoseRate(this BattleHero hero) // { // long nowHp = hero.prop.GetValueNoCheck(CSPropIDType.Hp); // long maxHp = hero.prop.GetValueNoCheck(CSPropIDType.HpMax); // return (int)((maxHp - nowHp) * 1000 / maxHp); // } // public static int GetDefUpRate(this BattleHero hero) // { // if(hero.startPropDef <= 0) // { // hero.Battle.Error("BattleHeroExt.GetDefUpRate error startdef {0} {1}", hero.objId, hero.DescId); // return 0; // } // long nowDef = hero.prop.GetValueNoCheck(CSPropIDType.Def); // return (int)((nowDef - hero.startPropDef) * 1000 / hero.startPropDef); // } // public static long GetHp(this BattleHero hero) // { // return hero.prop.GetValueNoCheck(CSPropIDType.Hp); // } // public static long GetHpMax(this BattleHero hero) // { // return hero.prop.GetValueNoCheck(CSPropIDType.HpMax); // } // //获取保底的攻击力,最小为1 // public static long GetMinimumAtk(this BattleHero hero) // { // long atk = hero.prop.GetValueNoCheck(CSPropIDType.Atk); // return Math.Max(1, atk); // } // public static bool IsDead(this BattleHero hero) // { // return (hero.isDead || hero.prop.GetValueNoCheck(CSPropIDType.Hp) <= 0); // } // public static int GetMoveSpeed(this BattleHero hero) // { // return (int)hero.prop.GetValueNoCheck(CSPropIDType.Speed); // } // public static Fixed64 GetMoveSpeedFixed(this BattleHero hero) // { // return ((Fixed64)hero.prop.GetValueNoCheck(CSPropIDType.Speed)) / 1000; // } // public static long GetProp(this BattleHero hero, CSPropIDType id) // { // return hero.prop.GetValue(id); // } // public static long GetPropNoCheck(this BattleHero hero, CSPropIDType id) // { // return hero.prop.GetValueNoCheck(id); // } // public static bool AddProp(this BattleHero hero, BattleObj battle, CSPropIDType id, long value) // { // var relation = HeroProp.GetPropRelation(id); // if (id == CSPropIDType.Hp) // { // AddHp(hero, value); // return true; // } // if(relation != null && relation.PropFinal == (int)CSPropIDType.HpMax) // { // AddHpMax(hero, battle, id, value); // return true; // } // if (value != 0 && hero.prop.AddValue(id, value)) // { // return true; // } // return false; // } // public static bool SetProp(this BattleHero hero, CSPropIDType id, long value) // { // if (id == CSPropIDType.Hp) // { // SetHp(hero, value); // return true; // } // if(id == CSPropIDType.HpMax) // { // SetHpMax(hero, value); // return true; // } // long oldValue = hero.prop.GetValue(id); // if (value != oldValue && hero.prop.SetValue(id, value)) // { // return true; // } // return false; // } // // Hp不需要重算属性,且单独触发事件 // public static void SetHp(this BattleHero hero, long newHp) // { // if (newHp < 0) // { // newHp = 0; // } // long maxHp = hero.prop.GetValueNoCheck(CSPropIDType.HpMax); // if (newHp > maxHp) // { // newHp = maxHp; // } // long oldHp = hero.prop.GetValueNoCheck(CSPropIDType.Hp); // if (oldHp != newHp) // { // hero.prop.SetValueNoCheck(CSPropIDType.Hp, newHp, false); // } // } // // Hp上限不需要重算属性,且单独触发事件 // public static void SetHpMax(this BattleHero hero, long newHpMax) // { // if (newHpMax <= 0) // { // newHpMax = 1; // } // long oldHp = hero.prop.GetValueNoCheck(CSPropIDType.Hp); // if (oldHp > newHpMax) // { // hero.prop.SetValueNoCheck(CSPropIDType.Hp, newHpMax, false); // } // hero.prop.SetValueNoCheck(CSPropIDType.HpMax, newHpMax, false); // } // // Hp不需要重算属性,且单独触发事件 // public static void AddHp(this BattleHero hero, long value) // { // if (value == 0) // { // return; // } // long currHp = hero.prop.GetValueNoCheck(CSPropIDType.Hp); // long maxHp = hero.prop.GetValueNoCheck(CSPropIDType.HpMax); // currHp += value; // if (currHp < 0) // { // currHp = 0; // } // else if (currHp > maxHp) // { // currHp = maxHp; // } // hero.prop.SetValueNoCheck(CSPropIDType.Hp, currHp, false); // } // public static void AddHpMax( this BattleHero hero, BattleObj battle, CSPropIDType propid, long value) // { // long oldHp = hero.prop.GetValueNoCheck(CSPropIDType.Hp); // long oldHpMax = hero.prop.GetValueNoCheck(CSPropIDType.HpMax); // hero.prop.AddValue(propid, value, true); // long newHpMax = hero.prop.GetValueNoCheck(CSPropIDType.HpMax); // if(newHpMax <= 0) // { // hero.prop.SetValueNoCheck(CSPropIDType.Hp, 0, false); // hero.prop.SetValueNoCheck(CSPropIDType.HpMax, 1, false); // return; // } // long hpAdd = 0; // if(newHpMax - oldHpMax > 0) // { // hpAdd = newHpMax - oldHpMax; // } // //血量大于上限,修改血量 // if (oldHp > newHpMax) // { // hero.prop.SetValueNoCheck(CSPropIDType.Hp, newHpMax, false); // } // else // { // hero.prop.SetValueNoCheck(CSPropIDType.Hp, Math.Min(oldHp + hpAdd, newHpMax), false); // } // BattleControl.CreateBattleLog(battle, hero.objId, hero.objId, BattleEventType.SetHP, 0, // hero.prop.GetValueNoCheck(CSPropIDType.Hp), hero.prop.GetValueNoCheck(CSPropIDType.HpMax)); // } // } //}