private void CheckIfOffscreen()
 {
     if (this.transform.position.y > edge.GetTop().y)
     {
         this.gameObject.SetActive(false);
     }
     if (this.transform.position.y < edge.GetBotton().y)
     {
         this.gameObject.SetActive(false);
     }
     if (this.transform.position.x < edge.GetLeft().x)
     {
         this.gameObject.SetActive(false);
     }
     if (this.transform.position.x > edge.GetRight().x)
     {
         this.gameObject.SetActive(false);
     }
 }
Exemplo n.º 2
0
    void SpawnEnemy(ObjectPooler pool)
    {
        ScreenEdgeReference reference = ScreenEdgeReference.Instance;
        float randomX = 0;

        if (Random.Range(0, 2) == 0)
        {
            randomX = reference.GetLeft().x;
        }
        else
        {
            randomX = reference.GetRight().x;
        }

        float randomY = Random.Range(reference.GetBotton().y, reference.GetTop().y);

        GameObject enemy = PoolManager.Instance.GrabFromPool(pool);

        enemy.SetActive(true);
        enemy.transform.SetPositionAndRotation(new Vector3(randomX, randomY, 0), Quaternion.identity);
    }
Exemplo n.º 3
0
    private void WarpToLeft()
    {
        Vector3 vec = new Vector3(edge.GetLeft().x, t.position.y, t.position.z);

        t.SetPositionAndRotation(vec, t.rotation);
    }