示例#1
0
    // 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));
        }
    }
示例#2
0
    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));
        }
    }
示例#3
0
    // Start is called before the first frame update
    public void Start()
    {
        // Sets Default Values for Certain Variables
        ShiftDelay  = Constants.SHIFT_DELAY;
        ShiftSpeed  = Constants.SHIFT_SPEED;
        RunSpeed    = Constants.RUN_SPEED;
        ServeDelay  = Constants.SERVE_DELAY;
        FillSpeed   = Constants.FILL_SPEED;
        FillPercent = Constants.FILL_PERCENT;

        // Every time the Player starts it will play a "You used a life" Track
        NewLife.Play();

        // Connects to the Components
        boxCollider    = GetComponent <BoxCollider2D>();
        rBody          = GetComponent <Rigidbody2D>();
        animator       = GetComponent <Animator>();
        spriteRenderer = GetComponent <SpriteRenderer>();

        // Sets Default Values to false to prevent misbehaviour
        IsRunning         = false;
        IsShifting        = false;
        IsFacingLeft      = false;
        IsFillingBeer     = false;
        IsAtCurrentBarTap = false;

        // Sets the Animator Values according to the Default Bool Values
        IsIdleWithBeer = false;
        animator.SetBool("isIdleWithBeer", IsIdleWithBeer);

        IsFillingBeer = false;
        animator.SetBool("isFillingBeer", IsFillingBeer);

        // Get Current Bartap and set Default Position
        BarTap currentTap = GameManager.instance.levelManager.GetBarTapAtTapIndex(CurrentTapIndex);

        rBody.transform.position = currentTap.GetShiftPositionVector();
    }
示例#4
0
    // Start is called before the first frame update
    protected void Start()
    {
        boxCollider    = GetComponent <BoxCollider2D>();
        rBody          = GetComponent <Rigidbody2D>();
        animator       = GetComponent <Animator>();
        spriteRenderer = GetComponent <SpriteRenderer>();

        IsRunning         = false;
        IsShifting        = false;
        IsFacingLeft      = false;
        IsFillingBeer     = false;
        IsAtCurrentBarTap = false;

        IsIdleWithBeer = false;
        animator.SetBool("isIdleWithBeer", IsIdleWithBeer);

        IsFillingBeer = false;
        animator.SetBool("isFillingBeer", IsFillingBeer);

        BarTap currentTap = GameManager.instance.levelManager.GetBarTapAtTapIndex(CurrentTapIndex);

        rBody.transform.position = currentTap.GetShiftPositionVector();
    }