Esempio n. 1
0
    // Spawns ball with given difficulty parameters
    public void SpawnBall(BallSize size, BallSpeed speed, BallInitAngle initAngle, BallHorizDirection hDirect)
    {
        SetSpeed(speed);
        SetAngle(initAngle);
        SetSize(size);
        SetDirection(hDirect);
        Vector3 chosenSpawn = ChooseSpawn();

        currBalls += 1;
        //vertDirection = Random.Range(0, 2) * 2 - 1;
        //initialImpulse = new Vector3(initialImpulse.x * horizDirection, initialImpulse.y, initialImpulse.z * vertDirection);
        ball.GetComponent <BallBehavior>().initialImpulse = initialImpulse;
        Instantiate(ball, chosenSpawn, Quaternion.identity);
        Debug.Log("Spawned ball.");
        ResetBallPrefab();
    }
Esempio n. 2
0
    // Sets up ball's rotation to properly reflect the selected BallInitAngle
    void SetAngle(BallInitAngle initAngle)
    {
        float f = new float();

        if (initAngle.Equals(BallInitAngle.Shallow))
        {
            f = Random.Range(shallowMin, shallowMax);
        }
        if (initAngle.Equals(BallInitAngle.Medium))
        {
            f = Random.Range(medAngMin, medAngMax);
        }
        if (initAngle.Equals(BallInitAngle.Wide))
        {
            f = Random.Range(wideMin, wideMax);
        }
        if (initAngle.Equals(BallInitAngle.Random))
        {
            f = Random.Range(shallowMin, wideMax);
        }
        Debug.Log("Initial angle = " + f);
        initialImpulse = new Vector3(initialImpulse.z * Mathf.Sin(f), 0, initialImpulse.z * Mathf.Cos(f));
    }