Esempio n. 1
0
    private void InitializePlayerController()
    {
        playerController.Initialize();
        playerController.OnEnemyDefeated = (enemy) =>
        {
            // add score
            GlobalStore.Instance.ScoreStore.AddScore(enemy.Score);

            // go to next stage if enemies are all dead
            if (enemyController.AliveEnemies.Count() == 0)
            {
                // reload the scene
                GlobalStore.Instance.StageStore.IncrementStage();
                NextStateSet(GetComponent <InGameState>());
                return;
            }

            // 敵を一時停止(既に停止中の場合は、停止時間を引き伸ばすことはしない)
            if (!isPausingGame && PausingEnemyCoroutine == null)
            {
                PausingEnemyCoroutine = StartCoroutine(PauseEnemiesShortly());
            }
        };

        playerController.OnDeadAnimationStart = () =>
        {
            PauseGame();
            materialController.ChangeAllColorRed();
        };

        playerController.OnDeadAnimationEnd = () =>
        {
            // reborn
            if (GlobalStore.Instance.PlayerStore.Life > 0)
            {
                GlobalStore.Instance.PlayerStore.DecrementLife();
                materialController.RestoreAllColor();
                StartCoroutine(RebornGame());
            }
            // GameOver
            else
            {
                StartCoroutine(GameOver());
            }
        };
        materialController.Add(playerController.Player.GetComponentsInChildren <MeshRenderer>());
    }