示例#1
0
    void Start()
    {
        var time          = GetTime();
        var randomService = new RandomFloat(new System.Random());
        var collisions    = GetCollisions();

        //Create the Hazard Spawner
        var hazardSpawner = new HazardSpawner(
            time,
            spawnInterval,
            randomService,
            minHazardHeight,
            maxHazardHeight,
            initialPosition,
            hazardSpeed
            );

        //Initialize Bird
        bird.Setup(time, collisions);

        //When a collision event occurs, the hazard spawner stop spawning hazards
        collisions.Subscribe(collisionEvent => hazardSpawner.Stop());

        //Every time the HazardSpawner spawns a hazar, create a hazard view
        hazardSpawner.Hazards.Subscribe(hazard => CreateHazard(hazard, collisions));
    }
 IEnumerator WhenSpawnerIsStoppedTimePasses(float seconds)
 {
     hazardSpawner.Stop();
     yield return(WhenTimePasses(seconds));
 }