static int GetDemageHurtType(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); TriggerData arg0 = (TriggerData)ToLua.CheckObject(L, 1, typeof(TriggerData)); FightManager.HurtType o = FightManager.GetDemageHurtType(arg0); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
private void Awake() { // 初始化事件 settlementDamageOrCure = (type1, type2, trigger, alldata) => { //Debug.Log("伤害结算"); var isChange = false; // 治疗结算 if (type1 == TriggerLevel1.Fight && type2 == TriggerLevel2.BeCure) { alldata.MemberData.CurrentHP += trigger.HealthChangeValue; isChange = true; // 统计受到的治疗量 FightDataStatistical.Single.AddHealthChange("" + alldata.MemberData.ObjID.ID, trigger.HealthChangeValue, alldata.MemberData.Camp, DemageOrCure.Cure, trigger.DemageType); // 统计产生的治疗量 FightDataStatistical.Single.AddHealthChange( "" + trigger.ReleaseMember.ClusterData.AllData.MemberData.ObjID.ID, trigger.HealthChangeValue, trigger.ReleaseMember.ClusterData.AllData.MemberData.Camp, DemageOrCure.Cure, trigger.DemageType, AttackOrBeAttach.Attack); // 抛出治疗事件给外层 FightManager.Single.DoHealthChangeAction(trigger.ReleaseMember.GameObj, alldata.MemberData.TotalHp, alldata.MemberData.CurrentHP, trigger.HealthChangeValue, FightManager.HurtType.Cure, alldata.MemberData.ObjID.ObjType); } // 伤害结算 if (type1 == TriggerLevel1.Fight && type2 == TriggerLevel2.BeAttack) { //Debug.Log("结算生命值:" + trigger.HealthChangeValue); alldata.MemberData.SetCurrentHP(alldata.MemberData.CurrentHP - trigger.HealthChangeValue); // 统计受到的伤害量 FightDataStatistical.Single.AddHealthChange("" + alldata.MemberData.ObjID.ID, trigger.HealthChangeValue, alldata.MemberData.Camp, DemageOrCure.Demage, trigger.DemageType); // 统计产生的伤害量 FightDataStatistical.Single.AddHealthChange( "" + trigger.ReleaseMember.ClusterData.AllData.MemberData.ObjID.ID, trigger.HealthChangeValue, trigger.ReleaseMember.ClusterData.AllData.MemberData.Camp, DemageOrCure.Demage, trigger.DemageType, AttackOrBeAttach.Attack); // 转换伤害类型 var hurtType = FightManager.GetDemageHurtType(trigger); // 抛出伤害事件给外层 FightManager.Single.DoHealthChangeAction(trigger.ReleaseMember.GameObj, alldata.MemberData.TotalHp, alldata.MemberData.CurrentHP, trigger.HealthChangeValue, hurtType, alldata.MemberData.ObjID.ObjType); if (alldata.MemberData.CurrentHP < Utils.ApproachZero) { alldata.MemberData.SetCurrentHP(0); // 并判断该伤害是否致死, 如果不致死则生命值设置为1 if (trigger.IsNotLethal) { alldata.MemberData.SetCurrentHP(1); } else { // 抛出致死攻击事件 tmpList.Add(new TriggerData() { HealthChangeValue = trigger.HealthChangeValue, ReceiveMember = trigger.ReceiveMember, ReleaseMember = trigger.ReleaseMember, TypeLevel1 = TriggerLevel1.Fight, TypeLevel2 = TriggerLevel2.LethalHit }); // 统计杀敌数量 FightDataStatistical.Single.AddKillCount("" + alldata.MemberData.ObjID.ID, 1, alldata.MemberData.Camp); } } // 是否有吸收伤害 if (trigger.IsAbsorption) { // 检测是否有伤害吸收的buff/skill // 触发吸收伤害事件 tmpList.Add(new TriggerData() { HealthChangeValue = trigger.HealthChangeValue, ReceiveMember = trigger.ReceiveMember, ReleaseMember = trigger.ReleaseMember, TypeLevel1 = TriggerLevel1.Fight, TypeLevel2 = TriggerLevel2.Absorption }); } // 抛出伤害事件 if (trigger.HealthChangeValue > 0) { tmpList.Add(new TriggerData() { HealthChangeValue = trigger.HealthChangeValue, ReceiveMember = trigger.ReceiveMember, ReleaseMember = trigger.ReleaseMember, TypeLevel1 = TriggerLevel1.Fight, TypeLevel2 = TriggerLevel2.BeHurt }); // 伤害类型 var attackType = TriggerLevel2.BeNormalAttackHurt; switch (trigger.DemageType) { // 普通伤害 case DemageType.NormalAttackDemage: attackType = TriggerLevel2.BeNormalAttackHurt; break; // 技能伤害 case DemageType.SkillAttackDemage: attackType = TriggerLevel2.BeSkillHurt; break; } tmpList.Add(new TriggerData() { HealthChangeValue = trigger.HealthChangeValue, ReceiveMember = trigger.ReceiveMember, ReleaseMember = trigger.ReleaseMember, TypeLevel1 = TriggerLevel1.Fight, TypeLevel2 = attackType }); } isChange = true; } // 如果血量有变动则抛出血量变动事件 if (isChange) { tmpList.Add(new TriggerData() { ReceiveMember = trigger.ReceiveMember, ReleaseMember = trigger.ReleaseMember, TypeLevel1 = TriggerLevel1.Fight, TypeLevel2 = TriggerLevel2.HealthChange }); } }; }