using System;
using BackupParamAccessor;
using PlayerStatus;
using Schedule;
using UnityEngine;

public class ResultIncomeMgr : BaseCreatePanel
{
	public override void Init()
	{
		this.m_goPanel = base.GetPanel("ResultIncomePanel");
		this.m_ctrl = base.GetCtrl<ResultIncomeCtrl>();
		this.m_ctrl.Init(this, this.m_goPanel);
		this.m_api = new ResultIncomeAPI();
		this.m_goPanel.SetActive(false);
	}

	public void OpenResultIncomePanel()
	{
		Debug.Log("収支リザルトをオープンしました。");
		this.m_api.SceneStart(this, new ResultIncomeAPI.dgOnSceneStartCallBack(this.OpenResultIncomeCallBack));
	}

	public void OpenResultIncomeCallBack()
	{
		base.BaseOpenPanel();
	}

	protected override void OpenPanel()
	{
		ResultIncomeCtrl.ResultIncome loadData = this.LoadData();
		this.ExecuteRelatedAPI();
		this.m_ctrl.CreateViewer(loadData);
	}

	private void ExecuteRelatedAPI()
	{
	}

	private ResultIncomeCtrl.ResultIncome LoadData()
	{
		if (!this.m_initSchedule)
		{
			this.m_diff = ScheduleAPI.OneDayParamDiff(null);
			this.m_initSchedule = true;
		}
		ResultIncomeCtrl.ResultIncome resultIncome = new ResultIncomeCtrl.ResultIncome();
		if (this.m_diff == null)
		{
			Debug.LogWarning("Schedule.ScheduleAPI.OneDayParamDiff()の戻り値がNULLでしたので収支の結果を表示できません。");
			return resultIncome;
		}
		Status status = GameMain.Instance.CharacterMgr.status;
		resultIncome.balance = 0L;
		if (RhythmAction_Mgr.DoChallengeDance)
		{
			RhythmAction_Mgr.DoChallengeDance = false;
			resultIncome.bonusIncome = (long)RhythmAction_Mgr.DanceReward;
			GameMain.Instance.CharacterMgr.status.clubGauge = 0;
			RhythmAction_Mgr.RewardRecet();
		}
		else
		{
			resultIncome.bonusIncome = 0L;
		}
		this.m_dayIncome = (long)this.m_diff.clubMoney;
		resultIncome.workingFunds = (long)this.m_diff.clubMoney;
		resultIncome.clubIncome = status.money - (long)this.m_diff.clubMoney - resultIncome.bonusIncome;
		resultIncome.totalAmount = status.money;
		resultIncome.clientEvaluation = this.m_diff.clubEvaluation;
		resultIncome.acquisitionEvaluation = status.clubEvaluation - this.m_diff.clubEvaluation;
		resultIncome.result = status.clubEvaluation;
		return resultIncome;
	}

	public void CloseResultIncome()
	{
		GameMain.Instance.SysDlg.Close();
		base.BaseClosePanel();
	}

	protected override void AfterClose()
	{
		if (this.sceneMgr != null)
		{
			this.m_api.EndNextScene(new ResultIncomeAPI.dgOnSceneFinalCallBack(this.sceneMgr.CloseScene));
		}
	}

	protected override void SetFadeTargetPanel()
	{
		this.fadeTargetPanel = this.m_goPanel;
	}

	private ResultIncomeCtrl m_ctrl;

	private ResultIncomeAPI m_api;

	private Params m_diff;

	private long m_dayIncome;

	private bool m_initSchedule;
}
