Exemple #1
0
 public void SubscribeOnCollection(BulletPullPresenter pull)
 {
     pull.allBulletsPresenter
     .ObserveRemove()
     .Where(asteroid => asteroid.Value == this)
     .Subscribe(_ =>
     {
         Object.Destroy(this.gameObject);
     })
     .AddTo(this);
 }
Exemple #2
0
    private void InitializeGameManager()
    {
        lvl            = LvlManager.currentLvl;
        playerProgress = PlayerPrefs.GetInt("PlayerProgress", 0);
        switch (lvl)
        {
        case 0:
            asteroidType = AsteroidType.big;
            break;

        case 1:
            asteroidType = AsteroidType.medium;
            break;

        case 2:
            asteroidType = AsteroidType.small;
            break;

        default:
            asteroidType = AsteroidType.small;
            break;
        }
        points      = new ReactiveProperty <int>(0);
        ssPresenter = new GameObject("SpaceshipPresenter").AddComponent <SpaceshipPresenter>();
        scPresenter = new GameObject("ScorePresenter").AddComponent <ScorePresenter>();
        scPresenter.SubscribeToManager(this);
        bulletPull   = new GameObject("BulletPull").AddComponent <BulletPullPresenter>();
        asteroidPull = new GameObject("AsteroidPull").AddComponent <AsteroidPullPresenter>();
        asteroidPull.asteroidType = this.asteroidType;
        MessageBroker.Default
        .Receive <ScoringNotice>()
        .Subscribe(_ => {
            points.Value += (int)asteroidType;
            if (points.Value >= pointsToWin)
            {
                GameOver(true);
            }
        })
        .AddTo(this);
        StartGame();
    }