Ejemplo n.º 1
0
        IEnumerator Strafe()
        {
            //Debug.Log("readying to fire");
            AssessTarget();
            if (Target == null)
            {
                yield return(0);
            }
            var p = Target.transform.position;

            transform.up = aim();
            Speed        = MaxSpeed * 1.15f;
            float t = Vector2.Distance(p, transform.position) * 0.5f;

            t /= getDV();
            yield return(StartCoroutine(StaticUtilities.Wait(t)));

            AssessTarget();
            if (Target == null)
            {
                yield return(0);
            }
            fire();
            disengage();
            yield return(StartCoroutine(StaticUtilities.Wait(t * 3)));

            isAttacking = false;
        }
Ejemplo n.º 2
0
        IEnumerator ReadyFire()
        {
            //Debug.Log("readying to fire");
            AssessTarget();
            transform.up = aim();
            fire();
            yield return(StartCoroutine(StaticUtilities.Wait(reloadTime)));

            if (Target != null && Vector3.Distance(transform.position, Target.transform.position) <= maxAttackDistance)
            {
                StartCoroutine(ReadyFire());
            }
            else
            {
                isAttacking = false;
            }
        }
Ejemplo n.º 3
0
        IEnumerator TryPath()
        {
            //if agent is already has a path or is currently finding one dont do anything
            if (agent.pathPending || agent.hasPath)
            {
                yield return(0);
            }

            //try setting path to next waypoint
            agent.SetDestination(WayPoints[currWaypoint].position);

            //check for a lack of valid path
            if (!agent.pathPending && !agent.hasPath)
            {
                //clear prime goal so it trys to calculate path again
                agent.primeGoal = Vector2.zero;
                //wait a bit then try again
                yield return(StartCoroutine(StaticUtilities.Wait(0.75f)));

                yield return(StartCoroutine(TryPath()));
            }
        }