Exemplo n.º 1
0
        void updateTarget()
        {
            if (overridingTarget)
            {
                if (distance(Destination) <= 10)
                {
                    //successfully reached target;
                    overridingTarget = false;
                }
            }
            else
            {
                //remove dead or out of range targets
                BattleTargets.RemoveAll(target => target.isDead || target.distance(HitBox.Center) > sightRange);
                BattleTargets.OrderBy(target => target.distance(HitBox.Center));
                if (BattleTargets.Count > 0)
                {
                    //target nearest target
                    Destination = BattleTargets[0].HitBox.Center;
                }
                else
                {
                    Enemies.RemoveAll(target => target.isDead);
                    if (Enemies.Count > 0)
                    {
                        Enemies.OrderBy(target => target.distance(HitBox.Center));
                        //Destination = Enemies[0].HitBox.Center;
                        foreach (BattlePuppet enemy in Enemies)
                        {
                            checkTarget(enemy);
                        }
                    }
                    else
                    {
                        //no enemies, hoooraaaay!!
                        CurrentState = BattlePuppetState.Idle;
                        battleOver   = true;

                        //Destination = HitBox.Center;
                    }
                }
            }
        }
Exemplo n.º 2
0
        //if target is in hitting range
        bool inRangeOfTarget()
        {
            //remove dead or out of range targets
            BattleTargets.RemoveAll(target => target.isDead || target.distance(HitBox.Center) > sightRange);
            BattleTargets.OrderBy(target => target.distance(HitBox.Center));

            if (BattleTargets.Count > 0)
            {
                if (distance(BattleTargets[0].HitBox.Center) <= Unit.Range)
                {
                    return(true);
                }
            }
            else
            {
                CurrentState = BattlePuppetState.Walking;
            }
            return(false);
        }