// ====================================================================================== // PROTECTED MEMBERS - RUNTIMEMONOBEHAVIOUR // ====================================================================================== override protected void StartPhase() { base.StartPhase(); InitializeValues(); m_rb = this.GetComponent <Rigidbody2D>(); m_collider = this.GetComponent <CompositeCollider2D>(); if (m_collider == null) { #if UNITY_EDITOR Debug.Assert(this.GetComponents <Collider2D>().Length == 1, this.gameObject.name + " - PlayerController : Player must have a single collider or many colliders with a composite collider!"); #endif m_collider = this.GetComponent <Collider2D>(); } m_collisionCtlr = this.gameObject.GetComponent <CollisionCtlr>(); m_input = this.GetComponent <PlayerInputCtlr>(); // state IsGrounded = false; IsWallSnapped = false; IsEjecting = false; IsDashing = false; ForwardDir = eDirection.Right; }
// ====================================================================================== private IEnumerator Fall() { CollisionCtlr collision = this.gameObject.GetComponent <CollisionCtlr>(); PlayerController player = this.gameObject.GetComponent <PlayerController>(); Rigidbody2D rb = this.gameObject.GetComponent <Rigidbody2D>(); PlayerAnimatorController animator = this.gameObject.GetComponent <PlayerAnimatorController>(); while (collision.Ground == null) { if (!IsPaused()) { rb.simulated = true; UpdateGravity(player.m_configData.m_gravityRatio, player.m_configData.m_gravityMaxSpeed, rb); } else { rb.simulated = false; } yield return(new WaitForFixedUpdate()); } rb.velocity = Vector2.zero; rb.simulated = false; animator.m_animator.SetBool("IsFalling", false); }