예제 #1
0
    IEnumerable <Instruction> Main()
    {
        while (true)
        {
            Transform target = null;
            yield return(ControlFlow.ExecuteWhileRunning(
                             FindTargetInRectangle(catchXRange, catchYRange, trgt => target = trgt),
                             Idle(isright => right = isright)
                             ));

            if (target != null)
            {
                yield return(ControlFlow.ExecuteWhile(
                                 //WaitForSecondsCr(CD_Time),
                                 () => Mathf.Abs(transform.position.x - target.position.x) >= attackRange,
                                 TrackTarget(target, isright => right = isright)
                                 ));

                yield return(ControlFlow.ExecuteWhile(
                                 () => Mathf.Abs(transform.position.x - target.position.x) < attackRange || attacking,
                                 Attack()
                                 ));
            }
        }
    }
예제 #2
0
    // Root Coroutine
    IEnumerable <Instruction> Main()
    {
        // Save the initial orientation, we'll pass it to the Idle subroutine
        float startYAngle = transform.rotation.eulerAngles.y;

        while (true)
        {
            // Look for a target
            Transform target = null;

            yield return(ControlFlow.ExecuteWhileRunning(
                             // This is the master, it looks for a target, puts it in 'target' before completing
                             FindTargetInRadius(_LockOnRadius, trgt => target = trgt),

                             // This happens for as long as we're looking for a target
                             Idle(startYAngle)));

            // Track the target and shoot at it simultaneously
            if (target != null)
            {
                yield return(ControlFlow.ExecuteWhile(
                                 // Condition
                                 () => Vector3.Distance(target.position, transform.position) < _LockOffRadius,

                                 // Is executed while the condition is true, tracks the target
                                 TrackTarget(target),

                                 // Also executed while the condition is true, Fires projectiles
                                 FireProjectiles()));
            }
        }
    }
예제 #3
0
파일: Boss1Ai.cs 프로젝트: pyh0884/Retrieve
    //阶段主循环
    IEnumerable <Instruction> Phase(Transform target, bool aftermath = false)
    {
        try
        {
            SkillList.Clear();
            SkillList.Add(StoneSpawn(target, aftermath));
            SkillList.Add(Rush(target, aftermath));
            SkillList.Add(JumpInParabola(target, aftermath));
            SkillList.Add(OpenShield(target, aftermath));
            needRefill = false;
            //增加技能列表内的项目,有新技能就在这里加上

            float y    = transform.position.y;
            int   curr = SkillSelect(SkillList.Count);
            while (true)
            {
                yield return(ControlFlow.ExecuteWhileRunning(
                                 WaitForSecondsCr(pubCDTime),
                                 Idle(target)
                                 ));

                //while (!isGround) { enemyRigidBody.bodyType = RigidbodyType2D.Dynamic; yield return null; }
                //enemyRigidBody.bodyType = RigidbodyType2D.Kinematic;
                bool right = transform.rotation.eulerAngles != Vector3.zero;
                yield return(ControlFlow.ExecuteWhileRunning(SkillList[curr], TrackTarget(target, right, isright => right = isright)));

                curr = SkillSelect(SkillList.Count, curr);
                yield return(ControlFlow.ExecuteWhile(() => !Grounded, MoveTo(new Vector3(transform.position.x, y))));
            }
        }
        finally {
            SkillList.Clear();
        }
    }
예제 #4
0
    IEnumerable <Instruction> Main()
    {
        while (true)
        {
            Transform target = null;
            yield return(ControlFlow.ExecuteWhileRunning(
                             FindTargetInRadius(catchRange, trgt => target = trgt),
                             Idle()
                             ));

            if (target != null)
            {
                yield return(ControlFlow.ExecuteWhile(
                                 () => Mathf.Abs(target.position.x - transform.position.x) > attackRange,
                                 ChaseTarget(target),
                                 TrackTarget(target, isright => right = isright)
                                 ));

                yield return(ControlFlow.ExecuteWhile(
                                 () => Mathf.Abs(target.position.x - transform.position.x) < catchRange && !gotHit,
                                 log(),
                                 ArrowAttack(target),
                                 TrackTarget(target, isright => right = isright)
                                 ));

                if (gotHit)
                {
                    gotHit = false;
                }
            }
        }
    }
예제 #5
0
    IEnumerable <Instruction> Main()
    {
        float startZAngle = Child.localRotation.eulerAngles.z;

        while (true)
        {
            Transform target = null;

            yield return(ControlFlow.ExecuteWhileRunning(
                             FindTargetInRadius(_LockOnRadius, trgt => target = trgt),

                             Idle(startZAngle, num => goalNum = num)));

            if (target != null)
            {
                yield return(ControlFlow.ExecuteWhile(

                                 () => Vector3.Distance(target.position, transform.position) < _LockOffRadius,

                                 TrackTarget(target),

                                 FireProjectiles(),

                                 Idle(startZAngle, num => goalNum = num)));
            }
        }
    }
예제 #6
0
    IEnumerable <Instruction> Strike(Transform target, Transform curr, System.Action <bool> need)
    {
        gothit = false;
        yield return(ControlFlow.ExecuteWhileRunning(WaitForSecondsCr(CD_Time_Strike), FocusOn(target, curr)));

        yield return(ControlFlow.ExecuteWhileRunning(BackShake(2.0f, curr), FocusOn(target, curr)));

        yield return(ControlFlow.ExecuteWhile(() => !gothit, StrikeMove(target, curr)));

        need(true);
    }
예제 #7
0
    IEnumerable <Instruction> Cycle(Transform target)
    {
        try
        {
            bool Detached = false;
            yield return(ControlFlow.ExecuteWhile(
                             () => !Detached,
                             FocusOn(target, transform),
                             Prepare(target, detached => Detached = detached)
                             ));

            if (ViceLeft == null)
            {
                ViceLeft = Instantiate(shadowPrefab, transform.position, Quaternion.identity).transform;
            }
            if (ViceRight == null)
            {
                ViceRight = Instantiate(shadowPrefab, transform.position, Quaternion.identity).transform;
            }
            bool needReGrid = false;
            yield return(ControlFlow.ExecuteWhileRunning(
                             GridLie(transform, ViceLeft, false),
                             GridLie(transform, ViceRight, true),
                             FocusOn(target, transform),
                             FocusOn(target, ViceLeft),
                             FocusOn(target, ViceRight)
                             ));

            needReGrid = false;
            yield return(ControlFlow.ExecuteWhile(
                             () => !needReGrid,
                             Strike(target, transform, need => needReGrid = need),
                             Strike(target, ViceLeft, need => needReGrid = need),
                             Strike(target, ViceRight, need => needReGrid = need)
                             ));
        }
        finally {
            if (ViceLeft.GetComponent <Animator>() != null)
            {
                ViceLeft.GetComponent <Animator>().SetTrigger("Die");
            }
            if (ViceRight.GetComponent <Animator>() != null)
            {
                ViceRight.GetComponent <Animator>().SetTrigger("Die");
            }
        }
    }
예제 #8
0
파일: Ghost.cs 프로젝트: pyh0884/Retrieve
    IEnumerable <Instruction> Main()
    {
        while (true)
        {
            target = null;
            yield return(ControlFlow.ExecuteWhileRunning(FindTargetInRadius(catchRange, trgt => target = trgt)));

            if (target != null)
            {
                yield return(ControlFlow.ExecuteWhile(
                                 () => Vector3.Distance(target.position, transform.position) < lostRange,
                                 Attack(target),
                                 TrackTarget(target, isright => right = isright)
                                 ));
            }
        }
    }
예제 #9
0
    //阶段主循环
    IEnumerable <Instruction> Phase(Transform target, bool aftermath = false)
    {
        try
        {
            SkillList.Clear();
            if (!aftermath)
            {
                SkillList.Add(Sprint(target, paraHalfTime));              //0
                SkillList.Add(GhostFire(target, phase1MissileAmount));    //1
                SkillList.Add(Stab(target, stabCallNum1));                //2
            }
            else
            {
                SkillList.Add(Sprint(target, paraHalfTime / 2));                //0
                SkillList.Add(GhostFire(target, phase2MissileAmount));          //1
                SkillList.Add(Stab(target, stabCallNum2));                      //2
                SkillList.Add(Sprint(target, sprintSpeedFast, aftermath));      //3
                SkillList.Add(GhostFire(target, viceMissileAmount, aftermath)); //4
                SkillList.Add(Stab(target, stabGapFrame, aftermath));           //5
            }
            int curr = SkillSelect(SkillList.Count);
            while (true)
            {
                int p = curr % (SkillList.Count / (aftermath ? 2 : 1));
                //yield return ControlFlow.Call(MoveTo(SceneCenter.position));
                Vector3 stage = new Vector3(target.position.x > SceneCenter.position.x ? 2 * SceneCenter.position.x - skillActPos[p].position.x : skillActPos[p].position.x, skillActPos[p].position.y);
                yield return(ControlFlow.ExecuteWhileRunning(
                                 MoveTo(stage),
                                 TrackTarget(target, sr.flipX, isright => sr.flipX = isright)
                                 ));

                yield return(ControlFlow.Call(SkillList[curr]));

                yield return(ControlFlow.ExecuteWhileRunning(
                                 Restore(CD_Time, skillRestPos[Random0ToN(SkillList.Count / (aftermath ? 2 : 1))].position),
                                 TrackTarget(target, sr.flipX, isright => sr.flipX = isright)
                                 ));

                curr = SkillSelect(SkillList.Count, curr);
            }
        }
        finally
        {
            SkillList.Clear();
        }
    }
예제 #10
0
    IEnumerable <Instruction> Cycle()
    {
        Transform target = null;

        while (true)
        {
            yield return(ControlFlow.ExecuteWhileRunning(
                             FindTargetInRadius(catchRange, trgt => target = trgt),
                             Idle()));

            if (target != null)
            {
                yield return(ControlFlow.ExecuteWhile(
                                 () => Vector3.Distance(target.position, transform.position) < lostRange,
                                 Attack()
                                 ));
            }
        }
    }
예제 #11
0
    IEnumerable <Instruction> Main()
    {
        while (true)
        {
            Transform target = null;
            yield return(ControlFlow.ExecuteWhileRunning(
                             FindTargetInRadius(catchRange, trgt => target = trgt),
                             Idle()
                             ));

            if (target != null)
            {
                if (gotHit)
                {
                    yield return(Utils.WaitForSeconds(CD_Time_Strike));

                    gotHit = false;
                }
                yield return(ControlFlow.ExecuteWhile(() => !gotHit, Strike(target)));
            }
        }
    }
예제 #12
0
    IEnumerable <Instruction> Strike(Transform target)
    {
        Vector3 dist, strikeTarget;

        while (true)
        {
            dist         = target.position - transform.position;
            strikeTarget = target.position + extraDist * dist.normalized;
            yield return(ControlFlow.ExecuteWhileRunning(WaitForSecondsCr(0.5f), RotateFor(dist, rotateSpeedStrike)));

            yield return(ControlFlow.Call(BackShake(backDist)));

            anim.SetTrigger("Attack");
            while (transform.position != strikeTarget)
            {
                transform.position = Vector3.MoveTowards(transform.position, strikeTarget, strikeSpeed * Time.deltaTime);
                //Debug.Log("Striking");
                yield return(null);
            }
            yield return(Utils.WaitForSeconds(CD_Time_Strike));
        }
    }
예제 #13
0
 ///---------------------------------------------------------------------------------------
 IEnumerable <Instruction> TestBehaviourGraph()
 {
     yield return(ControlFlow.ExecuteWhileRunning(Wait30Frames(), TestBehaviourCodeUsedAsCoroutine()));
 }