public void Unpause()
 {
     if (State == FallingDownGameState.Paused)
     {
         m_pauseObjectAnimatorInstance.SetBool("shouldExit", true);
         State = FallingDownGameState.InGame;
         OnUnpause?.Invoke();
     }
 }
 public void Pause()
 {
     if (State == FallingDownGameState.InGame)
     {
         m_pauseObjectAnimatorInstance = Instantiate(m_pauseObjcectAnimatorPrefab,
                                                     m_pauseObjcectAnimatorPrefab.transform.parent);
         m_pauseObjectAnimatorInstance.gameObject.SetActive(true);
         State = FallingDownGameState.Paused;
         OnPause?.Invoke();
     }
 }
    public void Init(GameSession parentSession)
    {
        //TODO: Implement the waiting
        State         = FallingDownGameState.InGame;
        m_gameSession = parentSession;
        m_players     = new FallingDownPlayer[2];

        m_players[0] = CreatePlayer(new Vector2(6, 3), Color.red,
                                    new PlayerInputDefault(KeyCode.A, KeyCode.D, KeyCode.W));
        m_players[1] = CreatePlayer(new Vector2(18, 3), Color.cyan,
                                    new PlayerInputDefault(KeyCode.LeftArrow, KeyCode.RightArrow, KeyCode.UpArrow));

        m_scanLine = CreateScanLine();
    }
    public void EndGame()
    {
        if (State == FallingDownGameState.InGame)
        {
            State = FallingDownGameState.Ended;
            Debug.Assert(m_depthText != null);
            Debug.Assert(m_gameOverPanel != null);
            m_gameOverPanel.gameObject.SetActive(true);
            int depth = Mathf.FloorToInt(-Mathf.Min(0f,
                                                    Mathf.Min(m_players[0].transform.position.y,
                                                              m_players[1].transform.position.y)));
            m_depthText.text = $"{depth}M";

            FallingDownRecord record;
            if (m_gameSession.Record.TryGetGameRecord <FallingDownRecord>("FallingDown", out record))
            {
                if (record.MaxDepth < depth)
                {
                    record.MaxDepth = depth;
                    m_gameSession.SyncRecord();
                }
            }
            else
            {
                record = new FallingDownRecord()
                {
                    MaxDepth = depth
                };
                m_gameSession.Record.SetGameRecord("FallingDown", record);
                m_gameSession.SyncRecord();
            }

            Debug.Assert(!(m_recordText is null));
            m_recordText.text = $"{record.MaxDepth}M";
        }

        //TODO: display the end game window
    }