コード例 #1
0
    public void Init(Pong2Ball ball)
    {
        this.ball          = ball;
        ballPos            = ball.transform.position;
        transform.position = new Vector3(ballPos.x, ballPos.y, -49);

        rend         = GetComponent <Renderer>();
        rend.enabled = false;
    }
コード例 #2
0
    // Start is called before the first frame update
    public void Init(bool isMoving, Pong2Ball ball, bool player)
    {
        this.isMoving = isMoving;
        this.ball     = ball;

        if (!isMoving)
        {
            if (player)
            {
                transform.position = new Vector3(0, 0, -49);
            }
            else
            {
                transform.position = new Vector3(0, 0, 49);
            }
        }
    }
コード例 #3
0
    void Start()
    {
        ball = Instantiate(ball) as Pong2Ball;
        room = Instantiate(room) as Room;

        playerPaddle    = Instantiate(paddle) as Pong2Paddle;
        computerPaddle  = Instantiate(paddle) as Pong2Paddle;
        movingIndicator = Instantiate(indicator) as Indicator;

        playerPaddle.Init(true, ball, false);
        computerPaddle.Init(false, ball, false);
        movingIndicator.Init(true, ball, false);
        ball.Init(true);

        restartText.enabled   = false;
        restart.image.enabled = false;
        startTime             = Time.time;
    }
コード例 #4
0
    public void Init(bool isPlayer, Pong2Ball ball, bool playForTime)
    {
        this.ball        = ball;
        this.isPlayer    = isPlayer;
        this.playForTime = playForTime;
        alpha            = 0.3f;
        impulseTime      = 0;
        collided         = false;

        //Retrieving the material component and current material color and setting the opacity to 10%
        //Used later on to display impulse effect on ball bounce
        col = gameObject.GetComponent <Renderer>().material.color;
        gameObject.GetComponent <Renderer>().material.color = new Color(col.r, col.g, col.b, 0.1f);

        //Setting initial positions for the player and the computer.
        if (isPlayer)
        {
            transform.position = new Vector3(0, VERTICALMID, PLAYERZ);
        }
        else
        {
            transform.position = new Vector3(0, VERTICALMID, COMPZ);
        }
    }