Example #1
0
    void Start()
    {
        gameView      = app.view;
        boundaryModel = new BoundaryModel();
        playerModel   = app.model.playerSettings;

        //write and read to XML
        gameModel = fileSave.ReadXml <GameModel>();

        app.model    = gameModel;
        lvlDataModel = app.model.lvldata;
        //fileSave.WriteXml(gameModel);
        lvlStructSource = lvlDataModel.lvlStruct[lvlDataModel.currentLvl.Value - 1];


        PoolManager.init(poolGO, spawnAsteroidObj);


        //определяем границы камеры
        boundaryModel.SetBoundary(Camera.main.ViewportToWorldPoint(new Vector2(0, 0)), Camera.main.ViewportToWorldPoint(new Vector2(1, 1)));


        //наблюдаем за добавлением объекта в коллекцию астероидов
        app.model.getAsterCollection().ObserveAdd().Subscribe(x =>
        {
            GameObject obj = PoolManager.Get(asteroidsPref);
            obj.GetComponent <AsteroidView>().setModel(x.Value);
            x.Value.moveObject();
        });

        //наблюдаем за удалением объекта в коллекции астероидов
        app.model.getAsterCollection().ObserveRemove().Subscribe(x =>
        {
            Debug.Log("remove subscribe");
            PoolManager.Put(tmp);
        });

        //наблюдаем за добавлением объекта в коллекцию пуль
        app.model.getBulletCollection().ObserveAdd().Subscribe(x =>
        {
            GameObject obj = PoolManager.Get(bulletPref);
            obj.GetComponent <BulletView>().setModel(x.Value);
            x.Value.moveObject();
        });

        //наблюдаем за удалением объекта в коллекции пуль
        app.model.getBulletCollection().ObserveRemove().Subscribe(x =>
        {
            Debug.Log("remove subscribe");
            PoolManager.Put(tmp2);
        });

        //StartCoroutine(AsteroidsSpawn());


        Observable.EveryUpdate()
        .Where(_ => Input.anyKeyDown)
        .Select(_ => Input.inputString)
        .Subscribe(x => {
            OnKeyDown(x);
        }).AddTo(this);
    }
    void Start()
    {
        gameView      = app.view;
        boundaryModel = new BoundaryModel();
        playerModel   = app.model.playerSettings;

        //write and read to XML
        gameModel = fileSave.ReadXml <GameModel>();

        app.model = gameModel;
        gameView.showTextAster();
        lvlDataModel = app.model.lvldata;
        //fileSave.WriteXml(gameModel);
        lvlStructSource = app.model.GetLvlStruct();

        if (lvlDataModel.lvlStruct[0].status != LvlStatus.Finished)
        {
            lvlDataModel.lvlStruct[0].status = LvlStatus.Open;
        }


        PoolManager.Init(spawnAsteroidObj);


        //определяем границы камеры
        boundaryModel.SetBoundary(Camera.main.ViewportToWorldPoint(new Vector2(0, 0)), Camera.main.ViewportToWorldPoint(new Vector2(1, 1)));


        //наблюдаем за добавлением объекта в коллекцию астероидов
        app.model.getAsterCollection().ObserveAdd().Subscribe(x =>
        {
            GameObject obj = PoolManager.Get(asteroidsPref);
            obj.GetComponent <AsteroidView>().setModel(x.Value);
            x.Value.moveObject();
        });

        //наблюдаем за удалением объекта в коллекции астероидов
        app.model.getAsterCollection().ObserveRemove().Subscribe(x =>
        {
            PoolManager.Put(tmpAster);
        });

        //наблюдаем за добавлением объекта в коллекцию пуль
        app.model.getBulletCollection().ObserveAdd().Subscribe(x =>
        {
            GameObject obj = PoolManager.Get(bulletPref);
            obj.GetComponent <BulletView>().setModel(x.Value);
            x.Value.moveObject();
        });

        //наблюдаем за удалением объекта в коллекции пуль
        app.model.getBulletCollection().ObserveRemove().Subscribe(x =>
        {
            PoolManager.Put(tmpBullet);
        });



        Observable.EveryUpdate()
        .Where(_ => Input.anyKeyDown)
        .Select(_ => Input.inputString)
        .Subscribe(x => {
            OnKeyDown(x);
        }).AddTo(this);
    }