コード例 #1
0
    void CreateObservables()
    {
        // trigger an observable based on when the player's position changes
        playerLocation = new BehaviorSubject <Vector2>(Vector2.zero);
        latitude.Merge(longitude)
        .Select((float _) => {
            // value could be either lat or lng, so just cheat and grab the current property values
            return(new Vector2(longitude.Value, latitude.Value));
        })
        .Subscribe((Vector2 coords) => {
            playerLocation.OnNext(coords);
        });

        activeStar           = new BehaviorSubject <StarController>(null);
        deliveryDestinations = new BehaviorSubject <Dictionary <int, int> >(GenerateDeliveries());

        fuelAvailable
        .Select((x) => x < 3 && fuelTimeRemaining.Value == 0)
        .Subscribe((x) => {
            StartFuelTimer();
        });
    }