public override TargetType GetTargetType()
    {
        TargetUnit  targetUnit  = spellData.targetUnit;
        TargetRange targetRange = spellData.targetRange;

        return(new TargetType(targetUnit, targetRange));
    }
Beispiel #2
0
        public virtual void RefreshWaypoints()
        {
            if (TargetUnit == null || TargetUnit.IsDead || GetDistanceTo(TargetUnit) <= Stats.Range.Total && Waypoints.Count == 1)
            {
                return;
            }

            if (GetDistanceTo(TargetUnit) <= Stats.Range.Total - 2f)
            {
                SetWaypoints(new List <Vector2> {
                    new Vector2(X, Y)
                });
            }
            else
            {
                SetWaypoints(new List <Vector2>()
                {
                    GetPosition(), TargetUnit.GetPosition()
                });

                /* TODO: Soon we will use path finding for this.
                 * if(CurWaypoint >= Waypoints.Count)
                 * {
                 *  var newWaypoints = _game.Map.NavGrid.GetPath(GetPosition(), TargetUnit.GetPosition());
                 *  if (newWaypoints.Count > 1)
                 *  {
                 *      SetWaypoints(newWaypoints);
                 *  }
                 * }*/
            }
        }
Beispiel #3
0
        bool IEquatable <UnitConversion> .Equals(UnitConversion other)
        {
            bool sourceUnitMatches = SourceUnit?.Equals(other.SourceUnit) ?? SourceUnit == other.SourceUnit;
            bool targetUnitMatches = TargetUnit?.Equals(other.TargetUnit) ?? TargetUnit == other.TargetUnit;

            return(sourceUnitMatches && targetUnitMatches);
        }
        public bool EqualKey(UnitTranslation ItemToCompare)
        {
            bool ReturnValue;


            ReturnValue = TranslationFlag.Equals(ItemToCompare.TranslationFlag);
            if (TranslationFlag == (TranslationType)0)
            {
                ReturnValue &= (BaseUnit.Equals(ItemToCompare.BaseUnit) && TargetUnit.Equals(ItemToCompare.TargetUnit)) ||
                               (BaseUnit.Equals(ItemToCompare.TargetUnit) && TargetUnit.Equals(ItemToCompare.BaseUnit));
            }

            if ((AffectedIngredient != null) && TranslationFlag.HasFlag(TranslationType.IsIngredientDependent))
            {
                ReturnValue &= AffectedIngredient.Equals(ItemToCompare.AffectedIngredient);
            }

            if (TranslationFlag.HasFlag(TranslationType.IsTypeChange) && (!TranslationFlag.HasFlag(TranslationType.IsIngredientDependent)))
            {
                ReturnValue &= (IngredientType == ItemToCompare.IngredientType);
            }

            if ((TranslationFlag.HasFlag(TranslationType.IsIngredientDependent)) && (AffectedIngredient != null) &&
                (ItemToCompare.AffectedIngredient != null))
            {
                ReturnValue &= AffectedIngredient.Equals(ItemToCompare.AffectedIngredient);
            }


            return(ReturnValue);
        }
Beispiel #5
0
        protected override void StartEffectivePerform()
        {
            base.StartEffectivePerform();
            var b = (Buff)Buff.Clone();

            TargetUnit.AddBuff(b, Performer, Mediator);
        }
 protected override void EndPerform(bool aborted)
 {
     base.EndPerform(aborted);
     TargetUnit.StopAnimation();
     TargetUnit.CanPerformAbilitiesBlockers--;
     effect.Remove();
 }
Beispiel #7
0
 private void Update()
 {
     if (TargetUnit == null)
     {
         Destroy(this.gameObject);
     }
     else
     {
         //Folge dem Targetobject
         transform.position = Vector3.MoveTowards(transform.position, TargetUnit.transform.position, 0.5f);
         if (Vector3.Distance(transform.position, TargetUnit.transform.position) < 1f)
         {
             if (TargetUnit.transform.tag.Equals("enemy") || TargetUnit.transform.tag.Equals("Unit"))
             {
                 TargetUnit.GetComponent <Unitprops>().gothit(damage);
             }
             else if (TargetUnit.transform.tag.Equals("Building") || TargetUnit.transform.tag.Equals("enemyBuilding"))
             {
                 TargetUnit.GetComponent <BuildingScript>().gothit(damage);
             }
             else if (TargetUnit.transform.tag.Equals("wall"))
             {
                 TargetUnit.GetComponent <wallscript>().gothit(damage);
             }
             Destroy(this.gameObject);
         }
     }
 }
Beispiel #8
0
        protected override void InputEndedHandler()
        {
            base.InputEndedHandler();

            if (IsAbilityResolved)
            {
                TargetUnit.Die();
            }
        }
        protected override void StartPerform()
        {
            base.StartPerform();

            TargetUnit.MotionUnit.VelocityImpulse(
                Vector3.Normalize(TargetUnit.Position - Performer.Position) * KnockbackStrength);
            TargetUnit.CanPerformAbilitiesBlockers++;
            TargetUnit.PlayAnimation(UnitAnimations.Knockback);
        }
Beispiel #10
0
    public List <BattleCharacter> EnemyToFilter(BattleCommand battleCommand)
    {
        BattleCharacter owner       = battleCommand.owner;
        TargetType      targetType  = battleCommand.GetTargetType();
        TargetUnit      targetUnit  = targetType.targetUnit;
        TargetRange     targetRange = targetType.targetRange;

        return(EnemyToFilter(owner, targetUnit, targetRange));
    }
Beispiel #11
0
        protected override void PerformingTick()
        {
            int actualDamage = TargetUnit.Hit(Performer, HPPerTic, AttackType.Ethereal, this);
            int actualHeal   = Performer.Heal(TargetUnit, actualDamage);

            if (actualHeal != actualDamage || TargetUnit.CanBeDestroyed)
            {
                TryEndPerform(false);
            }
        }
Beispiel #12
0
 protected override void EndPerform(bool aborted)
 {
     base.EndPerform(aborted);
     if (!aborted)
     {
         TargetUnit.State = UnitState.RaisingCorpse;
         TargetUnit.Heal(Performer, 100);
     }
     TargetUnit.ScriptingUserdata.Remove("RaiseDeadRunning");
 }
Beispiel #13
0
        public override bool Process()
        {
            if (TargetUnit == null)
            {
                return(false);
            }

            SpellEffects.Effect eff = new SpellEffects.Drain(MapLogic.TICRATE, Spell.GetDamage(), Spell.User);
            TargetUnit.AddSpellEffects(eff);
            return(false);
        }
 protected override void StartPerform()
 {
     base.StartPerform();
     TargetUnit.LoopAnimation(UnitAnimations.Dazed);
     TargetUnit.CanPerformAbilitiesBlockers++;
     effect = new Client.Game.Map.Effects.DazedIconEffect
     {
         Translation = TargetEntity.Translation + Vector3.UnitZ * TargetUnit.HeadOverBarHeight * TargetUnit.Scale.Z
     };
     TargetUnit.Scene.Add(effect);
 }
Beispiel #15
0
        public override bool Process()
        {
            if (TargetUnit == null)
            {
                return(false);
            }

            SpellEffects.Effect eff = new SpellEffects.ProtectionWater((int)(MapLogic.TICRATE * Spell.GetDuration()), Spell.GetProtection());
            TargetUnit.AddSpellEffects(eff);
            return(false);
        }
Beispiel #16
0
        public override bool Process()
        {
            if (TargetUnit == null)
            {
                return(false);
            }

            SpellEffects.Effect eff = new SpellEffects.Invisibility(40 * 15); // 15 seconds invisible
            TargetUnit.AddSpellEffects(eff);
            return(false);
        }
Beispiel #17
0
    public bool CanEffect(BattleCharacter target, TargetUnit targetUnit)
    {
        if (!target.IsDead())
        {
            return(true);
        }
        if (target.IsDead() && targetUnit == TargetUnit.死亡者)
        {
            return(true);
        }

        return(false);
    }
Beispiel #18
0
        // this should only be called for arrows (i.e. homing projectiles), with TargetUnit set.
        protected void SpawnProjectile(AllodsProjectile type, int speed, int damage)
        {
            // following offsets are based on unit's width, height and center
            float tX, tY;

            if (TargetUnit != null)
            {
                tX = TargetUnit.X + TargetUnit.Width * 0.5f + TargetUnit.FracX;
                tY = TargetUnit.Y + TargetUnit.Height * 0.5f + TargetUnit.FracY;
            }
            else
            {
                tX = TargetX + 0.5f;
                tY = TargetY + 0.5f;
            }

            float cX, cY;

            if (Spell.User != null)
            {
                cX = Spell.User.X + Spell.User.Width * 0.5f + Spell.User.FracX;
                cY = Spell.User.Y + Spell.User.Height * 0.5f + Spell.User.FracY;
                Vector2 dir = new Vector2(tX - cX, tY - cY).normalized *((Spell.User.Width + Spell.User.Height) / 2) / 1.5f;
                cX += dir.x;
                cY += dir.y;
            }
            else
            {
                cX = tX;
                cY = tY;
            }

            Server.SpawnProjectileHoming(type, Spell.User, cX, cY, 0,
                                         TargetUnit,
                                         speed,
                                         (MapProjectile fproj) =>
            {
                //Debug.LogFormat("spell projectile hit!");
                // done, make damage
                DamageFlags spdf = SphereToDamageFlags(Spell);

                if (TargetUnit.TakeDamage(spdf, Spell.User, damage) > 0)
                {
                    TargetUnit.DoUpdateInfo = true;
                    TargetUnit.DoUpdateView = true;
                }

                fproj.Dispose();
                MapLogic.Instance.Objects.Remove(fproj);
            });
        }
Beispiel #19
0
    public List <BattleCharacter> PlayerToFilter(BattleCommand battleCommand)
    {
        List <PlayerCharacter> playerCharacters = BattleController.instance.AlivePlayerCharacters;
        List <EnemyCharacter>  enemyCharacters  = BattleController.instance.AliveEnemyCharacters;
        BattleCharacter        owner            = battleCommand.owner;

        TargetType  targetType  = battleCommand.GetTargetType();
        TargetUnit  targetUnit  = targetType.targetUnit;
        TargetRange targetRange = targetType.targetRange;

        IReadOnlyCollection <BattleCharacter> target = new List <BattleCharacter>();

        switch (targetUnit)
        {
        case TargetUnit.自分:
            return(new List <BattleCharacter>()
            {
                owner
            });

        case TargetUnit.味方:
            target = playerCharacters;
            break;

        case TargetUnit.相手:
            target = enemyCharacters;
            break;

        case TargetUnit.死亡者:
            var allPlayer = BattleController.instance.playerCharacters;
            target = allPlayer.Where(x => x.IsDead()).ToList();
            break;

        default:
            break;
        }

        switch (targetRange)
        {
        case TargetRange.単体:
            return(Randam(target));

        case TargetRange.全体:
            return(target.Cast <BattleCharacter>().ToList());

        default:
            break;
        }
        return(null);
    }
    //効果の処理
    private IEnumerator EffctExecution(BattleCommand battleCommand)
    {
        BattleCharacter        owner         = battleCommand.owner;
        List <BattleCharacter> targets       = battleCommand.target;
        TargetUnit             targetUnit    = battleCommand.GetTargetType().targetUnit;
        PlayableAsset          playableAsset = battleCommand.GetCommand().animation;
        var effects = battleCommand.GetEffect();

        //効果の範囲が全体の場合
        if (battleCommand.GetTargetType().targetRange == TargetRange.全体)
        {
            //敵キャラクタの行動はアニメション表示をしない
            if (owner is PlayerCharacter)
            {
                BattleDirectorController.Instance.AnimationPlay(playableAsset);
            }
        }

        foreach (var effect in effects)
        {
            //単体処理
            foreach (var target in targets)
            {
                //ターゲットが存在しないとき新しいターゲットに変更する
                BattleCharacter newTarget = target;
                if (TargetUnit.死亡者 != targetUnit && target.IsDead())
                {
                    TargetFilter targetFilter = new TargetFilter();
                    newTarget = targetFilter.Auto(battleCommand);
                }

                //効果の処理
                if (battleCommand.GetTargetType().targetRange == TargetRange.単体)
                {
                    //敵キャラクタの行動はアニメション表示をしない
                    if (owner is PlayerCharacter)
                    {
                        BattleDirectorController.Instance.AnimationPlay(playableAsset, newTarget.transform);
                    }
                }

                effect.Use(owner, newTarget);
                //演出を再生する
                yield return(BattleDirectorController.Instance.Play());
            }
        }
        yield break;
    }
        protected override void PerformingTick()
        {
            base.PerformingTick();
            if (TargetUnit.State != UnitState.Alive)
            {
                TryEndPerform(true);
                return;
            }

            if (demonSmokeCharge == null)
            {
                Game.Instance.Scene.Add(demonSmokeCharge = new Effects.DemonSmoke1Small());
            }
            else
            {
                TargetUnit.Hit(Performer, 50, AttackType.Ethereal, this);
                if (!second)
                {
                    Performer.Heal(Performer, 100);
                }
                second = false;
                demonSmokeCharge.Stop();
                demonSmokeTransport = demonSmokeCharge;
                demonSmokeCharge    = new Client.Game.Map.Effects.DemonSmoke1Small();
                Game.Instance.Scene.Add(demonSmokeCharge);
                transport = new Common.Interpolator3 {
                    Value = TargetUnit.Translation
                };
                transport.AddKey(transportKey = new Common.InterpolatorKey <Vector3>
                {
                    Time     = TickPeriod,
                    TimeType = Common.InterpolatorKeyTimeType.Relative,
                    Value    = Performer.Translation
                });
                if (TargetUnit.State != UnitState.Alive)
                {
                    new DemonLinkExplosion
                    {
                        Performer      = Performer,
                        Mediator       = TargetUnit,
                        TargetEntity   = TargetUnit,
                        TargetPosition = TargetUnit.Position
                    }.TryStartPerform();
                }
            }
        }
Beispiel #22
0
    public List <BattleCharacter> GetBattleCharacters(BattleCommand battleCommand, IReadOnlyCollection <BattleCharacter> Friend, IReadOnlyCollection <BattleCharacter> Opponent)
    {
        BattleCharacter owner       = battleCommand.owner;
        TargetType      targetType  = battleCommand.GetTargetType();
        TargetUnit      targetUnit  = targetType.targetUnit;
        TargetRange     targetRange = targetType.targetRange;
        IReadOnlyCollection <BattleCharacter> target = new List <BattleCharacter>();

        switch (targetUnit)
        {
        case TargetUnit.自分:
            return(new List <BattleCharacter>()
            {
                owner
            });

        case TargetUnit.味方:
            target = Friend;
            break;

        case TargetUnit.相手:
            target = Opponent;
            break;

        case TargetUnit.死亡者:
            target = Friend.Where(x => x.IsDead()).ToList();
            break;

        default:
            break;
        }

        switch (targetRange)
        {
        case TargetRange.単体:
            return(Randam(target));

        case TargetRange.全体:
            return(target.Cast <BattleCharacter>().ToList());

        default:
            break;
        }
        return(null);
    }
Beispiel #23
0
    public List <BattleCharacter> EnemyToFilter(BattleCharacter owner, TargetUnit targetUnit, TargetRange targetRange)
    {
        List <PlayerCharacter> playerCharacters = BattleController.instance.AlivePlayerCharacters;
        List <EnemyCharacter>  enemyCharacters  = BattleController.instance.AliveEnemyCharacters;

        IReadOnlyCollection <BattleCharacter> target = new List <BattleCharacter>();

        switch (targetUnit)
        {
        case TargetUnit.自分:
            return(new List <BattleCharacter>()
            {
                owner
            });

        case TargetUnit.味方:
            target = enemyCharacters;
            break;

        case TargetUnit.相手:
            target = playerCharacters;
            break;

        case TargetUnit.死亡者:
            target = enemyCharacters.Where(x => x.IsDead()).ToList();
            break;

        default:
            break;
        }

        switch (targetRange)
        {
        case TargetRange.単体:
            return(Randam(target));

        case TargetRange.全体:
            return(target.Cast <BattleCharacter>().ToList());

        default:
            break;
        }
        return(null);
    }
Beispiel #24
0
        /// <summary>
        /// Créer une interpolation entre un point a et b, avec a la position actuelle
        /// et b le prochain noeud du pathfinding (waypoints).
        /// On peut se permettre d'utiliser  Client.Send(new HeroSpawn2Message(NetId, Position.X, Position.Y));
        /// si l'on envoit pas MovementAnswerMessage pour pouvoir tester la qualitée de notre interpolation.
        /// </summary>
        /// <param name="deltaTime"></param>
        private void InterpolateMovement(float deltaTime)
        {
            if (IsMoving && !End)
            {
                float deltaMovement = Unit.Stats.MoveSpeed.TotalSafe * 0.001f * deltaTime; // deltaTime

                float xOffset = Direction.X * deltaMovement * 1.00f;
                float yOffset = Direction.Y * deltaMovement * 1.00f;

                Unit.Position = new Vector2(Unit.Position.X + xOffset, Unit.Position.Y + yOffset);

                if (TargetUnit != null)
                {
                    if (TargetUnit.GetDistanceTo(Unit) <= DistanceToTarget)
                    {
                        OnTargetReachAction();
                        End = true;
                        return;
                    }
                }


                if (Math.Abs(Unit.Position.X - NextPosition.Value.X) <= Math.Abs(xOffset) && Math.Abs(Unit.Position.Y - NextPosition.Value.Y) <= Math.Abs(yOffset))
                {
                    Unit.Position = NextPosition.Value;


                    WaypointsIndex++;

                    if (WaypointsIndex == Waypoints.Count)
                    {
                        End          = true;
                        PendingPoint = null;

                        if (TargetUnit != null)
                        {
                            OnTargetReachAction();
                        }
                    }
                }
            }
        }
Beispiel #25
0
    //バトルコマンドの効果を実行します
    public IEnumerator Execution(BattleCommand battleCommand)
    {
        BattleCharacter        owner      = battleCommand.owner;
        List <BattleCharacter> targets    = battleCommand.target;
        TargetUnit             targetUnit = battleCommand.GetTargetType().targetUnit;

        var effects = battleCommand.GetEffect();

        foreach (var effect in effects)
        {
            foreach (var target in targets)
            {
                if (!CanEffect(target, targetUnit))
                {
                    continue;
                }
                yield return(StartCoroutine(EffectExecution(effect, owner, target)));
            }
        }
        yield break;
    }
Beispiel #26
0
        // AI tasks
        protected bool ScanForTargets()
        {
            if (TargetUnit != null && !TargetUnit.IsDead && Vector2.Distance(TargetUnit.GetPosition(), this.GetPosition()) < DETECT_RANGE)
            {
                return(true);
            }
            IAttackableUnit nextTarget         = null;
            var             nextTargetPriority = 14;
            var             objects            = _game.ObjectManager.GetObjects();

            //Find target closest to max attack range.
            foreach (var it in objects.OrderBy(x => GetDistanceTo(x.Value) - Stats.Range.Total))
            {
                if (!(it.Value is IAttackableUnit u) ||
                    u.IsDead ||
                    u.Team == Team ||
                    GetDistanceTo(u) > DETECT_RANGE ||
                    !_game.ObjectManager.TeamHasVisionOn(Team, u))
                {
                    continue;
                }
                var priority = (int)ClassifyTarget(u); // get the priority.
                if (priority < nextTargetPriority)     // if the priority is lower than the target we checked previously
                {
                    nextTarget         = u;            // make him a potential target.
                    nextTargetPriority = priority;
                }
            }
            if (nextTarget != null)      // If we have a target
            {
                TargetUnit = nextTarget; // Set the new target and refresh waypoints
                _game.PacketNotifier.NotifySetTarget(this, nextTarget);
                return(true);
            }
            _game.PacketNotifier.NotifyNPC_InstantStopAttack(this, false);
            IsAttacking = false;
            return(false);
        }
Beispiel #27
0
    public TargetUnit GetTargetUnit(string targetName)
    {
        TargetUnit tu = new TargetUnit(targetName);

        return(tu);
    }
 protected override void StartPerform()
 {
     base.StartPerform();
     TargetUnit.LoopAnimation(UnitAnimations.Dazed);
     TargetUnit.CanPerformAbilitiesBlockers++;
 }
Beispiel #29
0
        public bool RecalculateAttackPosition()
        {
            if (Target != null && TargetUnit != null && !TargetUnit.IsDead && GetDistanceTo(Target) < CollisionRadius && GetDistanceTo(TargetUnit.X, TargetUnit.Y) <= Stats.Range.Total)//If we are already where we should be, do not move.
            {
                return(false);
            }
            var objects = _game.ObjectManager.GetObjects();
            List <CirclePoly> UsedPositions = new List <CirclePoly>();
            var isCurrentlyOverlapping      = false;

            var thisCollisionCircle = new CirclePoly(((Target)Target)?.GetPosition() ?? GetPosition(), CollisionRadius + 10);

            foreach (var gameObject in objects)
            {
                var unit = gameObject.Value as AttackableUnit;
                if (unit == null ||
                    unit.NetId == NetId ||
                    unit.IsDead ||
                    unit.Team != Team ||
                    unit.GetDistanceTo(TargetUnit) > DETECT_RANGE
                    )
                {
                    continue;
                }
                var targetCollisionCircle = new CirclePoly(((Target)unit.Target)?.GetPosition() ?? unit.GetPosition(), unit.CollisionRadius + 10);
                if (targetCollisionCircle.CheckForOverLaps(thisCollisionCircle))
                {
                    isCurrentlyOverlapping = true;
                }
                UsedPositions.Add(targetCollisionCircle);
            }
            if (isCurrentlyOverlapping)
            {
                var targetCircle = new CirclePoly(((Target)TargetUnit.Target)?.GetPosition() ?? TargetUnit.GetPosition(), Stats.Range.Total, 72);
                //Find optimal position...
                foreach (var point in targetCircle.Points.OrderBy(x => GetDistanceTo(X, Y)))
                {
                    if (_game.Map.NavGrid.IsWalkable(point))
                    {
                        var positionUsed = false;
                        foreach (var circlePoly in UsedPositions)
                        {
                            if (circlePoly.CheckForOverLaps(new CirclePoly(point, CollisionRadius + 10, 20)))
                            {
                                positionUsed = true;
                            }
                        }
                        if (!positionUsed)
                        {
                            SetWaypoints(new List <Vector2> {
                                GetPosition(), point
                            });
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Beispiel #30
0
 public TargetType(TargetUnit unit, TargetRange range)
 {
     this.targetUnit  = unit;
     this.targetRange = range;
 }