// Use this for initialization void Start() { //确定球的出生点位置 GameObject tempball = Instantiate <GameObject>(prefabBall); BoxCollider2D ballCollider = tempball.GetComponent <BoxCollider2D>(); float ballColliderHalfWidth = ballCollider.size.x / 2; float ballColliderHalfHeight = ballCollider.size.y / 2; Destroy(tempball); 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); delayRange = ConfigurationUtils.MaximumSpawnTime - ConfigurationUtils.MinimumSpawnTime; spawntimer = gameObject.AddComponent <Timer>(); spawntimer.Duration = RandomSpawnDelay(); spawntimer.AddTimerFinishedListener(HandleSpawnTimerFinished); spawntimer.Run(); Spawnball(); EventManager.AddBallSpawnListener(Spawnball); }
void Start() { gameObject.AddComponent <Timer> (); timer = GetComponent <Timer> (); timer.Duration = Random.Range(ConfigurationUtils.MinBallSpawnTime, ConfigurationUtils.MaxBallSpawnTime); timer.Run(); EventManager.AddBallSpawnListener(SpawnBall); //spawn check support GameObject tempBall = Instantiate <GameObject>(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); }
void Start() { EventManager.AddBallDecrementInvoker(this); EventManager.AddBallSpawnListener(Spawn); }