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

public class VSResult : Result_Display
{
	private void Awake()
	{
		this.m_IsWin = (GameMain.Instance.CharacterMgr.status.GetFlag("ダンス勝敗") == 1);
		if (!this.m_IsWin)
		{
			this.m_BattleResultEnd = this.m_BattleResultUI.localPosition;
			this.m_BattleResultUI.localPosition += Vector3.down * this.m_LoseUIDown;
			this.m_BattleResultStart = this.m_BattleResultUI.localPosition;
			this.m_BattlePanel = this.m_BattleResultUI.GetComponent<UIPanel>();
			this.m_BattlePanel.alpha = 0f;
		}
		base.Initialize();
		base.StartCoroutine(this.SlideIn());
	}

	protected override void UIInit(Transform child)
	{
		UISprite component = child.GetComponent<UISprite>();
		Vector3 localPosition = child.localPosition;
		localPosition.x = UI_ScreenFitBase.PointToScreenPos(Vector3.right * (float)UICamera.ScreenWidth).x;
		if (component)
		{
			localPosition.x += (float)(component.width / 2);
		}
		if (this.m_BattleResultUI != child)
		{
			this.m_GroupEnd.Add(child.localPosition);
			this.m_GroupStart.Add(localPosition);
			child.localPosition = localPosition;
			this.m_SlideUIList.Add(child);
		}
		else if (this.m_IsWin)
		{
			this.m_BattleResultStart = localPosition;
			this.m_BattleResultEnd = child.localPosition;
			child.localPosition = localPosition;
		}
	}

	protected override void Update()
	{
		base.Update();
	}

	private IEnumerator SlideIn()
	{
		while (GameMain.Instance.MainCamera.IsFadeOut())
		{
			yield return null;
		}
		float timer = 0f;
		int count = 0;
		GameMain.Instance.SoundMgr.PlaySe(this.m_SlideSEName, false);
		for (;;)
		{
			timer += base.m_MydeltaTime;
			this.m_SlideUIList[count].localPosition = Vector3.Lerp(this.m_GroupStart[count], this.m_GroupEnd[count], base.SinRate01(timer, this.m_UISlide));
			if (timer > this.m_UISlide)
			{
				count++;
				timer = 0f;
				if (count == this.m_SlideUIList.Count)
				{
					break;
				}
				GameMain.Instance.SoundMgr.PlaySe(this.m_SlideSEName, false);
				yield return new WaitForSeconds(this.m_UISlideRug / (float)this.m_TimeSpeed);
			}
			yield return null;
		}
		yield return new WaitForSeconds(this.m_BatteleResultWait / (float)this.m_TimeSpeed);
		base.StartCoroutine(this.DisplayBattleResult());
		yield break;
		yield break;
	}

	private IEnumerator DisplayBattleResult()
	{
		float timer = 0f;
		if (this.m_IsWin)
		{
			GameMain.Instance.SoundMgr.PlaySe(this.m_WinSEName, false);
		}
		else
		{
			GameMain.Instance.SoundMgr.PlaySe(this.m_LoseSEName, false);
		}
		for (;;)
		{
			timer += base.m_MydeltaTime;
			float time_rimmit = 0f;
			if (this.m_IsWin)
			{
				this.m_BattleResultUI.localPosition = Vector3.Lerp(this.m_BattleResultStart, this.m_BattleResultEnd, base.SinRate01(timer, this.m_WinSlide));
				time_rimmit = this.m_WinSlide;
			}
			else
			{
				this.m_BattleResultUI.localPosition = Vector3.Lerp(this.m_BattleResultStart, this.m_BattleResultEnd, base.SinRate01(timer, this.m_LoseUIFade));
				this.m_BattlePanel.alpha = base.SinRate01(timer, this.m_LoseUIFade);
				time_rimmit = this.m_LoseUIFade;
			}
			if (timer > time_rimmit)
			{
				break;
			}
			yield return null;
		}
		yield return new WaitForSeconds(this.m_ButtonActiveWait / (float)this.m_TimeSpeed);
		this.m_ButtonUI.SetActive(true);
		yield break;
		yield break;
	}

	[SerializeField]
	[Header("勝った時に鳴らすSE")]
	private string m_WinSEName = "4_battle_win.ogg";

	[SerializeField]
	[Header("負けた時に鳴らすSE")]
	private string m_LoseSEName = "5_battle_lose.ogg";

	[SerializeField]
	[Header("UIのスライド時間")]
	private float m_UISlide = 0.15f;

	[SerializeField]
	[Header("UI表示終了後の待機時間")]
	private float m_UISlideRug = 0.0625f;

	[SerializeField]
	[Header("対戦結果を表示するまでの待機時間")]
	private float m_BatteleResultWait = 1f;

	[SerializeField]
	[Header("勝利時のUIスライド時間")]
	private float m_WinSlide = 0.15f;

	[SerializeField]
	private float m_LoseUIDown = 1f;

	[SerializeField]
	[Header("勝利時のUIフェードイン時間")]
	private float m_LoseUIFade = 0.75f;

	private Vector3 m_BattleResultStart;

	private Vector3 m_BattleResultEnd;

	[SerializeField]
	[Header("結果表示後の待機時間")]
	private float m_ButtonActiveWait = 0.5f;

	[SerializeField]
	[Header("勝負結果表示UI")]
	private Transform m_BattleResultUI;

	private List<Transform> m_SlideUIList = new List<Transform>();

	private UIPanel m_BattlePanel;

	private bool m_IsWin;
}
