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(); }
public void Update(TimeSpan elapsed) { for (var i = 0; i < _collidables.Count; i++) { var collidable = _collidables[i]; for (var j = 0; j < _collidables.Count; j++) { var otherCollidable = _collidables[j]; if (IsCollisionDetected(collidable, otherCollidable)) { OnCollisionDetected?.Invoke(this, collidable, otherCollidable); } } } }
public void OnCollision(CollisionEventArgs collisionInfo) { OnCollisionDetected?.Invoke(collisionInfo); }