IEnumerator MainAILoop() { Dev.Where(); for (; ;) { yield return(new WaitForEndOfFrame()); if (stuns >= maxStuns) { break; } if (isSuspended) { continue; } if (hitsTaken < hitsToStun) { continue; } yield return(Stun()); } this.enabled = false; }
protected virtual IEnumerator MainAILoop() { Dev.Where(); for (;;) { if (!Running) { break; } yield return(currentState); if (nextState != null) { //TODO: remove as the states get implemented //Dev.Log( "State Complete - Hit N to advance" ); //while( !Input.GetKeyDown( KeyCode.N ) ) //{ // yield return new WaitForEndOfFrame(); //} //Dev.Log( "Next" ); if (overrideNextState != null) { nextState = overrideNextState; overrideNextState = null; } currentState = nextState(); nextState = null; } } yield break; }
protected virtual IEnumerator PlayAndWaitForEndOfAnimation(tk2dSpriteAnimator tk2dAnimator, string animation, Action doWhileWaiting = null) { Dev.Where(); if (tk2dAnimator.GetClipByName(animation) == null) { Dev.Log("Warning: " + animation + " clip not found"); yield break; } tk2dAnimator.AnimationCompleted = OnAnimationComplete; tk2dAnimator.Play(animation); BlockingAnimationIsPlaying = true; while (BlockingAnimationIsPlaying) { if (doWhileWaiting != null) { doWhileWaiting.Invoke(); } yield return(new WaitForEndOfFrame()); } yield break; }
IEnumerator Init() { Dev.Where(); meshRenderer.enabled = true; transform.localPosition = new Vector3(0f, 0f, 0f); transform.localRotation = Quaternion.identity; Vector3 localScale = transform.localScale; Vector3 lossyScale = transform.lossyScale; transform.SetParent(null); transform.localScale = lossyScale; yield return(PlayFromFrameAndWaitForEndOfAnimation(0)); isAnimating = false; transform.SetParent(parent.transform); transform.localScale = localScale; meshRenderer.enabled = false; currentState = null; gameObject.SetActive(false); yield break; }
private IEnumerator Start() { Dev.Where(); while (owner == null) { yield return(null); } if (logFSM) { if (collider != null) { lines = new List <GameObject>(); lines = Dev.CreateBoxOfLineRenderers(collider.bounds, Color.green, -2.1f, .01f); foreach (var go in lines) { go.transform.SetParent(owner.transform); go.transform.localPosition = Vector3.zero; } } } if (monitorFSMStates) { StartCoroutine(DebugFSMS()); } }
IEnumerator Complete() { Dev.Where(); Stop(); yield break; }
protected virtual IEnumerator GRight() { Dev.Where(); nextState = Right; yield break; }
protected virtual IEnumerator GLeft() { Dev.Where(); nextState = Left; yield break; }
//switch to this state when we enter from a transition protected virtual IEnumerator EnterSuperDash() { Dev.Where(); nextState = EnterL; nextState = EnterR; yield break; }
protected virtual IEnumerator HitWall() { Dev.Where(); nextState = CheckOnGround; yield break; }
protected virtual IEnumerator DirectionWall() { Dev.Where(); nextState = Right; nextState = Left; yield break; }
protected virtual IEnumerator ChargeCancelWall() { Dev.Where(); nextState = RegainControl; yield break; }
protected virtual IEnumerator WallCharged() { Dev.Where(); nextState = DirectionWall; yield break; }
protected virtual IEnumerator Left() { Dev.Where(); nextState = DashStart; yield break; }
protected virtual IEnumerator DashStart() { Dev.Where(); nextState = CheckOnGround; yield break; }
protected virtual IEnumerator EnterVelocity() { Dev.Where(); nextState = Dashing; yield break; }
protected virtual IEnumerator RegainControl() { Dev.Where(); hero.RegainControl(); nextState = Inactive; yield break; }
protected virtual IEnumerator RelinquishControl() { Dev.Where(); hero.RelinquishControl(); nextState = CheckOnGround; yield break; }
protected virtual void OnAnimationComplete(tk2dSpriteAnimator sprite, tk2dSpriteAnimationClip clip) { Dev.Where(); BlockingAnimationIsPlaying = false; if (sprite != null) { sprite.AnimationCompleted = null; } }
protected virtual IEnumerator Cancelable() { Dev.Where(); nextState = AirCancel; nextState = HitWall; nextState = AirCancel; yield break; }
public static void PrintHideFlagsInChildren(GameObject parent, bool print_nones = false) { #if UNITY_EDITOR && !DISABLE_EDITOR_DEBUG bool showed_where = false; if (print_nones) { Dev.Where(); showed_where = true; } foreach (Transform child in parent.GetComponentsInChildren <Transform>()) { if (print_nones && child.gameObject.hideFlags == HideFlags.None) { UnityEngine.Debug.Log(Dev.Colorize(child.gameObject.name, Dev.ColorToHex(Color.white)) + ".hideflags = " + Dev.Colorize(Convert.ToString(child.gameObject.hideFlags), _param_color)); } else if (child.gameObject.hideFlags != HideFlags.None) { if (!showed_where) { Dev.Where(); showed_where = true; } UnityEngine.Debug.Log(Dev.Colorize(child.gameObject.name, Dev.ColorToHex(Color.white)) + ".hideflags = " + Dev.Colorize(Convert.ToString(child.gameObject.hideFlags), _param_color)); } } #else bool showed_where = false; if (print_nones) { Dev.Where(); showed_where = true; } foreach (Transform child in parent.GetComponentsInChildren <Transform>()) { if (print_nones && child.gameObject.hideFlags == HideFlags.None) { DevLoggingOutput.Instance.Log(Dev.Colorize(child.gameObject.name, Dev.ColorToHex(Color.white)) + ".hideflags = " + Dev.Colorize(Convert.ToString(child.gameObject.hideFlags), _param_color)); } else if (child.gameObject.hideFlags != HideFlags.None) { if (!showed_where) { Dev.Where(); showed_where = true; } DevLoggingOutput.Instance.Log(Dev.Colorize(child.gameObject.name, Dev.ColorToHex(Color.white)) + ".hideflags = " + Dev.Colorize(Convert.ToString(child.gameObject.hideFlags), _param_color)); } } #endif }
void OnDisable() { Dev.Where(); if (meshRenderer != null) { meshRenderer.enabled = false; } isAnimating = false; mainLoop = null; currentState = null; }
IEnumerator Complete() { Dev.Where(); meshRenderer.enabled = false; isAnimating = false; gameObject.SetActive(false); mainLoop = null; currentState = null; yield break; }
IEnumerator Stun() { Dev.Where(); stuns++; hitsTaken = 0; if (onStun != null) { onStun.Invoke(); } yield break; }
IEnumerator CompleteFromHitWall() { Dev.Where(); thread.SetActive(true); isAnimating = false; currentState = null; mainLoop = null; yield break; }
protected virtual IEnumerator GroundCharged() { Dev.Where(); while ((isPressed)) { yield return(new WaitForEndOfFrame()); } nextState = Direction; yield break; }
protected virtual void OnTriggerEnter2D(Collider2D collider) { if (!isAnimating) { return; } Dev.Where(); if (collisionLayer.Contains(collider.gameObject)) { HitWall = true; } }
protected static void PlayAnimation(tk2dSpriteAnimator tk2dAnimator, string animation) { Dev.Where(); if (tk2dAnimator.GetClipByName(animation) == null) { Dev.Log("Warning: " + animation + " clip not found"); return; } tk2dAnimator.AnimationCompleted = null; tk2dAnimator.Play(animation); }
protected virtual IEnumerator CheckOnGround() { Dev.Where(); if (hero.cState.onGround) { nextState = GroundCharge; } else { nextState = WallCharge; } yield break; }
void OnEnable() { Dev.Where(); if (thread == null) { thread = gameObject.FindGameObjectInChildren("Thread"); } isAnimating = true; HitWall = false; mainLoop = MainAILoop(); StartCoroutine(mainLoop); }