IEnumerable <Instruction> RunEndGameCredits() { _OverlayCanvas.gameObject.SetActive(true); _StartingText.rectTransform.localPosition = new Vector3(_StartingText.rectTransform.localPosition.x, -100f, _StartingText.rectTransform.localPosition.z); _StartingText.rectTransform.LookAt(-Camera.main.transform.position); _StartingText.color = Color.white; //_OverlayCanvas.transform.GetChild(0).GetComponent<Image>().CrossFadeAlpha(1f, 5f, true); LeanTween.color(_OverlayCanvas.transform.GetChild(0).transform as RectTransform, Color.black, 5f).setUseEstimatedTime(true); var text = _OverlayCanvas.transform.GetChild(1).GetComponent <Text>(); //text.gameObject.SetActive(true); text.color = new Color(1f, 1f, 1f, 0f); //text.CrossFadeAlpha(1f, 5f, true); //LeanTween.color(text.rectTransform, new Color(1f, 1f, 1f, 1f), 5f).setUseEstimatedTime(true); LeanTween.textAlpha(text.rectTransform, 1f, 5f).setUseEstimatedTime(true); text.text = LargeSize + "Your score!\n" + EndSize + GameMachine.Instance.Points + "\n\nProperty Damage: " + GameMachine.Instance.Damage.ToString("C") + "\n\nHighest Multiplier Gained: " + Multiplier.Highest; //LeanTween.value(gameObject, // c => { // _OverlayCanvas.transform.GetChild(0).GetComponent<Image>().CrossFadeAlpha(1f, 5f, true); // }, // new Color(0f, 0f, 0f, 0f), new Color(0f, 0f, 0f, 1f), 5f); GameMachine.Instance.OpenTween("CreditsScroller", 190); LeanTween.moveLocalY(_StartingText.gameObject, 0f, 10f).onComplete = () => GameMachine.Instance.CloseTween("CreditsScroller", 190); yield return(ControlFlow.Call(Wait(10f))); _OverlayCanvas.transform.GetChild(2).gameObject.SetActive(true); }
IEnumerable <Instruction> Idle(float defaultAngle) { // Rotate back to default position yield return(ControlFlow.Call(RotateTo(defaultAngle, _RandomLookRotationSpeed))); // Then blink our mohawk try { MaterialPropertyBlock block = new MaterialPropertyBlock(); while (true) { block.SetColor("_EmissionColor", Color.red); Mohawk.SetPropertyBlock(block); yield return(Utils.WaitForSeconds(0.5f)); block.SetColor("_EmissionColor", Color.white); Mohawk.SetPropertyBlock(block); yield return(Utils.WaitForSeconds(0.5f)); } } finally { // Reset the mohawk Mohawk.SetPropertyBlock(null); } }
IEnumerable <Instruction> FadeIn(float duration) { GameMachine.Instance.OpenTween("CreditsScroller", 115); LeanTween.textColor(_StartingText.rectTransform, Color.black, duration).onComplete = () => GameMachine.Instance.CloseTween("CreditsScroller", 115); yield return(ControlFlow.Call(Wait(duration))); }
IEnumerable <Instruction> Idle() { while (true) { Vector2 randVector = Random.insideUnitCircle.normalized; Vector3 startPos = transform.position; Vector3 moveTarget = new Vector3(randVector.x, randVector.y) * moveRadius + transform.position; yield return(ControlFlow.Call(RotateFor(randVector, rotateSpeedMove))); while (transform.position != moveTarget) { transform.position = Vector3.MoveTowards(transform.position, moveTarget, moveSpeed * Time.deltaTime); yield return(null); } yield return(Utils.WaitForSeconds(CD_Time_Idle)); yield return(ControlFlow.Call(RotateFor(-randVector, rotateSpeedMove))); while (transform.position != startPos) { transform.position = Vector3.MoveTowards(transform.position, startPos, moveSpeed * Time.deltaTime); yield return(null); } yield return(Utils.WaitForSeconds(CD_Time_Idle)); } }
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> TestBehaviourCodeUsedAsCoroutine() { Debug.Log("Testing behaviour graph"); // We're calling code that is normally used for behaviour graphs, we just ignore the return values... yield return(ControlFlow.Call <Behaviours.BehaviourValue, Behaviours.BehaviourState>(SomeBehaviourGraphCode())); Debug.Log("End of testing behaviour graph"); }
IEnumerable <Instruction> Main() { //yield return ControlFlow.Call(TestCall()); //yield return ControlFlow.Call(TestConcurrent()); yield return(ControlFlow.Call(TestMasterSlave())); //yield return ControlFlow.Call(TestControlFlowReturnValue()); //yield return ControlFlow.Call(TestBehaviourGraph()); }
///--------------------------------------------------------------------------------------- IEnumerable <Instruction> TestControlFlowReturnValue() { int generatorResult = 0; yield return(ControlFlow.Call(WaitAndResultInt(res => generatorResult = res))); Debug.Log("returned value is " + generatorResult); }
//技能容器 IEnumerable <Instruction> Sprint(Transform target, float speedOrTime, bool aftermath = false) { try { anim.SetBool("Skill3", true); bool rand = target.position.x < SceneCenter.position.x; if (!aftermath) { //一阶段技能表现 for (int i = 0; i < paraStartPosList.Count - 1; i++) { int p = rand ? i : (paraStartPosList.Count - 1 - i); yield return(ControlFlow.Call(MoveTo(paraStartPosList[p].position, true))); skill3.enabled = true; if (paraBottomPosList[rand ? p : (p - 1)].position.x > paraStartPosList[p].position.x) { sr.flipX = true; } else { sr.flipX = false; } yield return(ControlFlow.Call(Para(paraBottomPosList[rand ? p : (p - 1)], speedOrTime))); } } else { //二阶段技能表现 for (int i = 0; i < sprintPosList.Count; i++) { int p = rand ? i : (sprintPosList.Count - i - 1); if (sprintPosList[p].position.x > transform.position.x) { sr.flipX = true; } else { sr.flipX = false; } yield return(ControlFlow.Call(MoveTo(sprintPosList[p].position, speedOrTime))); skill3.enabled = true; } } anim.SetBool("Skill3", false); skill3.enabled = false; } finally { skill3.enabled = false; anim.SetBool("Skill3", false); } }
IEnumerable <Instruction> ScrollCredits() { var timePerScreen = 10f; PopulateCredits(_ScrollText1, true); PopulateCredits(_ScrollText2); PopulateCredits(_ScrollText3); var startY = _StartingText.rectTransform.localPosition.y; GameMachine.Instance.OpenTween("CreditsScroller", 130); LeanTween.moveLocalY(_StartingText.gameObject, startY + 100f, timePerScreen).onComplete = () => GameMachine.Instance.CloseTween("CreditsScroller", 130); var texts = new List <Text>() { _ScrollText1, _ScrollText2, _ScrollText3 }; for (int j = 0; j < 2; j++) { for (int i = 0; i < texts.Count; i++) { startY = texts[i].rectTransform.localPosition.y; GameMachine.Instance.OpenTween("CreditsScroller", 142); LeanTween.moveLocalY(texts[i].gameObject, startY + 100f, timePerScreen).onComplete = () => GameMachine.Instance.CloseTween("CreditsScroller", 142); } yield return(ControlFlow.Call(Wait(timePerScreen))); GameMachine.Instance.StartGame(); } while (true) { for (int i = 0; i < texts.Count; i++) { startY = texts[i].rectTransform.localPosition.y; GameMachine.Instance.OpenTween("CreditsScroller", 156); LeanTween.moveLocalY(texts[i].gameObject, startY + 100f, timePerScreen).onComplete = () => GameMachine.Instance.CloseTween("CreditsScroller", 156); } yield return(ControlFlow.Call(Wait(timePerScreen))); var moveToEnd = texts[0]; texts.RemoveAt(0); texts.Add(moveToEnd); moveToEnd.rectTransform.localPosition += new Vector3(0, -300f, 0); PopulateCredits(moveToEnd); } }
//阶段主循环 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(); } }
//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> Phase(Transform target, bool aftermath = false) { try { SkillList.Clear(); SkillList.Add(StoneFall(target, aftermath)); SkillList.Add(Splash(target, aftermath)); int curr = SkillSelect(SkillList.Count); while (true) { yield return(ControlFlow.Call(SkillList[curr])); yield return(Utils.WaitForSeconds(CD_Time)); curr = SkillSelect(SkillList.Count, curr); } } finally { SkillList.Clear(); } }
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> RunTransition() { var overlayCanvas = CreditsScroller.Instance._OverlayCanvas; var image = overlayCanvas.transform.GetChild(0); var text = overlayCanvas.transform.GetChild(1); // fade out overlayCanvas.gameObject.SetActive(true); text.gameObject.SetActive(false); LeanTween.color(image.transform as RectTransform, Color.black, 1f); yield return(ControlFlow.Call(Wait(1f))); // swap _mousePlayer.SetActive(true); _vrPlayer.SetActive(true); CreditsScroller.Instance.DisableCreditOverlay(); LeanAudio.playAudio(_announcerClips[UnityEngine.Random.Range(0, _announcerClips.Length)], transform.position, 1f, 1f); yield return(null); Camera.main.gameObject.SetActive(false); _cameraStartup.gameObject.SetActive(true); // fade in LeanTween.color(image.transform as RectTransform, new Color(1f, 1f, 1f, 0f), 1f); yield return(ControlFlow.Call(Wait(1f))); // end text.gameObject.SetActive(true); overlayCanvas.gameObject.SetActive(false); }
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)); } }
private static IEnumerable <Instruction> IncrementalEvaluate(InfluenceMapEvaluator evaluator) { // this is largely rewritten from HBS code, and not subject to license var evalTrav = Traverse.Create(evaluator); evalTrav.Method("ProfileFrameBegin").GetValue(); evalTrav.Method("ProfileBegin", ProfileSection.AllInfluenceMaps).GetValue(); yield return(ControlFlow.Call(evalTrav.Method("Eval_Initialize").GetValue <IEnumerable <Instruction> >())); yield return(ControlFlow.Call(EvalFactors(evaluator))); yield return(ControlFlow.Call(evalTrav.Method("Apply_SprintScaling").GetValue <IEnumerable <Instruction> >())); evaluator.expectedDamageFactor.LogEvaluation(); evalTrav.Field("evaluationComplete").SetValue(true); evalTrav.Method("ProfileEnd", ProfileSection.AllInfluenceMaps).GetValue(); evalTrav.Method("ProfileFrameEnd").GetValue(); yield return(null); }
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())); } }