Example #1
0
        public void RetreatUpdate(float dt)
        {
            if (EnemyInRange(champion.GetInfo().viewRadius) && currentLane != null)
            {
                targetPos = nextTarget;
                Vector3 diff   = nextTarget - champion.GetPosition();
                float   length = diff.Length();
                diff /= length;
                if (length < 5)
                {
                    targetID--;
                    if (targetID < 0)
                    {
                        targetID = 0;
                    }
                    nextTarget = currentLane.Waypoints[targetID];
                }
            }
            else
            {
                if (!champion.GoingBack)
                {
                    champion.GoBack();
                    targetPos = champion.GetPosition();
                }
            }

            if (champion.GetHealth() > champion.GetInfo().maxHealth * 0.4f)
            {
                currentLane = null;
                targetID    = 0;
                state       = TestControllerState.Laning;
            }
        }
Example #2
0
 public void AttackUpdate(float dt)
 {
     targetPos = currentEnemy.GetPosition();
     Vector3 diff = currentEnemy.GetPosition() - champion.GetPosition();
     float length = diff.Length();
     diff /= length;
     if (champion.InRange(currentEnemy))
     {
         champion.Attack(currentEnemy);
         targetPos = champion.GetPosition();
     }
     if (currentEnemy.IsDead())
     {
         currentEnemy = null;
         state = TestControllerState.Laning;
     }
 }
Example #3
0
        public void AttackUpdate(float dt)
        {
            targetPos = currentEnemy.GetPosition();
            Vector3 diff   = currentEnemy.GetPosition() - champion.GetPosition();
            float   length = diff.Length();

            diff /= length;
            if (champion.InRange(currentEnemy))
            {
                champion.Attack(currentEnemy);
                targetPos = champion.GetPosition();
            }
            if (currentEnemy.IsDead())
            {
                currentEnemy = null;
                state        = TestControllerState.Laning;
            }
        }
Example #4
0
        public void LaneUpdate(float dt)
        {
            if (currentLane == null)
            {
                Team team = champion.GetTeam();
                targetID = 0;
                int index = MobaGame.random.Next(map.Lanes.Length);
                if (map.Lanes[index].Team == team)
                {
                    currentLane = map.Lanes[index];
                }
                if (currentLane != null)
                {
                    nextTarget = currentLane.Waypoints[0];
                }
            }

            targetPos = nextTarget;
            Vector3 diff   = nextTarget - champion.GetPosition();
            float   length = diff.Length();

            diff /= length;
            if (length < 5)
            {
                targetID++;
                if (targetID >= currentLane.Waypoints.Length)
                {
                    targetID = currentLane.Waypoints.Length - 1;
                }
                nextTarget = currentLane.Waypoints[targetID];
            }

            TryFindTarget();
            if (currentEnemy != null)
            {
                state = TestControllerState.Attacking;
            }
        }
Example #5
0
        public override void Update(float dt)
        {
            //Make sure we retreat when we're dying
            if (champion.GetHealth() < champion.GetInfo().maxHealth * 0.2f && state != TestControllerState.Retreating)
            {
                state        = TestControllerState.Retreating;
                currentEnemy = null;
                if (currentLane != null)
                {
                    targetID--;
                    if (targetID < 0)
                    {
                        targetID = 0;
                    }
                    nextTarget = currentLane.Waypoints[targetID];
                    targetPos  = nextTarget;
                }
            }

            switch (state)
            {
            case TestControllerState.Retreating: RetreatUpdate(dt); break;

            case TestControllerState.Laning: LaneUpdate(dt); break;

            case TestControllerState.Attacking: AttackUpdate(dt); break;
            }

            Vector3 tp;

            if (evade)
            {
                tp = evasionTarget;
            }
            else
            {
                tp = targetPos;
            }

            Vector3 tdiff   = tp - champion.GetPosition();
            float   tlength = tdiff.Length();

            tdiff /= tlength;
            if (tlength > 0)
            {
                Vector3 predictedPosition = champion.GetPosition() + tdiff * champion.GetInfo().movespeed * 0.5f;

                if (map.InCollision(predictedPosition))
                {
                    evade = true;
                    ICollidable collider = map.GetCollider(predictedPosition);
                    if (collider != null)
                    {
                        Vector3 vertex = collider.Bounds.GetEdgeToCircumvent(champion.GetPosition(), tp);;
                        Vector3 dir    = vertex - collider.Bounds.Center;
                        dir          /= dir.Length();
                        evasionTarget = vertex + dir;
                    }
                }

                champion.Move(tdiff * champion.GetInfo().movespeed *dt);
            }

            if (evade && tlength < 1)
            {
                evade = false;
            }
        }
Example #6
0
 public TestController(Map map, Champion champion)
     : base(map, champion)
 {
     state = TestControllerState.Laning;
 }
Example #7
0
        public void LaneUpdate(float dt)
        {
            if (currentLane == null)
            {
                Team team = champion.GetTeam();
                targetID = 0;
                int index = MobaGame.random.Next(map.Lanes.Length);
                if (map.Lanes[index].Team == team)
                    currentLane = map.Lanes[index];
                if (currentLane != null)
                    nextTarget = currentLane.Waypoints[0];
            }

            targetPos = nextTarget;
            Vector3 diff = nextTarget - champion.GetPosition();
            float length = diff.Length();
            diff /= length;
            if (length < 5)
            {
                targetID++;
                if (targetID >= currentLane.Waypoints.Length)
                    targetID = currentLane.Waypoints.Length - 1;
                nextTarget = currentLane.Waypoints[targetID];
            }

            TryFindTarget();
            if (currentEnemy != null)
                state = TestControllerState.Attacking;
        }
Example #8
0
 public TestController(Map map, Champion champion)
     : base(map, champion)
 {
     state = TestControllerState.Laning;
 }
Example #9
0
        public override void Update(float dt)
        {
            //Make sure we retreat when we're dying
            if (champion.GetHealth() < champion.GetInfo().maxHealth * 0.2f && state != TestControllerState.Retreating)
            {
                state = TestControllerState.Retreating;
                currentEnemy = null;
                if (currentLane != null)
                {
                    targetID--;
                    if (targetID < 0) targetID = 0;
                    nextTarget = currentLane.Waypoints[targetID];
                    targetPos = nextTarget;
                }
            }

            switch(state)
            {
                case TestControllerState.Retreating: RetreatUpdate(dt); break;
                case TestControllerState.Laning: LaneUpdate(dt); break;
                case TestControllerState.Attacking: AttackUpdate(dt); break;
            }

            Vector3 tp;
            if (evade)
                tp = evasionTarget;
            else
                tp = targetPos;

            Vector3 tdiff = tp - champion.GetPosition();
            float tlength = tdiff.Length();
            tdiff /= tlength;
            if (tlength > 0)
            {
                Vector3 predictedPosition = champion.GetPosition() + tdiff * champion.GetInfo().movespeed * 0.5f;

                if (map.InCollision(predictedPosition))
                {
                    evade = true;
                    ICollidable collider = map.GetCollider(predictedPosition);
                    if (collider != null)
                    {
                        Vector3 vertex = collider.Bounds.GetEdgeToCircumvent(champion.GetPosition(), tp); ;
                        Vector3 dir = vertex - collider.Bounds.Center;
                        dir /= dir.Length();
                        evasionTarget = vertex + dir;
                    }
                }

                champion.Move(tdiff * champion.GetInfo().movespeed * dt);
            }

            if (evade && tlength < 1)
                evade = false;
        }
Example #10
0
        public void RetreatUpdate(float dt)
        {
            if(EnemyInRange(champion.GetInfo().viewRadius) && currentLane!=null)
            {
                targetPos = nextTarget;
                Vector3 diff = nextTarget - champion.GetPosition();
                float length = diff.Length();
                diff /= length;
                if (length < 5)
                {
                    targetID--;
                    if (targetID < 0)
                        targetID = 0;
                    nextTarget = currentLane.Waypoints[targetID];
                }
            }
            else
            {
                if (!champion.GoingBack)
                {
                    champion.GoBack();
                    targetPos = champion.GetPosition();
                }
            }

            if (champion.GetHealth() > champion.GetInfo().maxHealth * 0.4f)
            {
                currentLane = null;
                targetID = 0;
                state = TestControllerState.Laning;
            }
        }