using System; using System.Collections.Generic; using System.Linq; using System.Text; using XmdsCommon.Plugin; using XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills; namespace XmdsCommonSkill.Plugin.Buffs { /// /// FileName: XmdsBuff_EnergyCost.cs /// Author: Alex.Yu /// Corporation:... /// Description: 能量消耗改变. /// DateTime: 2015/6/17 17:37:50 /// public class XmdsBuff_EnergyCost : XmdsBuffBase { /// /// BUFF作用效果.正:增加消耗,负:减少消耗(过量保护). /// public float BuffChangeValue = 0; /// /// 百分比型. /// public bool IsPercent = true; private int mHandUUID = 0; //默认时间. private const int DefaultTime = int.MaxValue; /// /// 大于0,则只影响对应的技能效果. /// public int TargetSkillID = 0; public override int GetAbilityID() { return (int)XmdsCommon.Plugin.XmdsBuffProperties.XmdsBuffAbility.EnergyCost; } public override void CopyTo(UnitBuff other) { var ret = other as XmdsBuff_EnergyCost; ret.BuffChangeValue = this.BuffChangeValue; ret.IsPercent = this.IsPercent; ret.TargetSkillID = this.TargetSkillID; base.CopyTo(other); } protected override void OnBindTemplate(ref CommonAI.Zone.BuffTemplate buffTemplate) { //如果为次数型,那么需设置作用时间. if (BuffUseType == (int)XmdsBuffBase.XmdsBuffUseType.Times) { buffTemplate.LifeTimeMS = DefaultTime; } } protected override void OnBuffBegin(XmdsCommonServer.Plugin.XmdsVirtual hitter, XmdsCommonServer.Plugin.XmdsVirtual attacker, CommonAI.Zone.Instance.InstanceUnit.BuffState state) { mHandUUID = hitter.RegistLaunchSkillOver(OnLaunchSkillOver, null, true); } protected override void OnBuffEnd(XmdsCommonServer.Plugin.XmdsVirtual hitter, CommonAI.Zone.Instance.InstanceUnit.BuffState state, bool replace) { hitter.UnRegistLaunchSkillOver(mHandUUID); } private int OnLaunchSkillOver(GameSkill info, XmdsCommonServer.Plugin.XmdsVirtual attacker, CommonAI.Zone.Instance.InstanceUnit.SkillState state) { if (!IsInvaild() && BuffInvaildCheck()) { attacker.mUnit.removeBuff(BindBuffID); } return 0; } } }