using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameEndedState : BaseGameState {

    public override void InitState()
    {
        base.InitState();

        this.gameController.UIController.GameOverView.ShowSummary(this.gameController.DataStorage.CurrentGame);
        this.gameController.UIController.GameOverView.OnSummaryClosed += OnSummaryClosed;
        this.gameController.UIController.GameOverView.OnGameReplay += OnGameReplay;
    }

    public override void DeinitState()
    {
        this.gameController.UIController.GameOverView.OnGameReplay -= OnGameReplay;
        this.gameController.UIController.GameOverView.OnSummaryClosed -= OnSummaryClosed;
        this.gameController.UIController.GameOverView.HideView();

        base.DeinitState();
    }


    private void OnSummaryClosed () {
        this.gameController.ChangeState(new GameMenuState());
    }

    private void OnGameReplay () {
        this.gameController.ChangeState(new GenerateNewGameState());
    }
}
