Esempio n. 1
0
 private void BoundaryCheck(Boid boid)
 {
     if (boid.transform.position.y < yMin - buffer)
     {
         flock.Remove(boid);
         Destroy(boid.gameObject);
         CallBacks.IssueOnEnemyDied();
     }
 }
Esempio n. 2
0
        private void SpawnWall()
        {
            gapSize = (boidsController.BoidsAlive * .5f);
            float s = UnityEngine.Random.Range(0, (xMax * 2) - gapSize);
            float r = (xMax * 2 - gapSize) - s;


            GameObject wall = new GameObject("Wall");

            wall.transform.SetParent(transform);

            GameObject leftWall;
            GameObject rightWall;

            leftWall = Instantiate(levelPrefab, wall.transform);
            leftWall.transform.localScale = new Vector2(s, 1);
            leftWall.transform.position   = new Vector2(xMin + (leftWall.GetComponent <BoxCollider2D>().bounds.size.x / 2), 0);

            leftWall.name = "A";

            rightWall = Instantiate(levelPrefab, wall.transform);
            rightWall.transform.localScale = new Vector2(r, 1);
            rightWall.transform.position   = new Vector2(xMax - (rightWall.GetComponent <BoxCollider2D>().bounds.size.x / 2), 0);

            rightWall.name = "B";


            objectHeight            = leftWall.GetComponent <BoxCollider2D>().bounds.size.y;
            wall.transform.position = new Vector2(0, yMax + objectHeight);
            walls.Add(wall);
            levelScore++;

            CallBacks.IssueOnSurvived();

            //y = x / (x + 4)
        }