public void OnBoostTriggered(BoostLogicEventData eventData) { if (!enabled) { return; } m_CameraController.AttemptActionZoom(); }
private void OnTriggerEnter2D(Collider2D collision) { var boostLogic = collision.GetComponent <BoostLogic>(); if (boostLogic != null) { var eventData = new BoostLogicEventData() { m_BoostLogic = boostLogic, m_TileDirection = boostLogic.GetComponent <TileDirection>(), }; m_Events.BoostTriggered.Invoke(eventData); } }
public void OnBoostTriggered(BoostLogicEventData eventData) { var direction = eventData.m_TileDirection.m_Direction; var boostSpeed = eventData.m_BoostLogic.m_Speed; var velocity = m_Rigidbody.velocity; var preventMovementInput = false; // You should only prevent movement input for // horizontal boosts switch (direction) { case Direction.RIGHT: velocity.x = boostSpeed; preventMovementInput = true; break; case Direction.UP: velocity.y = boostSpeed; break; case Direction.LEFT: velocity.x = -boostSpeed; preventMovementInput = true; break; case Direction.DOWN: velocity.y = -boostSpeed; break; } m_LatestBoostDelay = eventData.m_BoostLogic.m_Delay; m_LatestBoostFullDuration = eventData.m_BoostLogic.m_FullDuration; BeginBoosting(preventMovementInput); m_Rigidbody.velocity = velocity; }