Example #1
0
    public void SpawnBall()
    {
        float      x       = Random.Range(SpawnAreaTopLeftCorner.x, SpawnAreaBotRightCorner.x);
        float      y       = Random.Range(SpawnAreaBotRightCorner.y, SpawnAreaTopLeftCorner.y);
        GameObject ballObj = ballPool.GetBall();

        ballObj.transform.position = new Vector3(x, y, 0);
        ballObj.GetComponent <Ball>().PlayFX();
        ballCount++;
    }
Example #2
0
    private void SpawnBall()
    {
        var ball = pool.GetBall(Random.value > Config.BadSpawnRatio).GetComponent <Rigidbody>();

        if (ball != null)
        {
            ball.velocity           = Vector3.zero;
            ball.angularVelocity    = Vector3.zero;
            ball.transform.position = spawnPosition;
            ball.transform.rotation = Quaternion.identity;
        }
    }
Example #3
0
 void FixedUpdate()
 {
     if (Input.GetKey(KeyCode.Escape))
     {
         Application.Quit();                //wylaczenie gry przy wcisnięciu ESC
     }
     time += Time.fixedDeltaTime;           //do zmiennej time dodawany jest czas trwania klatki
     while (time > 0.25f && amount < limit) //jeżeli "czas" osiągnął 0.25 sekundy, dodawana jest nowa kula
     {
         time -= 0.25f; amount++;
         pool.GetBall(new Vector3(Random.Range(-20, 20), Random.Range(-20, 20), Random.Range(-20, 20)), 1f);
     }
     if (amount == limit)
     {
         limitAchieved = true;
     }
 }
 //łączenie dwóch kul w jedną, większą
 void Merging(GameObject g1, GameObject g2, Vector3 pos, float mass)
 {
     pool.GetBall(pos, mass);
 }