private static async ETTask CommonAttack_Internal(this CommonAttackComponent self) { HeroDataComponent heroDataComponent = self.Entity.GetComponent <HeroDataComponent>(); float attackPre = heroDataComponent.NodeDataForHero.OriAttackPre / (1 + heroDataComponent.NodeDataForHero.ExtAttackSpeed); float attackPos = heroDataComponent.NodeDataForHero.OriAttackPos / (1 + heroDataComponent.NodeDataForHero.ExtAttackSpeed); float attackSpeed = heroDataComponent.NodeDataForHero.OriAttackSpeed + heroDataComponent.NodeDataForHero.ExtAttackSpeed; //播放动画,如果动画播放完成还不能进行下一次普攻,则播放空闲动画 await Game.Scene.GetComponent <TimerComponent>().WaitAsync((long)(attackPre * 1000), self.CancellationTokenSource.Token); List <NP_RuntimeTree> targetSkillCanvas = self.Entity.GetComponent <SkillCanvasManagerComponent>().GetSkillCanvas(10001); foreach (var skillCanva in targetSkillCanvas) { skillCanva.GetBlackboard().Set("CastNormalAttack", true); skillCanva.GetBlackboard().Set("NormalAttackUnitIds", new List <long>() { self.CachedUnitForAttack.Id }); } Game.EventSystem.Run(EventIdType.ChangeHP, self.CachedUnitForAttack.Id, -50.0f); self.LastAttackTime = TimeHelper.Now(); self.CanAttack = false; self.AttackInterval = (long)(1 / attackSpeed - attackPre) * 1000; await Game.Scene.GetComponent <TimerComponent>().WaitAsync(self.AttackInterval, self.CancellationTokenSource.Token); //此次攻击完成 self.CancellationTokenSource.Dispose(); self.CancellationTokenSource = null; }
public static float CalculateCurrentData <A, B>(A buffSystem, B buffData) where A : ABuffSystemBase where B : BuffDataBase { //取得来源Unit的Hero数据 HeroDataComponent theUnitFromHeroData = buffSystem.TheUnitFrom.GetComponent <HeroDataComponent>(); float tempData = 0; //依据基础数值的加成方式来获取对应数据 switch (buffData.BaseBuffBaseDataEffectTypes) { case BuffBaseDataEffectTypes.FromHeroLevel: tempData = buffData.ValueToBeChanged[theUnitFromHeroData.CurrentLevel]; break; case BuffBaseDataEffectTypes.FromSkillLevel: tempData = buffData.ValueToBeChanged[buffSystem.TheUnitFrom.GetComponent <SkillCanvasManagerComponent>() .GetSkillLevel(buffData.BelongToSkillId.Value)]; break; case BuffBaseDataEffectTypes.FromHasLostLifeValue: tempData = buffSystem.TheUnitBelongto.GetComponent <HeroDataComponent>().MaxLifeValue - buffSystem.TheUnitBelongto.GetComponent <HeroDataComponent>().CurrentLifeValue; break; case BuffBaseDataEffectTypes.FromCurrentOverlay: tempData = buffData.ValueToBeChanged[buffSystem.CurrentOverlay]; break; } //依据加成方式对伤害进行加成 foreach (var additionValue in buffData.AdditionValue) { switch (additionValue.Key) { case BuffAdditionTypes.Percentage_Physical: tempData += additionValue.Value * theUnitFromHeroData.CurrentAttackValue; break; case BuffAdditionTypes.Percentage_Magic: tempData += additionValue.Value * theUnitFromHeroData.CurrentSpellpower; break; case BuffAdditionTypes.SelfOverlay_Mul: tempData *= additionValue.Value * buffSystem.CurrentOverlay; break; case BuffAdditionTypes.SelfOverlay_Plu: tempData += additionValue.Value * buffSystem.CurrentOverlay; break; } } return(tempData); }
public void Awake(Unit hero, FUI headBar) { this.m_Hero = hero; HeroDataComponent heroDataComponent = hero.GetComponent <HeroDataComponent>(); this.m_HeadBar = headBar as FUIHeadBar; //这个血量最大值有点特殊,还需要设置一下密度用事件比较好一点 Game.EventSystem.Run(EventIdType.ChangeHPMax, hero.Id, heroDataComponent.MaxLifeValue); this.m_HeadBar.Bar_HP.self.value = heroDataComponent.MaxLifeValue; this.m_HeadBar.Bar_MP.self.max = heroDataComponent.MaxMagicValue; this.m_HeadBar.Bar_MP.self.value = heroDataComponent.MaxMagicValue; }
public void Awake(Unit hero, FUI headBar) { this.m_Hero = hero; HeroDataComponent heroDataComponent = hero.GetComponent <HeroDataComponent>(); this.m_HeadBar = headBar as FUIHeadBar; //这个血量最大值有点特殊,还需要设置一下密度用事件比较好一点 this.SetDensityOfBar(this.m_Hero.GetComponent <HeroDataComponent>().GetAttribute(NumericType.MaxHp)); this.m_HeadBar.Bar_HP.self.value = heroDataComponent.GetAttribute(NumericType.MaxHp); this.m_HeadBar.Bar_MP.self.max = heroDataComponent.GetAttribute(NumericType.MaxMp); this.m_HeadBar.Bar_MP.self.value = heroDataComponent.GetAttribute(NumericType.MaxMp); }
public override void OnExecute() { //Log.Info("自身添加了血怒Buff!!!!!!!!!!!!!!!!!!!!!"); HeroDataComponent tempHeroDataComponent = this.TheUnitBelongto.GetComponent <HeroDataComponent>(); ChangePropertyBuffData tempChangePropertyBuffData = this.BuffData as ChangePropertyBuffData; switch (this.BuffData.BuffWorkType) { case BuffWorkTypes.ChangeAttackValue: tempHeroDataComponent.CurrentAttackValue += tempChangePropertyBuffData.TheValueWillBeAdded; break; } this.BuffState = BuffState.Running; }
private static async ETTask CommonAttack_Internal(this CommonAttackComponent self) { MessageHelper.Broadcast(new M2C_CommonAttack() { AttackCasterId = self.Entity.Id, TargetUnitId = self.CachedUnitForAttack.Id, CanAttack = true }); HeroDataComponent heroDataComponent = self.Entity.GetComponent <HeroDataComponent>(); float attackPre = heroDataComponent.NodeDataForHero.OriAttackPre / (1 + heroDataComponent.GetAttribute(NumericType.AttackSpeedAdd)); float attackSpeed = heroDataComponent.GetAttribute(NumericType.AttackSpeed); //播放动画,如果动画播放完成还不能进行下一次普攻,则播放空闲动画 await TimerComponent.Instance.WaitAsync((long)(attackPre * 1000), self.CancellationTokenSource.Token); DamageData damageData = ReferencePool.Acquire <DamageData>().InitData(BuffDamageTypes.PhysicalSingle | BuffDamageTypes.CommonAttack, heroDataComponent.GetAttribute(NumericType.Attack), self.Entity as Unit, self.CachedUnitForAttack); self.Entity.GetComponent <CastDamageComponent>().BaptismDamageData(damageData); float finalDamage = self.CachedUnitForAttack.GetComponent <ReceiveDamageComponent>().BaptismDamageData(damageData); if (finalDamage >= 0) { self.CachedUnitForAttack.GetComponent <HeroDataComponent>().NumericComponent.ApplyChange(NumericType.Hp, -finalDamage); //抛出伤害事件,需要监听伤害的buff(比如吸血buff)需要监听此事件 Game.Scene.GetComponent <BattleEventSystem>().Run($"{EventIdType.ExcuteDamage}{self.Entity.Id}", damageData); //抛出受伤事件,需要监听受伤的Buff(例如反甲)需要监听此事件 Game.Scene.GetComponent <BattleEventSystem>().Run($"{EventIdType.TakeDamage}{self.CachedUnitForAttack.Id}", damageData); } CDComponent.Instance.TriggerCD(self.Entity.Id, "CommonAttack"); CDInfo commonAttackCDInfo = CDComponent.Instance.GetCDData(self.Entity.Id, "CommonAttack"); commonAttackCDInfo.Interval = (long)(1 / attackSpeed - attackPre) * 1000; List <NP_RuntimeTree> targetSkillCanvas = self.Entity.GetComponent <SkillCanvasManagerComponent>().GetSkillCanvas(10001); foreach (var skillCanva in targetSkillCanvas) { skillCanva.GetBlackboard().Set("CastNormalAttack", true); skillCanva.GetBlackboard().Set("NormalAttackUnitIds", new List <long>() { self.CachedUnitForAttack.Id }); } await TimerComponent.Instance.WaitAsync(commonAttackCDInfo.Interval, self.CancellationTokenSource.Token); }
public override void OnUpdate() { //只有不是永久Buff的情况下才会执行Update判断 if (this.BuffData.SustainTime + 1 > 0) { if (TimeHelper.Now() >= this.MaxLimitTime) { HeroDataComponent tempHeroDataComponent = this.TheUnitBelongto.GetComponent <HeroDataComponent>(); ChangePropertyBuffData tempChangePropertyBuffData = this.BuffData as ChangePropertyBuffData; switch (this.BuffData.BuffWorkType) { case BuffWorkTypes.ChangeAttackValue: tempHeroDataComponent.CurrentAttackValue -= tempChangePropertyBuffData.TheValueWillBeAdded; break; } this.BuffState = BuffState.Finished; } } }
public override void Start(FUI5V5Map self) { Unit unit = UnitComponent.Instance.MyUnit; HeroDataComponent heroDataComponent = unit.GetComponent <HeroDataComponent>(); NodeDataForHero mNodeDataForHero = heroDataComponent.NodeDataForHero; self.SmallMapSprite.onRightClick.Add(this.AnyEventHandler); self.Btn_GMController_Enable.self.visible = false; self.Btn_GMController_Disable.self.onClick.Add(() => { self.Btn_GMController_Disable.Visible = false; self.Btn_GMController_Enable.Visible = true; self.Par_GMControllerDis.Play(); }); self.Btn_GMController_Enable.self.onClick.Add(() => { self.Btn_GMController_Disable.Visible = true; self.Btn_GMController_Enable.Visible = false; self.Part_GMControllerEnable.Play(); }); self.Btn_CreateSpiling.self.onClick.Add(() => { SessionComponent.Instance.Session.Send(new Actor_CreateSpiling() { X = unit.Position.x, Y = unit.Position.y, Z = unit.Position.z, ParentUnitId = unit.Id }); ETModel.Log.Info($"发送请求木桩父实体id:{unit.Id}"); }); GameObject HeroAvatars = ETModel.Game.Scene.GetComponent <ResourcesComponent>().LoadAsset <GameObject>(ABPathUtilities.GetTexturePath("HeroAvatars")); GameObject HeroSkillIcons = ETModel.Game.Scene.GetComponent <ResourcesComponent>().LoadAsset <GameObject>(ABPathUtilities.GetTexturePath("HeroSkillIcons")); self.HeroAvatarLoader.texture = new NTexture(HeroAvatars.GetTargetObjectFromRC <Sprite>(mNodeDataForHero.HeroAvatar).texture); self.SkillTalent_Loader.texture = new NTexture(HeroSkillIcons.GetTargetObjectFromRC <Sprite>(mNodeDataForHero.Talent_SkillSprite).texture); self.SkillQ_Loader.texture = new NTexture(HeroSkillIcons.GetTargetObjectFromRC <Sprite>(mNodeDataForHero.Q_SkillSprite).texture); self.SkillW_Loader.texture = new NTexture(HeroSkillIcons.GetTargetObjectFromRC <Sprite>(mNodeDataForHero.W_SkillSprite).texture); self.SkillE_Loader.texture = new NTexture(HeroSkillIcons.GetTargetObjectFromRC <Sprite>(mNodeDataForHero.E_SkillSprite).texture); self.SkillR_Loader.texture = new NTexture(HeroSkillIcons.GetTargetObjectFromRC <Sprite>(mNodeDataForHero.R_SkillSprite).texture); self.AttackInfo.text = heroDataComponent.GetAttribute(NumericType.Attack).ToString(); self.ExtraAttackInfo.text = heroDataComponent.GetAttribute(NumericType.AttackAdd).ToString(); self.MagicInfo.text = heroDataComponent.GetAttribute(NumericType.MagicStrength).ToString(); self.ExtraMagicInfo.text = heroDataComponent.GetAttribute(NumericType.MagicStrengthAdd).ToString(); self.ArmorInfo.text = heroDataComponent.GetAttribute(NumericType.Armor).ToString(); self.ArmorpenetrationInfo.text = heroDataComponent.GetAttribute(NumericType.ArmorPenetration).ToString(); self.SpellResistanceInfo.text = heroDataComponent.GetAttribute(NumericType.MagicResistance).ToString(); self.MagicpenetrationInfo.text = heroDataComponent.GetAttribute(NumericType.MagicPenetration).ToString(); self.AttackSpeedInfo.text = heroDataComponent.GetAttribute(NumericType.AttackSpeed).ToString(); self.SkillCDInfo.text = heroDataComponent.GetAttribute(NumericType.SkillCD).ToString(); self.CriticalstrikeInfo.text = heroDataComponent.GetAttribute(NumericType.CriticalStrikeProbability).ToString(); self.MoveSpeedInfo.text = heroDataComponent.GetAttribute(NumericType.Speed).ToString(); self.RedText.text = $"{heroDataComponent.GetAttribute(NumericType.Hp)}/{heroDataComponent.GetAttribute(NumericType.MaxHp)}"; self.BlueText.text = $"{heroDataComponent.GetAttribute(NumericType.Mp)}/{heroDataComponent.GetAttribute(NumericType.MaxMp)}"; self.RedProBar.self.max = heroDataComponent.GetAttribute(NumericType.MaxHp); self.RedProBar.self.value = heroDataComponent.GetAttribute(NumericType.Hp); self.BlueProBar.self.max = heroDataComponent.GetAttribute(NumericType.MaxMp); self.BlueProBar.self.value = heroDataComponent.GetAttribute(NumericType.Mp); self.SkillTalent_CDInfo.visible = false; self.SkillTalent_Bar.Visible = false; self.SkillQ_CDInfo.visible = false; self.SkillQ_Bar.Visible = false; self.SkillW_CDInfo.visible = false; self.SkillW_Bar.Visible = false; self.SkillE_CDInfo.visible = false; self.SkillE_Bar.Visible = false; self.SkillR_CDInfo.visible = false; self.SkillR_Bar.Visible = false; self.SkillD_CDInfo.visible = false; self.SkillD_Bar.Visible = false; self.SkillF_CDInfo.visible = false; self.SkillF_Bar.Visible = false; }