//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * Overwritten Method: Check Limit //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ protected override void CheckLimit() { if (m_rNotesManager != null && CanSwitchNotes) { if (!IsValidScale(LocalScale)) { CorrectScaleSize(); return; } // Transition to Prev/Next note if Note has gone out of Bounds OutOfBoundsIdentity eBoundary = GetOutOfBounds(); if (eBoundary != OutOfBoundsIdentity.NOT_OUT_OF_BOUNDS) { if (eBoundary == OutOfBoundsIdentity.EAST && m_rNotesManager.HasPreviousNote && LocalPosition.x > EasternBoundary * 1.25f) { m_rNotesManager.Disappear(MultipleNotesManager.TransitioningNote.PREVIOUS_NOTE); } else if (eBoundary == OutOfBoundsIdentity.WEST && m_rNotesManager.HasNextNote && LocalPosition.x < WesternBoundary * 1.25f) { m_rNotesManager.Disappear(MultipleNotesManager.TransitioningNote.NEXT_NOTE); } else { CorrectMovementPosition(); } } } else { base.CheckLimit(); } }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * New Method: Is A Valid Move Area? (Get Out of Bounds) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ protected virtual OutOfBoundsIdentity GetOutOfBounds() { // Find the Boundary that has been broken the most. float fBiggestDistance = 0.0f; OutOfBoundsIdentity eBrokenBoundary = OutOfBoundsIdentity.NOT_OUT_OF_BOUNDS; // CHECK HORIZONTAL AXIS if (LocalPosition.x > EasternBoundary) { float distance = Mathf.Abs(LocalPosition.x - EasternBoundary); if (distance > fBiggestDistance) { fBiggestDistance = distance; eBrokenBoundary = OutOfBoundsIdentity.EAST; } } else if (LocalPosition.x < WesternBoundary) { float distance = Mathf.Abs(LocalPosition.x - WesternBoundary); if (distance > fBiggestDistance) { fBiggestDistance = distance; eBrokenBoundary = OutOfBoundsIdentity.WEST; } } // CHECK VERTICAL AXIS if (LocalPosition.y < NorthernBoundary) { float distance = Mathf.Abs(LocalPosition.y - NorthernBoundary); if (distance > fBiggestDistance) { eBrokenBoundary = OutOfBoundsIdentity.NORTH; } } else if (LocalPosition.y > SouthernBoundary) { float distance = Mathf.Abs(LocalPosition.y - SouthernBoundary); if (distance > fBiggestDistance) { eBrokenBoundary = OutOfBoundsIdentity.SOUTH; } } return(eBrokenBoundary); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * New Method: Move With Touch //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ public void MoveWithTouch() { if (CanMove && !IsTapped) { // Find Distance between previous and current frames. If X Scale is great enough to warrant movement on the X Axis, allow that too. Otherwise only do for Y Axis m_vUserPreviousFramePosition = m_vUserCurrentPosition; m_vUserCurrentPosition = (CanMoveX ? CurrentPosition : CurrentPositionWithoutX); m_vFrameMovement = m_vUserCurrentPosition - m_vUserPreviousFramePosition; // Move notes. Provide resistance to movement if Notes have gone out of bounds. OutOfBoundsIdentity eBoundary = GetOutOfBounds(); if (eBoundary == OutOfBoundsIdentity.NOT_OUT_OF_BOUNDS) { WorldPosition += (m_vFrameMovement * m_fMovementSensitivity); if (m_rSprRend != null) { m_rSprRend.color = Color.white; } } else if (m_vFrameMovement != Vector3.zero) { WasMoved = true; WorldPosition += (m_vFrameMovement * m_fMovementSensitivity * m_fResistanceMovementMultiplier); // Now Change the Gray/Disabled Colouring of the Sprite/Note if existing if (m_rSprRend != null) { // Find out which Boundary we are checking float fBoundVal, fLocalPos; switch (eBoundary) { case OutOfBoundsIdentity.NORTH: fBoundVal = NorthernBoundary * 0.8f; fLocalPos = LocalPosition.y; break; case OutOfBoundsIdentity.SOUTH: fBoundVal = SouthernBoundary * 0.8f; fLocalPos = LocalPosition.y; break; case OutOfBoundsIdentity.EAST: fBoundVal = EasternBoundary; fLocalPos = LocalPosition.x; break; default: fBoundVal = WesternBoundary; fLocalPos = LocalPosition.x; break; } // Now find out how far we've gone out of Boundaries. Shrink Boundaries based on how big the notes are. float fBoundLength = (Mathf.Abs(fBoundVal * 2.0f) * (1.0f - ZoomPercentage)); if (fBoundLength > 0.0f) { float fPercentage = Mathf.Max(0.0f, Mathf.Min(1.0f, Mathf.Abs(fLocalPos - fBoundVal) / fBoundLength)); m_rSprRend.color = Color.Lerp(Color.white, m_cIllegalActionColour, fPercentage); } } } } }