private void OnCollisionDetected(OnCollisionDetected ev) { switch (m_slimeForms) { case SlimeForms.NORMAL: if (ev.CurrentDirection == Vector2.right || ev.CurrentDirection == Vector2.left) { m_slimeForms = SlimeForms.SEMI_STRETCHED_V; } else if (ev.CurrentDirection == Vector2.up || ev.CurrentDirection == Vector2.down) { m_slimeForms = SlimeForms.SEMI_STRECHED_H; } break; case SlimeForms.SEMI_STRECHED_H: if (ev.CurrentDirection == Vector2.right || ev.CurrentDirection == Vector2.left) { m_slimeForms = SlimeForms.NORMAL; } else if (ev.CurrentDirection == Vector2.up || ev.CurrentDirection == Vector2.down) { m_slimeForms = SlimeForms.FULL_STRETCHED_H; } break; case SlimeForms.FULL_STRETCHED_H: if (ev.CurrentDirection == Vector2.right || ev.CurrentDirection == Vector2.left) { m_slimeForms = SlimeForms.SEMI_STRECHED_H; } break; case SlimeForms.SEMI_STRETCHED_V: if (ev.CurrentDirection == Vector2.right || ev.CurrentDirection == Vector2.left) { m_slimeForms = SlimeForms.FULL_STRETCHED_V; } else if (ev.CurrentDirection == Vector2.up || ev.CurrentDirection == Vector2.down) { m_slimeForms = SlimeForms.NORMAL; } break; case SlimeForms.FULL_STRETCHED_V: if (ev.CurrentDirection == Vector2.up || ev.CurrentDirection == Vector2.down) { m_slimeForms = SlimeForms.SEMI_STRETCHED_V; } break; default: throw new ArgumentOutOfRangeException(); } ev.OnFinishAnimation?.Invoke(); }
private void Awake() { GameManager.Instance.GlobalDispatcher.Subscribe <OnCollisionDetected>(OnCollisionDetected); m_slimeForms = SlimeForms.NORMAL; }