// Use this for initialization void Start() { // set the min/max spawn times for random balls minBallSpawnTime = ConfigurationUtils.MinRandomSpawnTime; maxBallSpawnTime = ConfigurationUtils.MaxRandomSpawnTime; // get the boundaries of the spawn location Ball tempBall = Instantiate <Ball>(prefabBall); BoxCollider2D collider = tempBall.GetComponent <BoxCollider2D>(); float ballColliderHalfWidth = collider.size.x / 2; float ballColliderHalfHeight = collider.size.y / 2; spawnLocationMin = new Vector2( tempBall.transform.position.x - ballColliderHalfWidth, tempBall.transform.position.y - ballColliderHalfHeight); spawnLocationMax = new Vector2( tempBall.transform.position.x + ballColliderHalfWidth, tempBall.transform.position.y + ballColliderHalfHeight); Destroy(tempBall.gameObject); // create a time to spawn a ball at random intervals timerRandomBallSpawn = gameObject.AddComponent <Timer>(); retrySpawn = true; // Add listeners for events IntEventManager.AddListener(EventName.SubtractBallsEvent, SpawnBalls); IntEventManager.AddListener(EventName.BallsDiedEvent, SpawnBalls); IntEventManager.AddListener(EventName.GameOverEvent, GameOver); }
// Use this for initialization void Start() { scoreText = GameObject.FindGameObjectWithTag("ScoreText").GetComponent <Text>(); ballsLeftText = GameObject.FindGameObjectWithTag("BallsLeftText").GetComponent <Text>(); ballsLeft = ConfigurationUtils.BallsPerGame; ballsLeftText.text = "Balls Left: " + ballsLeft.ToString(); blockCount = LevelBuilder.BlockCount; // cheap 'n nasty; could also get this by finding tagged block count IntEventManager.AddListener(EventName.PointsAdded, AddPoints); IntEventManager.AddListener(EventName.SubtractBallsEvent, SubtractBalls); IntEventManager.AddListener(EventName.BlockDestroyed, SubtractBlocks); intUnityEvents.Add(EventName.GameOverEvent, new GameOverEvent()); IntEventManager.AddInvoker(EventName.GameOverEvent, this); }
// Use this for initialization void Start() { IntEventManager.AddListener(EventName.GameOverEvent, GameOver); }