Example #1
0
        public void Start()
        {
            var gameTimerObj = GameObject.Find("GameTimer");

            if (gameTimerObj == null)
            {
                Debug.LogError("GameTimer GameObject is not found");
                return;
            }

            var gameTimer = gameTimerObj.GetComponent <GameTimer>();

            if (gameTimer == null)
            {
                Debug.LogError("GameTimer Component is not attached to GameTiemr GameObject");
                return;
            }

            remainedTimeSecond
            .Where(time => remainedTimeSecond.Value <= 0)
            .Subscribe(_ =>
            {
                isEnabled.Value = false;

                if (timerDisposable != null)
                {
                    timerDisposable.Dispose();
                }
            })
            .AddTo(gameObject);

            var index = 0;

            gameTimer.ElapsedTimeSecond
            .Subscribe(time =>
            {
                if (index < raiseTimeSecondList.Length && time >= raiseTimeSecondList[index])
                {
                    ++index;
                    Raise();
                }
            })
            .AddTo(gameObject);

            // SE
            feverAudio = GetComponent <AudioSource>();
            Assert.IsNotNull(feverAudio);

            var gameBGM = GameObject.Find("GameBGM").GetComponent <AudioSource>();

            Assert.IsNotNull(gameBGM);

            var feverStart = GameObject.Find("FeverStart").GetComponent <UI.FruitFever>();

            Assert.IsNotNull(feverStart);

            // Fever Start SE
            IsEnabled.Where(x => x == true).Subscribe(_ =>
            {
                float audioSize = feverAudio.clip.length;

                // show Fever Effect
                feverStart.ShowEffect();

                StartCoroutine(DurationBGMMute(gameBGM, audioSize));

                feverAudio.Play();
            }).AddTo(gameObject);
        }