Esempio n. 1
0
        protected override IEnumerator AfterStart()
        {
            this.RegisterSelf(this);

            _multTextMeshProText = _multTextMeshProText.GetComponentFromDescendants(this, nameof(_multTextMeshProText));
            _multSkillButton     = _multSkillButton.GetComponentFromDescendants(this, nameof(_multSkillButton));
            _plusTextMeshProText = _plusTextMeshProText.GetComponentFromDescendants(this, nameof(_plusTextMeshProText));
            _plusSkillButton     = _plusSkillButton.GetComponentFromDescendants(this, nameof(_plusSkillButton));
            yield return(BrickMgrM.WaitModule <IPropertyTag>());

            yield return(null);

            //按下按键尝试释放
            _multSkillButton.OnClickAsObservable().Subscribe(__ =>
            {
                MessageBroker.Default.Publish(new SkillTag_TryModifySkill());
                MessageBroker.Default.Publish(new PropTag_ModifyMultiplyCount {
                    value = -1
                });
            }).AddTo(this);
            _plusSkillButton.OnClickAsObservable().Subscribe(__ =>
            {
                MessageBroker.Default.Publish(new SkillTag_TryPlusSkill());
                MessageBroker.Default.Publish(new PropTag_ModifyPlusCount {
                    value = -1
                });
            }).AddTo(this);
            // ----------------------
            //更新plus
            BrickMgrM.PropertyModule.plusCount.current.SubscribeWithState(_plusTextMeshProText, (x, t) => t.text = x.ToString()).AddTo(this);
            //更新mult
            BrickMgrM.PropertyModule.multiplyCount.current.SubscribeWithState(_multTextMeshProText, (x, t) => t.text = x.ToString()).AddTo(this);
        }
Esempio n. 2
0
        protected override System.Collections.IEnumerator OnInitializeRegisterSelf()
        {
            Mgr.Instance.RegisterModule(this);
            Debug.Log("Create UIManager");

            // mainHudCanvas = mainHudCanvas.GetComponentFromChildren(this, nameof(mainHudCanvas));
            // mainHudCanvas.worldCamera = BrickMgrM.CameraManager.mainCam;
            // worldHudCanvas = worldHudCanvas.GetComponentFromChildren(this, nameof(worldHudCanvas));
            // worldHudCanvas.worldCamera = BrickMgrM.CameraManager.mainCam;
            // var mainHudTran = mainHudCanvas.transform;
            // var worldHudTran = worldHudCanvas.transform;

            //游戏开始,加载关卡
            MessageBroker.Default.Receive <GameTag_GameStart>().Subscribe(x => LoadGameUI()).AddTo(this);;
            //游戏结束,弹出窗口
            MessageBroker.Default.Receive <GameTag_GameEnd>().Subscribe(x => GameEnd(x.isWinorNot)).AddTo(this);;
            //回到主菜单,清理InGameUI
            MessageBroker.Default.Receive <GameTag_BackToMenu>().Subscribe(__ => BackToMenu()).AddTo(this);;

            yield return(BrickMgrM.WaitModule <ICameraTag>());

            //生成弹窗
            constHudCanvas             = constHudCanvas.GetComponentFromChildren(this, nameof(constHudCanvas));
            constHudCanvas.worldCamera = BrickMgrM.CameraManager.MainCam;
        }
Esempio n. 3
0
        protected override System.Collections.IEnumerator OnInitializeRegisterSelf()
        {
            Mgr.Instance.RegisterModule(this);
            Debug.Log("Create EntityManager");
            yield return(BrickMgrM.WaitModule <IPropertyTag>());

            //加载slider
            MessageBroker.Default.Receive <PropTag_ModifySliderSize>().Subscribe(x => GenerateSlider()).AddTo(this);
            //回到菜单
            MessageBroker.Default.Receive <GameTag_BackToMenu>()
            .Subscribe(__ => {
                Observable.Timer(System.TimeSpan.FromMilliseconds(150)).Subscribe(___ => ClearBalls(false));
            }).AddTo(this);;
            //开始
            MessageBroker.Default.Receive <GameTag_GameStart>()
            .Subscribe(__ => {
                MessageBroker.Default.Publish(new GameTag_Reload());
                ClearBalls(false);
            }).AddTo(this);
            //游戏结束
            MessageBroker.Default.Receive <GameTag_GameEnd>()
            .Subscribe(x => ClearBalls(x.isWinorNot)).AddTo(this);;
            // //Load
            MessageBroker.Default.Receive <GameTag_Reload>().Subscribe(__ => GenerateStartBall()).AddTo(this);
            //如果在游戏状态且球变为0了,扣一点
            this.ObserveEveryValueChanged(x => x.BallsSet.Count)
            .Where(x => x == 0 && LoaderManager.isLoaded)
            .Subscribe(__ =>
            {
                MessageBroker.Default.Publish(new PropTag_ModifyHealth(-1));
                MessageBroker.Default.Publish(new GameTag_Reload());
            });
        }
Esempio n. 4
0
        protected override System.Collections.IEnumerator OnInitializeRegisterSelf()
        {
            Mgr.Instance.RegisterModule(this);
            Debug.Log("Create PropertyManager");
            yield return(BrickMgrM.WaitModule <ILoaderTag>());

            //初始化数据
            plusCount.Init(100, PlayerPrefs.GetInt(PlayerPrefKey.PlusCount, 999));
            multiplyCount.Init(100, PlayerPrefs.GetInt(PlayerPrefKey.MultiplyCount, 999));
            // HealthCount.Init(3);
            //
            Difficulty = (EDifficulty)PlayerPrefs.GetInt(PlayerPrefKey.Difiicuilty, 1);
            Level      = PlayerPrefs.GetInt(PlayerPrefKey.Level, 1);

            //改变生命
            MessageBroker.Default.Receive <PropTag_ModifyHealth>().Where(x => x.isInit == false).Subscribe(x => OnModifyHealth(x.value)).AddTo(this);
            //改变plus
            MessageBroker.Default.Receive <PropTag_ModifyPlusCount>().Subscribe(x => OnModifyPlus(x.value)).AddTo(this);
            //改变multiply
            MessageBroker.Default.Receive <PropTag_ModifyMultiplyCount>().Subscribe(x => OnModufyMultiply(x.value)).AddTo(this);
            //改变slider size
            MessageBroker.Default.Receive <PropTag_ModifySliderSize>().Where(x => x.isInit == false).Subscribe(x => OnModifySliderSize(x.value)).AddTo(this);
            //游戏开始
            MessageBroker.Default.Receive <GameTag_GameStart>().Subscribe(__ => OnGameStart()).AddTo(this);
            //退出游戏
            MessageBroker.Default.Receive <GameTag_QuitGame>().Subscribe(__ => OnGameEnd()).AddTo(this);
            //游戏结束
            MessageBroker.Default.Receive <GameTag_GameEnd>().Subscribe(__ => OnGameEnd()).AddTo(this);
            //回到菜单
            MessageBroker.Default.Receive <GameTag_BackToMenu>().Subscribe(__ => OnGameEnd()).AddTo(this);
        }
Esempio n. 5
0
        protected override System.Collections.IEnumerator OnStart()
        {
            _collider = GetComponent <EdgeCollider2D>();
            yield return(BrickMgrM.WaitModule <IEntityTag>());

            BrickMgrM.EntityModule.RegisteBoard(this);
        }
Esempio n. 6
0
        protected override System.Collections.IEnumerator OnInitializeRegisterSelf()
        {
            Mgr.Instance.RegisterModule(this);
            Debug.Log("Create GridManager");
            yield return(BrickMgrM.WaitModule <ILoaderTag>());

            //游戏开始,加载对应关卡的LevelTile
            MessageBroker.Default.Receive <GameTag_GameStart>().Subscribe(x => StartCoroutine(LoadLevel(x.level, x.difficulty))).AddTo(this);;
        }
Esempio n. 7
0
        protected override System.Collections.IEnumerator OnStart()
        {
            _collider = GetComponent <CircleCollider2D>();
            rb        = GetComponent <Rigidbody2D>();
            yield return(BrickMgrM.WaitModule <IEntityTag>());

            BrickMgrM.EntityModule.RegisteBall(this);
            rb.gravityScale = 0;
            //Init(Vector3.zero, new Vector3(0, 0, -180));
        }
Esempio n. 8
0
        protected override IEnumerator OnStart()
        {
            yield return(BrickMgrM.WaitModule <IPoolTag>());

            var aop = Resources.LoadAsync(_path);

            yield return(aop);

            pool = BrickMgrM.PoolModule.GetOrCreate <T>(aop.asset as GameObject);
        }
Esempio n. 9
0
        protected override System.Collections.IEnumerator OnInitializeRegisterSelf()
        {
            // Screen.SetResolution(1366, 768, true);
            isLoaded = false;
            Mgr.Instance.RegisterModule(this);
            Debug.Log("Create LoaderManager");
            yield return(BrickMgrM.WaitModule <IPropertyTag>());

            //TEST
            BackToMainMenu();
            yield return(new WaitForSeconds(1));

            isLoaded = true;
        }
Esempio n. 10
0
        protected override IEnumerator AfterStart()
        {
            yield return(BrickMgrM.WaitModule <IEntityTag>());;
            this.RegisterSelf(this);

            _camera = Camera.main;

            var dragTrigger      = this.gameObject.AddComponent <ObservableDragTrigger>();
            var endDragTrigger   = this.gameObject.AddComponent <ObservableEndDragTrigger>();
            var beginDragTrigger = this.gameObject.AddComponent <ObservableBeginDragTrigger>();
            // ---------------------------------
            float?  last = null;
            float   worldX;
            Vector3 temp = new Vector3();

            MessageBroker.Default.Receive <GameTag_Reload>().Subscribe(__ => _firstTap = false).AddTo(this);
            // ---------------------------------
            //初次拖动,生成小球
            beginDragTrigger.OnBeginDragAsObservable().Where(__ => _firstTap == false)
            .Where(__ => BrickMgrM.EntityModule.startBall != null)
            .Subscribe(__ =>
            {
                _firstTap = true;
                MessageBroker.Default.Publish(new SkillTag_TryPlusSkill());
                BrickMgrM.LoaderManager.ReleaseObject(BrickMgrM.EntityModule.startBall.gameObject);
                BrickMgrM.EntityModule.startBall = null;
            });
            // ----------------------
            // 拖动时候Board变化modifier倍数的相对距离
            dragTrigger.OnDragAsObservable()
            .RepeatUntilDestroy(this)
            .Subscribe(data =>
            {
                // if (BrickMgrM.LoaderManager.isInGameState == false) BrickMgrM.LoaderManager.isInGameState = true;
                worldX         = _camera.ScreenToWorldPoint(data.position).x *_modifier;
                _deltaVertical = last == null?0: (worldX - last.Value);
                temp.x         = _deltaVertical;
                BrickMgrM.EntityModule.SlidersList.ForEach(x => x.transform.position += temp);
                last = worldX;
            });
            // ----------------------
            //结束拖动
            endDragTrigger.OnEndDragAsObservable()
            .RepeatUntilDestroy(this)
            .Subscribe(data =>
            {
                last           = null;
                _deltaVertical = 0;
            });
        }
Esempio n. 11
0
        protected override IEnumerator OnStart()
        {
            _rb = GetComponent <Rigidbody2D>();
            _rb.gravityScale = 0;
            yield return(BrickMgrM.WaitModule <IEntityTag>());

            yield return(BrickMgrM.WaitModule <IPropertyTag>());

            BrickMgrM.EntityModule.RegisteBonus(this);
            // //依赖skillHolder
            // skillHolder = BrickMgrM.PropertyModule.GetElement<SkillHolder>();
            //下降

            Observable.EveryUpdate()
            .Subscribe(__ =>
            {
                this.transform.Translate(Vector3.down * _speed * Time.deltaTime, Space.World);
            }).AddTo(this);
        }
Esempio n. 12
0
        protected override IEnumerator AfterStart()
        {
            this.RegisterSelf(this);
            yield return(BrickMgrM.WaitModule <IPoolTag>());

            slotsList = new List <UI_LevelSlot>();

            _content    = gameObject.Descendants().Where(x => x.name == "Content").First().transform;
            _backButton = _backButton.GetComponentFromChildren(this, nameof(_backButton));
            _backButton.OnClickAsObservable().TakeUntilDestroy(this).Subscribe(__ =>
            {
                this.Hide();
                BrickMgrM.UIModule.GetElement <UI_MainMenu>().Show();
            });
            // ----------------------
            string path = AssetPath.PrefabPrefix + AssetPath.LevelSlotButton;
            var    aop  = Resources.LoadAsync(path);

            Debug.Log(path);
            yield return(aop);

            // ----------------------
            //创建物品池
            pool = BrickMgrM.PoolModule.GetOrCreate <UI_LevelSlot>(aop.asset as GameObject);
            // pool.setInActiveWhenReturn = false;
            pool.parent        = _content;
            pool.onBeforeRent += x =>
            {
                x.transform.SetParent(_content);
                x.transform.localScale    = Vector3.one;
                x.transform.localPosition = Vector3.zero;
            };
            pool.onBeforeReturn += x =>
            {
                // x.transform.SetParent(_content);
            };
            pool.PreloadAsync(100, 10).Subscribe();
            PreloadLevelSlot(100, 1, EDifficulty.Eazy);
            // ----------------------
        }
Esempio n. 13
0
 protected override IEnumerator OnStart()
 {
     yield return(BrickMgrM.WaitModule <IEntityTag>());
 }