示例#1
0
 protected virtual void OnDestructibleEntersRange(Destructible u, Destructible enterer)
 {
     if (enterer is Unit)
     {
         OnUnitEntersRange((Unit)enterer);
     }
 }
示例#2
0
 public virtual bool IsInEffectiveRange(Destructible target, float tolerance)
 {
     return(Common.Math.CircleArcIntersection(Common.Math.ToVector2(target.Position),
                                              target.HitRadius,
                                              Common.Math.ToVector2(MediatorOffsetedPosition), EffectiveRange * tolerance, Mediator.LookatDir,
                                              EffectiveAngle));
 }
示例#3
0
 protected virtual void OnDestructibleExitsRange(Destructible u, Destructible exiter)
 {
     if (exiter is Unit)
     {
         OnUnitExitsRange((Unit)exiter);
     }
 }
示例#4
0
 public override bool IsEffectiveTowardsTarget(Vector3 targetPosition, Destructible targetEntity)
 {
     if (!(targetEntity is Unit))
     {
         return(false);
     }
     return(((Unit)targetEntity).CanAddBuff(Buff) && base.IsEffectiveTowardsTarget(targetPosition, targetEntity));
 }
        bool PassesValidTarget(Destructible target)
        {
            if ((ValidTargets & Targets.None) != 0)
            {
                return(false);
            }
            if ((ValidTargets & Targets.All) != 0)
            {
                return(true);
            }

            if ((ValidTargets & Targets.Ground) != 0)
            {
                return(true);
            }

            bool isUnit = target is Unit;

            if (isUnit && (ValidTargets & Targets.Units) != 0)
            {
                return(true);
            }

            if (target == Performer && (ValidTargets & Targets.Self) != 0)
            {
                return(true);
            }

            if (isUnit && target.State == UnitState.RaisableCorpse && (ValidTargets & Targets.RaisableCorpses) != 0)
            {
                return(true);
            }
            if (isUnit && target.State == UnitState.Dead && (ValidTargets & Targets.Dead) != 0)
            {
                return(true);
            }

            if (!target.CanBeDestroyed)
            {
                return(false);
            }

            bool isHostile = Mechanics.TeamReleations.IsHostile(Performer.Team, target.Team);

            if (isHostile && (ValidTargets & Targets.Enemies) != 0)
            {
                return(true);
            }

            if (!isHostile && (ValidTargets & Targets.Friendlies) != 0)
            {
                return(true);
            }

            return(false);
        }
示例#6
0
 public virtual bool IsInGroup(Destructible destructible)
 {
     foreach (var v in GetDestructibles())
     {
         if (v == destructible)
         {
             return(true);
         }
     }
     return(false);
 }
示例#7
0
        void NNObject_ExitsRange(Destructible arg1, Destructible arg2)
        {
            if (!IsValidTarget(arg2))
            {
                return;
            }

            if (arg2 is Unit)
            {
                OnUnitExitsRange((Unit)arg2);
            }
        }
示例#8
0
 protected virtual int CalculateDamage(Destructible target)
 {
     if (IsCritting)
     {
         return((int)(Damage * CritDamageMultiplier *
                      Math.Pow(1 + CritRowMultiplier, nCritsInRow)));
     }
     else
     {
         return(Damage);
     }
 }
示例#9
0
        protected void TryHit(Destructible target)
        {
            if (!IsInEffectiveRange(target))
            {
                return;
            }
            if (!CanHit(target))
            {
                return;
            }

            Hit(target);
        }
示例#10
0
        public override bool IsPerformableTowardsTarget(Vector3 targetPosition, Destructible targetEntity)
        {
            float d;

            if (targetEntity != null)
            {
                d = targetEntity.HitDistance(Mediator.Translation);
            }
            else
            {
                d = (Mediator.Translation - targetPosition).Length();
            }

            return(d < PerformableRange &&
                   Performer.State == UnitState.Alive &&
                   //Performer.MotionUnit.IsOnGround &&
                   base.IsPerformableTowardsTarget(targetPosition, targetEntity));
        }
示例#11
0
 IState TryFindBetterState(IState state, Destructible target)
 {
     foreach (var a in Abilities)
     {
         if (a.IsValidTarget(target))
         {
             var s = new TryPerformAbility(this)
             {
                 Ability = a,
                 Chasing = target
             };
             if (state.IsBetterState(s))
             {
                 state = s;
             }
         }
     }
     return(state);
 }
示例#12
0
        private void Hit(Destructible target)
        {
            int damage = CalculateDamage(target);

            if (IsCritting)
            {
                target.Hit(Performer, damage, CritAttackType, this);
            }
            else
            {
                target.Hit(Performer, damage, AttackType, this);
            }

            if (ApplyBuffToTargets != null && target is Unit)
            {
                var b = (Buff)ApplyBuffToTargets.Clone();
                ((Unit)target).AddBuff(b, (Unit)Performer, Mediator);
            }

            OnHit(target);
        }
示例#13
0
 public override float AIPriority(Unit performer, Vector3 targetPosition, Destructible targetUnit)
 {
     if (IsPerforming)
     {
         return(2);
     }
     if (!IsValidTarget(targetUnit))
     {
         return(-100);
     }
     if (!IsEffectiveTowardsTarget(targetPosition, targetUnit))
     {
         return(-50);
     }
     if (CurrentCooldown >= 0)
     {
         return(0.1f);
     }
     if (!IsInEffectiveRange(targetUnit))
     {
         return(0.5f);
     }
     return(1);
 }
示例#14
0
 protected abstract int GetValue(Destructible d);
示例#15
0
        protected override void SetValue(Destructible d, int value)
        {
            var u = d as Unit;

            u.CanPerformAbilitiesBlockers = value;
        }
示例#16
0
 protected virtual void OnHit(Destructible target)
 {
 }
示例#17
0
        protected override int GetValue(Destructible d)
        {
            var u = d as Unit;

            return(u.CanControlRotationBlockers);
        }
示例#18
0
 protected virtual bool CanHit(Destructible target)
 {
     return(true);
 }
示例#19
0
 public virtual bool AIIsInEffectiveRange(Destructible target)
 {
     return(IsInEffectiveRange(target, AIEffectiveRangeTolerance));
 }
示例#20
0
 /// <summary>
 /// Used mainly by the AI to determin if we wan to use this ability
 /// </summary>
 public virtual bool IsEffectiveTowardsTarget(Vector3 targetPosition, Destructible targetEntity)
 {
     return(IsPerformableTowardsTarget(targetPosition, targetEntity));
 }
示例#21
0
        protected override int GetValue(Destructible d)
        {
            var u = d as Unit;

            return(u.CanPerformAbilitiesBlockers);
        }
示例#22
0
 public override bool IsEffectiveTowardsTarget(Vector3 targetPosition, Destructible targetEntity)
 {
     return(targetEntity != null && base.IsEffectiveTowardsTarget(targetPosition, targetEntity));
 }
示例#23
0
 protected virtual int GetMaxValue(Destructible d)
 {
     return(GetValue(d));
 }
示例#24
0
 protected virtual void OnKillsDestructible(Destructible target)
 {
 }
示例#25
0
        protected override void SetValue(Destructible d, int value)
        {
            var u = d as Unit;

            u.CanControlRotationBlockers = value;
        }
示例#26
0
 protected override void OnDestructibleExitsRange(Destructible u, Destructible exiter)
 {
     base.OnDestructibleExitsRange(u, exiter);
     inRangeLastChangedFrame = Game.Instance.FrameId;
 }
示例#27
0
        public override float AIPriority(Unit performer, Vector3 targetPosition, Destructible targetUnit)
        {
            float d = Math.Max(1, (targetUnit.Position - Game.Instance.Map.MainCharacter.Position).Length());

            return(base.AIPriority(performer, targetPosition, targetUnit) + 0.01f / d);
        }
示例#28
0
 public bool IsInEffectiveRange(Destructible target)
 {
     return(IsInEffectiveRange(target, 1));
 }
示例#29
0
 public virtual float AIPriority(Unit performer, Vector3 targetPosition, Destructible targetEntity)
 {
     return(1);
 }
示例#30
0
 protected abstract void SetValue(Destructible d, int value);