예제 #1
0
 public void ReleaseObject(PlaygroundObject objectInstance)
 {
     //Make sure the object is within a stable state
     objectInstance.Reset();
     if (_inUse.Remove(objectInstance))
     {
         _available.Push(objectInstance);
     }
 }
예제 #2
0
    private void SpamObject(float velocity)
    {
        //Spam one playgroundObject with a specific pattern
        PlaygroundObject playgroundObject = pool.GetObject();

        Transform objectTransform = playgroundObject.transform;

        objectTransform.SetParent(transform, false);
        objectTransform.localPosition = new Vector3(12.0f, -4.0f, 0.0f);

        playgroundObject.Activate();

        //playgroundObject.GetComponent<Rigidbody>().AddRelativeForce(-Vector3.right*100.0f);
        playgroundObject.GetComponent <Rigidbody>().velocity = -velocity * playgroundObject.transform.right;

        _objects.Add(playgroundObject);
    }
예제 #3
0
    private IEnumerator SpamObject(float waitingTime, float velocity)
    {
        yield return(new WaitForSeconds(waitingTime));

        //Spam one playgroundObject with a specific pattern
        PlaygroundObject playgroundObject = pool.GetObject();

        Transform objectTransform = playgroundObject.transform;

        objectTransform.SetParent(transform, false);
        objectTransform.localPosition = new Vector3(12.0f, 3.0f, 0.0f);

        playgroundObject.Activate();

        //playgroundObject.GetComponent<Rigidbody>().AddRelativeForce(-Vector3.right*100.0f);
        playgroundObject.GetComponent <Rigidbody>().velocity = -velocity * playgroundObject.transform.right;

        _objects.Add(playgroundObject);
    }
예제 #4
0
    private IEnumerator SpamObject(int index, float velocity, float xOffset)
    {
        yield return(new WaitForSeconds(index * (xOffset / velocity) * 0.28f));

        for (int i = 0; i < _objectCount / 2; ++i)
        {
            //Spam one playgroundObject with a specific pattern
            PlaygroundObject playgroundObject = pool.GetObject();

            //playgroundObject.GetComponent<Gravity>().enabled = false;

            Transform objectTransform = playgroundObject.transform;
            objectTransform.SetParent(transform, false);
            objectTransform.localPosition = new Vector3(12.0f + (index / 2 + i * 2) * xOffset, 3.0f, 0.0f);

            playgroundObject.Activate();

            //playgroundObject.GetComponent<Rigidbody>().AddRelativeForce(-Vector3.right*100.0f);
            playgroundObject.GetComponent <Rigidbody>().velocity = -velocity * playgroundObject.transform.right;

            _objects.Add(playgroundObject);
        }
    }
예제 #5
0
    private PlaygroundObject InstantiateObject()
    {
        PlaygroundObject playgroundObject = Instantiate(objectPrefab) as PlaygroundObject;

        return(playgroundObject);
    }