// Shift to next Bar Tap private void ShiftToNextBarTap(int yDir) { if (IsShifting) { return; // don't do anything if already shifting } // Get Next Tap Index int nextTapIndex = CurrentTapIndex; // If you are going down go to the next bar if (yDir < Constants.ZERO) { nextTapIndex++; } // If you go up go to the previous bar else if (yDir > Constants.ZERO) { nextTapIndex--; } // Get all Bars BarTap foundTap = GameManager.instance.levelManager.GetBarTapAtTapIndex(nextTapIndex); BarTap firstTap = GameManager.instance.levelManager.GetFirstBarTap(); BarTap lastTap = GameManager.instance.levelManager.GetLastBarTap(); // Is found is only found if it found a tap bool isFound = (foundTap != null); // wrap to beginning or last tap if needed if (!isFound && nextTapIndex < firstTap.TapIndex) { isFound = true; nextTapIndex = lastTap.TapIndex; foundTap = lastTap; } else if (!isFound && nextTapIndex > lastTap.TapIndex) { isFound = true; nextTapIndex = firstTap.TapIndex; foundTap = firstTap; } // If player is in the scene but not at the tap still Shift but also resets it's position according to where the tap is if (isFound && !foundTap.IsPlayerAtTap) { CurrentTapIndex = nextTapIndex; BoxCollider2D tapCollider = foundTap.GetComponent <BoxCollider2D>(); Vector3 newPos = foundTap.GetShiftPositionVector(); StartCoroutine(DoShift(newPos)); } }
private void ShiftToNextBarTap(int yDir) { if (IsShifting) { return; // don't do anything if already shifting } int nextTapIndex = CurrentTapIndex; if (yDir < 0) { nextTapIndex++; } else if (yDir > 0) { nextTapIndex--; } BarTap foundTap = GameManager.instance.levelManager.GetBarTapAtTapIndex(nextTapIndex); BarTap firstTap = GameManager.instance.levelManager.GetFirstBarTap(); BarTap lastTap = GameManager.instance.levelManager.GetLastBarTap(); bool isFound = (foundTap != null); // wrap to beginning or last tap if needed if (!isFound && nextTapIndex < firstTap.TapIndex) { isFound = true; nextTapIndex = lastTap.TapIndex; foundTap = lastTap; } else if (!isFound && nextTapIndex > lastTap.TapIndex) { isFound = true; nextTapIndex = firstTap.TapIndex; foundTap = firstTap; } if (isFound && !foundTap.IsPlayerAtTap) { CurrentTapIndex = nextTapIndex; BoxCollider2D tapCollider = foundTap.GetComponent <BoxCollider2D>(); Vector3 newPos = foundTap.GetShiftPositionVector(); StartCoroutine(DoShift(newPos)); } }
private void HideCurrentTapIfFilling() { if (!IsFillingBeer && !IsIdleWithBeer) { return; } BarTap currentTap = GameManager.instance.levelManager.GetBarTapAtTapIndex(CurrentTapIndex); if (currentTap.IsPlayerAtTap && !IsShifting) { currentTap.GetComponent <SpriteRenderer>().enabled = false; Vector3 theScale = transform.localScale; theScale.x = currentTap.transform.localScale.x; transform.localScale = theScale; } }
private void HideCurrentTapIfFilling() { // If it isn't being filled don't go further if (!IsFillingBeer && !IsIdleWithBeer) { return; } // Get CurrentBarTap BarTap currentTap = GameManager.instance.levelManager.GetBarTapAtTapIndex(CurrentTapIndex); // If Player is at the Current Tap set the CurrentTap Sprite to false if (currentTap.IsPlayerAtTap && !IsShifting) { currentTap.GetComponent <SpriteRenderer>().enabled = false; Vector3 theScale = transform.localScale; theScale.x = currentTap.transform.localScale.x; transform.localScale = theScale; } }