123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- using CommonAI.Zone.Helper;
- using CommonAI.Zone.Instance;
- using XmdsCommonServer.Plugin;
- using XmdsCommonServer.XLS.Data;
- using XmdsCommonSkill.Plugin.Buffs;
- using System;
- using static CommonAI.Zone.Instance.InstanceUnit;
- using XmdsCommon.Plugin;
- using CommonAI.Zone;
- using XmdsCommonServer.Plugin.Units;
- using CommonAI.Zone.Formula;
- using XmdsCommonSkill.Plugin.Skills;
- using XmdsCommonServer.Plugin.XmdsSkillTemplate.DamageCalculator;
- using XmdsCommonSkill.Plugin.Skills.Magic;
- using CommonLang;
- using CommonAI.Data;
- namespace XmdsCommonSkill.Plugin.PassiveSkills.Magic
- {
- /// <summary>
- /// 防御塔被动
- /// 1. 受伤机制, 2. 攻击机制
- /// </summary>
- public class Other_100003 : XmdsPassiveSkillBase
- {
- /// 技能ID.
- public static readonly int ID = 100003;
- public static readonly float SoliderAtkRange = 6.0f;
- private XmdsVirtual mOwner = null;
- private int mUUID_1 = 0;
- private int mUUID_2 = 0;
- public override int SkillID { get { return ID; } }
- protected override void OnInit(GameSkill skillInfo, XmdsVirtual owner)
- {
- this.mOwner = owner;
- mUUID_1 = owner.RegistOnHitDamage(OnHandleHitDmage, skillInfo, true);
- mUUID_2 = owner.RegistOnHitOther(OnHandleOnHitOther, skillInfo, true);
- }
- //受到攻击
- private float OnHandleHitDmage(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source,
- ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch)
- {
- //队伍范围内找友军
- int soldiersCount = 0;
- using (var list = ListObjectPool<InstanceUnit>.AllocAutoRelease())
- {
- mOwner.mUnit.Parent.getObjectsRoundRange<InstanceUnit>(
- (obj, dx, dy, dr) =>
- {
- var u = obj as InstanceUnit;
- if (u.Virtual is XmdsVirtual_Monster && CMath.includeRoundPoint(dx, dy, dr, u.X, u.Y))
- {
- //己方单位.
- if (mOwner.mUnit.Force != u.Force)
- {
- soldiersCount++;
- }
- }
- return true;
- },
- mOwner.mUnit.X,
- mOwner.mUnit.Y,
- SoliderAtkRange,
- list, mOwner.mUnit.AoiStatus);
- }
- //有小兵,伤害不衰减,最大1/10防御塔最大血量
- if (soldiersCount > 0)
- {
- return Math.Min(damage, mOwner.mUnit.MaxHP / 10);
- }
- //没有小兵,伤害衰减10倍,最大1/10防御塔最大血量
- return Math.Min(damage / 100, mOwner.mUnit.MaxHP / 10);
- }
- //单位攻击
- private float OnHandleOnHitOther(float damage, XmdsVirtual hitter, XmdsVirtual attacker, AttackSource source,
- ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch)
- {
- if (hitter is XmdsVirtual_Player)
- {
- damage = Math.Max(damage, hitter.mUnit.MaxHP/10);
- }
- return damage;
- }
- protected override void OnDispose(XmdsVirtual owner)
- {
- owner.UnRegistOnHitDamage(mUUID_1);
- owner.UnRegistOnHitOther(mUUID_2);
- }
- }
- }
|