public string GetAnimationState(PlayerController interactor, out bool shouldBeFlipped) { shouldBeFlipped = false; Vector2 inVec = interactor.CenterPosition - specRigidbody.UnitCenter; switch (BraveMathCollege.VectorToQuadrant(inVec)) { case 0: return("tablekick_down"); case 1: shouldBeFlipped = true; return("tablekick_right"); case 2: return("tablekick_up"); case 3: return("tablekick_right"); default: Debug.Log("[ExpandKickableObject] Failed to find table animation state. Using fall back 'tablekick_up' instead."); return("tablekick_up"); } }
public string GetAnimationState(PlayerController interactor, out bool shouldBeFlipped) { shouldBeFlipped = false; Vector2 inVec = interactor.CenterPosition - specRigidbody.UnitCenter; switch (BraveMathCollege.VectorToQuadrant(inVec)) { case 0: return("tablekick_down"); case 1: shouldBeFlipped = true; return("tablekick_right"); case 2: return("tablekick_up"); case 3: return("tablekick_right"); default: Debug.Log("fail"); return("tablekick_up"); } }
public IntVector2 GetFlipDirection(SpeculativeRigidbody kickerRigidbody, out int quadrant) { Vector2 inVec = new Vector2(0, 1); if (specRigidbody != null) { inVec = specRigidbody.UnitCenter - kickerRigidbody.UnitCenter; } else if (sprite != null) { inVec = sprite.WorldCenter - kickerRigidbody.UnitCenter; } quadrant = BraveMathCollege.VectorToQuadrant(inVec); return(IntVector2.Cardinals[quadrant]); }
private IEnumerator HandleBounceback() { if (m_lastDirectionKicked != null) { m_isBouncingBack = true; Vector2 dirToMove = m_lastDirectionKicked.Value.ToVector2().normalized * -1f; int quadrant = BraveMathCollege.VectorToQuadrant(dirToMove); specRigidbody.Velocity = rollSpeed * dirToMove; IntVector2?lastDirectionKicked = m_lastDirectionKicked; m_lastDirectionKicked = ((lastDirectionKicked == null) ? null : new IntVector2?(lastDirectionKicked.GetValueOrDefault() * -1)); if (hasRollingAnimations) { tk2dSpriteAnimationClip rollClip = spriteAnimator.GetClipByName(rollAnimations[quadrant]); if (rollClip.wrapMode == tk2dSpriteAnimationClip.WrapMode.LoopSection) { spriteAnimator.PlayFromFrame(rollClip, rollClip.loopStart); } else { spriteAnimator.Play(rollClip); } } float ela = 0f; float dura = 1.5f / specRigidbody.Velocity.magnitude; while (ela < dura && m_isBouncingBack) { ela += BraveTime.DeltaTime; specRigidbody.Velocity = rollSpeed * dirToMove; yield return(null); } if (m_isBouncingBack) { StopRolling(false); } } yield break; }