Exemplo n.º 1
0
        public void Update()
        {
            if (_isFinishedCanvasShown)
            {
                return;
            }

            if (_chunkFactory.CurrentState == ChunkFactory.State.FINISHED && !_gameManager.IsGameover)
            {
                // ゲームクリアの画面を表示する
                var obj = Instantiate(_originalFinishedCanvas, this.transform).GetComponent <FinishedCanvas>();
                obj.Text.text             = _localizer.GetLocalize("Finish");
                obj.RetryLabel.text       = _localizer.GetLocalize("Retry");
                obj.BackToTitleLabel.text = _localizer.GetLocalize("BackToTitle");

                _isFinishedCanvasShown = true;
                _remaining.gameObject.SetActive(false);
                _lifeGauge.SetActive(false);
                return;
            }

            if (_gameManager.IsGameover)
            {
                // ゲームオーバーの画面を表示する
                var obj = Instantiate(_originalFinishedCanvas, this.transform).GetComponent <FinishedCanvas>();
                obj.Text.text             = _localizer.GetLocalize("GameOver");
                obj.RetryLabel.text       = _localizer.GetLocalize("Retry");
                obj.BackToTitleLabel.text = _localizer.GetLocalize("BackToTitle");

                _isFinishedCanvasShown = true;
                _remaining.gameObject.SetActive(false);
                _lifeGauge.SetActive(false);
                return;
            }

            _currentPhase.text = _localizer.GetFormattedString(
                "CurrentPhase",
                _chunkFactory.CurrentPhase,
                _chunkFactory.MaxPhase
                );

            //=====================================================
            // 残りのチャンク数を表示する
            //=====================================================
            _remaining.text = _localizer.GetFormattedString("Remaining", _gameManager.CurrentChunkCount);

            //=====================================================
            // 残機を表示する
            //=====================================================
            var gauges = GameObject.FindGameObjectsWithTag("LifeGauge").ToList();
            var diff   = _life.Life - gauges.Count;

            if (diff > 0)
            {
                for (int i = 0; i < diff; i++)
                {
                    Instantiate(_originalGauge, _lifeGauge.transform).tag = "LifeGauge";
                }
            }

            if (diff < 0)
            {
                var deletedGauges = gauges.GetRange(0, Math.Abs(diff));
                foreach (var g in deletedGauges)
                {
                    Destroy(g);
                }
            }
        }