/// <summary> /// Use this for initialization /// </summary> protected virtual void Start() { switch (myType) { case BallType.Standard: case BallType.Freezer: hits = ConfigurationUtils.BallHits; points = 1; break; case BallType.Bonus: hits = ConfigurationUtils.BonusHits; points = ConfigurationUtils.BonusPoints; break; } lifetimer = gameObject.AddComponent <Timer>(); lifetimer.Duration = ConfigurationUtils.BallLifetime; lifetimer.Run(); moveTimer = gameObject.AddComponent <Timer>(); // print( ConfigurationUtils.BallSpawnTime ); moveTimer.Duration = ConfigurationUtils.BallSpawnTime; moveTimer.Run(); // Set up top left and lower right only once. if (!setBounds) { setBounds = true; var halfDims = GetComponent <BoxCollider2D>().size / 2.0f; var pos = transform.position; topLeft.Set(pos.x - halfDims.x, pos.y + halfDims.y); botRight.Set(pos.x - halfDims.x, pos.y - halfDims.y); } Freeze(); // So we don't start prematurely. lifetimer.AddListener(DestroyAndMakeNewBall); moveTimer.AddListener(InitiateMovement); if (speedupTimer == null) { speedupTimer = gameObject.AddComponent <Timer>(); } if (!initializedListeners) { EventManager.AddListener(SpeedUp); Pickup.AddSpeedupListener(SpeedUp); initializedListeners = true; } spawn.Play(); }