//阶段主循环 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(); } }
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; } } } }
//闲置状态 IEnumerable <Instruction> Idle(Transform target) { bool right = transform.rotation.eulerAngles != Vector3.zero; try { while (true) { yield return(ControlFlow.ExecuteWhile( () => Mathf.Abs(target.position.x - transform.position.x) > stopDist, Move(right, isright => right = isright) )); yield return(ControlFlow.ExecuteWhile( () => Mathf.Abs(target.position.x - transform.position.x) > stopstopDist, TrackTarget(target, right, isright => right = isright) )); yield return(null); } } finally { transform.eulerAngles = new Vector3(0, right ? 180 : 0); } }
IEnumerable <Instruction> Main() { bool gotFirst = false; bool finished = false; yield return(ControlFlow.ExecuteWhile( () => !finished, Throw(transform.rotation.eulerAngles.y == 0), CheckFirst(success => { gotFirst = success; finished = success; }), TimeOut(liveTime, finish => finished = finish) )); if (gotFirst) { List <GameObject> aims = new List <GameObject>(); bool gotOthers = false; yield return(ControlFlow.Call(Search(success => gotOthers = success, result => aims = result))); if (gotOthers) { for (int i = 0; i < HitTimes; i++) { yield return(ControlFlow.Call(Attack(aims[i % aims.Count]))); } } } Destroy(gameObject); }
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() )); } } }
// 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())); } } }
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))); } } }
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); }
IEnumerable <Instruction> Splash(Transform target, bool aftermath = false) { anim.SetTrigger("Attack2"); bool left = target.position.x < transform.position.x; GameObject obj = aftermath ? (left ? inkObject_Left : inkObject) : (left ? inkObject_Naive_Left : inkObject_Naive); obj.SetActive(true); yield return(ControlFlow.ExecuteWhile(() => obj.activeSelf, Donothing())); anim.SetTrigger("Stop"); }
IEnumerable <Instruction> Main() { try { yield return(ControlFlow.ExecuteWhile( () => !hp.dead, Cycle() )); yield break; } finally { anim.SetTrigger("Die"); } }
IEnumerable <Instruction> TestAdapter() { // Control execution of two slaves based on value returned by master yield return(ControlFlow.ExecuteWhile( Utils.Adapt(TestMasterFloat(), floatVal => floatVal > 1.0f), boolVal => boolVal == true, TestSlave(5), TestSlave(10))); // Alternate syntax yield return(ControlFlow.ExecuteWhile( TestMasterFloat().Adapt(floatVal => floatVal > 1.0f), boolVal => boolVal == true, TestSlave(5), TestSlave(10))); }
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"); } } }
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) )); } } }
//public void T // Root coroutine IEnumerable <Instruction> Main() { _StartingText.text = StaticIntro; _StartingText.color = new Color(0, 0, 0, 0); yield return(ControlFlow.Call(Wait(2))); yield return(ControlFlow.Call(FadeIn(2))); yield return(ControlFlow.Call(Wait(4))); LeanTween.delayedCall(10f, GameMachine.Instance.TransitionToPlayer); yield return(ControlFlow.ExecuteWhile(() => !isEnding, ScrollCredits())); yield return(ControlFlow.Call(RunEndGameCredits())); }
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() )); } } }
IEnumerable <Instruction> Main() { while (true) { Transform target = null; yield return(ControlFlow.Call(FindTargetInRadius(catchRange, trgt => target = trgt))); if (target != null) { while (true) { if (gothit) { gothit = false; break; } yield return(ControlFlow.ExecuteWhile(() => !gothit, Cycle(target))); } } } }
///--------------------------------------------------------------------------------------- IEnumerable <Instruction> TestMasterSlave() { // Do some stuff Debug.Log("Beginning test 3, frame #" + Time.frameCount); try { // Control execution of two slaves based on running state of master //yield return ControlFlow.ExecuteWhileRunning(TestMaster(), TestSlave(15), TestSlave(30)); // Alternate syntax: yield return(ControlFlow.ExecuteWhile(Utils.TrueWhileRunning(TestMaster()), running => running == true, TestSlave(15), TestSlave(30))); // Control execution of two slaves based on value returned by master yield return(ControlFlow.ExecuteWhile(TestMasterFloat(), val => val < 1.0f, TestSlave(5), TestSlave(10))); } finally { Debug.Log("Finishing test 3 frame #" + Time.frameCount); } }
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))); } } }
IEnumerable <Instruction> Rush(Transform target, bool aftermath = false) { try { skill2Object.GetComponent <Collider2D>().enabled = true; anim.SetBool("Skill2", true); yield return(Utils.WaitForFrames(20)); Vector3 targetPos = transform.position + new Vector3((target.position.x > transform.position.x ? sprintDistance : -sprintDistance) * (aftermath?1.1f:1), 0); yield return(ControlFlow.ExecuteWhile( () => !(isWall || transform.position == targetPos), MoveTo(targetPos, sprintSpeed * (aftermath?1.5f:1)), CreateShadow() )); anim.SetBool("Skill2", false); skill2Object.GetComponent <Collider2D>().enabled = false; } finally { anim.SetBool("Skill2", false); skill2Object.GetComponent <Collider2D>().enabled = false; } }
IEnumerable <Instruction> Main() { SkillList = new List <IEnumerable <Instruction> >(); SkillList.Clear(); Transform Target = null; yield return(ControlFlow.Call(FindPlayer(target => Target = target))); if (Target != null) { var hpObject = GetComponent <BossHp>(); yield return(ControlFlow.ExecuteWhile( () => hpObject.Hp > hpObject.HpMax * 0.5, Phase(Target))); yield return(ControlFlow.Call(Change())); yield return(ControlFlow.ExecuteWhile( () => hpObject.Hp > 0, Phase(Target, true))); yield return(ControlFlow.Call(BeforeDie())); } }