예제 #1
0
    public Foot SwitchChosen()
    {
        //check if there is a floor at the SNAPPED coordinate of other
        Vector3 snapped = SnappedCardinalDirection(SnapAngle(angle));

        Collider2D floor = Physics2D.OverlapPoint(new Vector2(snapped.x, snapped.y), 1 << LayerMask.NameToLayer("Floor"));


        //If there's no floor, it's a NO.
        //safecatch on total reversal of the game. in other words, going backwards when it's supposed to be going forward
        if (floor == null || (floor.GetComponent <Floor>().success&& Controller.isgameworld)
            //(floor != null && other.transform.position.x < this.transform.position.x))
            )
        {
            //flash the "Miss.." sprite
            feedback.SetNumber(0);
            feedback.RenderImage(Color.white);

            if (settings.flashActivated)
            {
                backgroundbars.FlashBar(Color.red);
            }
            return(this);
        }

        //level is cleared successfully
        if (floor.GetComponent <Floor>().isend)
        {
            controller.LevelCleared();
            return(this);
        }

        //find out the exact location at which the player taps. This will give the feedback on how accurate their tap is.
        CollisionCheck();

        //if flash is enabled, trigger it
        if (settings.flashActivated)
        {
            backgroundbars.FlashBar(Color.grey);
        }

        //this is when player makes successful move, turn it to green
        floor.GetComponent <Floor>().success = true;


        SnappedNextAngle        = SnapAngle(angle);
        other.SnappedLastAngle  = SnappedNextAngle - Mathf.PI;
        conductor.actuallasthit = conductor.songposition;
        conductor.lasthit      += (SnappedNextAngle - SnappedLastAngle) / Mathf.PI * conductor.crotchet / controller.speed;

        Debug.Log("lasthit " + conductor.lasthit);
        Debug.Log("songpos " + conductor.songposition);

        //swap the chosen one
        this.bChosen  = false;
        other.bChosen = true;

        other.SnapToCardinalDirection(SnappedNextAngle);
        return(other);
    }