// TIPS: ゲームループ IEnumerator MainGame() { _state = State.MainGame; _counter.TimeReset(); _startCount.Visible(); _audio.Play(14); var countDown = 3.5f; while (countDown > 0f) { countDown -= Time.deltaTime; _startCount.UpdateCount(Mathf.RoundToInt(countDown)); _device.ModelUpdate(); yield return(null); } _startCount.Visible(); if (_suddenDeath.isVisible) { _suddenDeath.Visible(); _counter.time = _counter.timeCount * 0.5f; } var finishCountStart = false; while (_counter.time > 0f) { _device.ModelUpdate(); _counter.board.text = "Time: " + _counter.timeToInt; // TIPS: モデルが表示されている間だけ実行 if (_device.models.All(model => model.isVisible)) { ActiveGameMode(); if (_counter.time < 3.5f && !finishCountStart) { finishCountStart = true; _audio.Play(15); _finishCount.Visible(); } } yield return(null); } _finishCount.Visible(); var p1score = _device.player1.scoreBoard.count; var p2score = _device.player2.scoreBoard.count; var draw = (p1score == p2score); if (draw) { _suddenDeath.Visible(); yield return(StartCoroutine(MainGame())); } }
void ActiveGameMode() { _counter.UpdateTimeCount(); if (_device.player1.inputKey()) { Shot(_device.player1, _device.player2); } if (_device.player2.inputKey()) { Shot(_device.player2, _device.player1); } if (_counter.time > 3.5f) { return; } _finishCount.UpdateCount(_counter.timeToInt); }