private string DoDemage(GamingPet source, GamingPet dest, DemageType type, int value, string title) { var realDemage = GetRealDemageValue(source, dest, type, value); if (realDemage <= 0) { return(null); } DoRealDemage(dest, realDemage); var msg = $"{source.Name}对{dest.Name}造成了{realDemage}点{type.ToString()}伤害({title}),{dest.Name}剩余{dest.HP}点生命值!"; var triggerMsg = BeAttackedTrigger(source, dest, realDemage, type); if (!string.IsNullOrWhiteSpace(triggerMsg)) { msg += $"\r\n{triggerMsg}"; } return(msg); }
static int GetHealthChange(IntPtr L) { try { ToLua.CheckArgsCount(L, 6); FightDataStatistical obj = (FightDataStatistical)ToLua.CheckObject(L, 1, typeof(FightDataStatistical)); string arg0 = ToLua.CheckString(L, 2); int arg1 = (int)LuaDLL.luaL_checknumber(L, 3); DemageOrCure arg2 = (DemageOrCure)ToLua.CheckObject(L, 4, typeof(DemageOrCure)); DemageType arg3 = (DemageType)ToLua.CheckObject(L, 5, typeof(DemageType)); AttackOrBeAttach arg4 = (AttackOrBeAttach)ToLua.CheckObject(L, 6, typeof(AttackOrBeAttach)); float o = obj.GetHealthChange(arg0, arg1, arg2, arg3, arg4); LuaDLL.lua_pushnumber(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
private int CalSourceDemage(GamingPet source, DemageType type, int value) { var result = value; var buffs = type switch { DemageType.物理 => source.Buffs.Where(p => p.Trigger == CheckTrigger.PhyAttackFix), DemageType.魔法 => source.Buffs.Where(p => p.Trigger == CheckTrigger.MagicAttackFix), DemageType.毒系 => source.Buffs.Where(p => p.Trigger == CheckTrigger.PoisionAttackFix), //DemageType.真实 => _ => new List <GamingBuff>() }; foreach (var buff in buffs) { buff.Data.AddSafe("Source", source); buff.Data.AddSafe("Value", result); result = int.Parse(ProcessEffect(buff)); } return(result); }
private int GetRealDemageValue(GamingPet source, GamingPet dest, DemageType type, int value) { var demage = CalSourceDemage(source, type, value); return(CalDestDemage(source, dest, type, demage)); }
public override void CreateEntity() { gameSkill = (LineRangeSkill)skill; string effectPath = this.skillConfig.effectPath; if (string.IsNullOrEmpty(effectPath)) { Debug.LogError("effectPath == null :" + this.skillConfig.skillId); return; } switch (this.skillConfig.param[0].name) { case "伤害": this.damegeType = DemageType.伤害; break; case "减速": this.damegeType = DemageType.减速; break; case "控制": this.damegeType = DemageType.控制; break; } switch (this.skillConfig.param[2].name) { case "持续": this.rangeType = RangeType.持续; this.liftTime = this.skillConfig.param[2].param; break; case "瞬发": this.rangeType = RangeType.瞬发; this.liftTime = this.skillConfig.param[2].param; break; } switch (this.skillConfig.param[3].name) { case "区域": this.shapeType = ShapeType.区域; break; case "圆形": this.shapeType = ShapeType.圆形; break; case "Box": this.shapeType = ShapeType.Box; break; } if (this.shapeType == ShapeType.区域) { param1 = new Vector2(this.skillConfig.param[4].param, this.skillConfig.param[5].param); //A点 param2 = new Vector2(this.skillConfig.param[6].param, this.skillConfig.param[7].param); //B点 } else if (this.shapeType == ShapeType.Box) { param1 = new Vector2(this.skillConfig.param[4].param, this.skillConfig.param[5].param); //pos param2 = new Vector2(this.skillConfig.param[6].param, this.skillConfig.param[7].param); //size } WWWResourceManager.Instance.Load(effectPath, (asset) => { if (asset == null) { Debug.LogError("asset == null"); return; } this.theEntity = asset.Instantiate().transform; this.theEntity.gameObject.SetActive(false); this.SetSpawPos(); if (theOwner is EntityLearn) { this.theEntity.gameObject.layer = LayerMask.NameToLayer("UI"); } this.audio = this.theEntity.GetComponent <AudioSource>(); if (this.gameSkill.EffectDelay > 0) { TimerManager.AddTimer(this.gameSkill.EffectDelay, 0, () => { this.bCanUpdate = true; this.theEntity.gameObject.SetActive(true); this.MoniEntityPos = this.theEntity.position; //音频 if (this.audio) { this.audio.Play(); } }); } else { this.bCanUpdate = true; this.theEntity.gameObject.SetActive(true); this.MoniEntityPos = this.theEntity.position; //音频 if (this.audio) { this.audio.Play(); } } }); }
private string BeAttackedTrigger(GamingPet source, GamingPet dest, int value, DemageType type) { var buffs = dest.Buffs.Where(b => b.Trigger == CheckTrigger.BeAttacked && ((b.Data["DemageTypes"] as DemageType[])?.Contains(type) ?? false)).ToList(); foreach (var buff in buffs) { buff.Data.AddSafe("Source", source); buff.Data.AddSafe("Dest", dest); buff.Data.AddSafe("Value", value); buff.Data.AddSafe("Type", type); } return(string.Join("\r\n", buffs.Select(ProcessEffect))); }
/// <summary> /// 获取单位伤害统计 /// </summary> /// <param name="key"></param> /// <param name="camp">阵营</param> /// <param name="changeType">变更类型</param> /// <param name="demageType">伤害类型</param> /// <param name="attackOrBeAttach"></param> /// <returns>变更量</returns> public float GetHealthChange(string key, int camp, DemageOrCure changeType, DemageType demageType, AttackOrBeAttach attackOrBeAttach = AttackOrBeAttach.BeAttach) { var tmpKey = key + "%" + camp + "%" + changeType + "%" + demageType + "%" + attackOrBeAttach; return(GetFloat(tmpKey)); }
/// <summary> /// 添加伤害统计 /// </summary> /// <param name="key">key</param> /// <param name="changeValue">变更量</param> /// <param name="camp">阵营</param> /// <param name="changeType">变更类型</param> /// <param name="demageType">伤害类型</param> /// <param name="attackOrBeAttach">攻击/被攻击</param> public void AddHealthChange(string key, float changeValue, int camp, DemageOrCure changeType, DemageType demageType, AttackOrBeAttach attackOrBeAttach = AttackOrBeAttach.BeAttach) { var tmpKey = key + "%" + camp + "%" + changeType + "%" + demageType + "%" + attackOrBeAttach; SetFloat(tmpKey, changeValue); AddCampHealthChange(camp, changeValue, changeType, attackOrBeAttach); }