示例#1
0
    /// <summary>
    /// Handles all checks for if this instance can begin gliding in any direction
    /// </summary>
    private void checkCanGlide()
    {
        switch (_text.text)
        {
        case "":
            break;

        // IF THIS INSTANCE HAS "o" AS TEXT VALUE
        case "o":
            // If its left Occupant has "p", and instance is not blocked to the right, glide right
            // Prep right glide
            if (leftOccupant != null && leftOccupant.getTextValue() == "p")
            {
                //Debug.Log ("LeftOccupant not Null");
                _rb.constraints = RigidbodyConstraints2D.FreezeRotation;
                checkGlideRight();
            }

            // If its right Occupant has "k", and instance is not blocked to the left, glide left
            // Prep left glide
            if (rightOccupant != null && rightOccupant.getTextValue() == "k")
            {
                _rb.constraints = RigidbodyConstraints2D.FreezeRotation;
                checkGlideLeft();
            }
            break;

        // IF THIS INSTANCE HAS "d" AS TEXT VALUE, Prep Down Glide
        case "d":
            // If its left Occupant has a vowel, and instance is not blocked below, glide down
            if (leftOccupant != null && leftOccupant.getTextValue() == "o")
            {
                //Debug.Log ("LeftOccupant not Null");
                _rb.constraints = RigidbodyConstraints2D.FreezeRotation;
                checkGlideDown();
            }
            break;

        // IF THIS INSTANCE HAS "p" AS TEXT VALUE, Prep Up Glide on RIGHT sides
        case "p":
            // If its left Occupant has a vowel, and instance is not blocked below, glide down
            if (leftOccupant != null && leftOccupant.getTextValue() == "o")
            {
                _rb.constraints = RigidbodyConstraints2D.FreezeRotation;
                checkGlideUp();
            }
            break;

        // IF THIS INSTANCE HAS "b" AS TEXT VALUE, Prep Up Glide on LEFT side
        case "b":
            // If its left Occupant has a vowel, and instance is not blocked below, glide down
            if (rightOccupant != null && rightOccupant.getTextValue() == "o")
            {
                _rb.constraints = RigidbodyConstraints2D.FreezeRotation;
                checkGlideUp();
            }
            break;

        case "v":
            // If its left Occupant has a vowel, and instance is not blocked below, glide up
            if (rightOccupant != null && rightOccupant.getTextValue() == "o")
            {
                _rb.constraints = RigidbodyConstraints2D.FreezeRotation;
                checkGlideDown();
            }
            break;

        default:
            break;
        }
    }