コード例 #1
0
ファイル: Ball.cs プロジェクト: NetkoNefarious/Pong
    private void UpdateAndContinue(string goalScore, bool isOutOfBounds)
    {
        if (!isOutOfBounds)
        {
            KeepScore.IncreaseTextUIScore(goalScore);
        }

        switch (Direction.x > 0)
        {
        case true:
            // This one is especially important for AI in order to not get scored on repeatedly
            Direction = Vector2.right.normalized;
            break;

        default:
            // Makes the ball go horizontally straight after scoring (in this case to the left)
            Direction = Vector2.left.normalized;
            break;
        }

        // Reset ball position
        transform.position = new Vector2(0, 0);

        // Staart the countdown
        StartCoroutine(score.Countdown());
    }