using System;
using UnityEngine;

public class SceneADV : MonoBehaviour
{
	public void Awake()
	{
		if (GameMain.Instance.VRMode)
		{
			GameObject gameObject = Resources.Load("OVR/DummyNGUICamera") as GameObject;
			NDebug.Assert(gameObject != null, "DummyNGUICameraが読み込めません。");
			GameObject gameObject2 = UnityEngine.Object.Instantiate<GameObject>(gameObject);
			gameObject2.transform.SetParent(base.transform, false);
		}
		this.panel = this.titleBar.transform.parent.GetComponent<UIPanel>();
		this.panel.alpha = 0f;
	}

	public void Start()
	{
		GameMain.Instance.ScriptMgr.adv_kag.enabled = true;
		GameMain.Instance.ScriptMgr.adv_kag.Exec();
	}

	public void CallTitleBar(string title)
	{
		int num = (1920 >= Screen.width) ? 1920 : Screen.width;
		int num2 = num / 2 * -1;
		int num3 = 456;
		UILabel componentInChildren = this.titleBar.GetComponentInChildren<UILabel>();
		componentInChildren.text = title;
		componentInChildren.width = 0;
		componentInChildren.MakePixelPerfect();
		GameObject childObject = UTY.GetChildObject(this.titleBar, "BG", false);
		UIWidget component = childObject.gameObject.GetComponent<UIWidget>();
		component.width = (int)componentInChildren.transform.localPosition.x + componentInChildren.width + 100;
		this.titleBarEffectStartPosX = num2 - component.width;
		this.titleBarAddPosX = component.width - 50;
		this.titleBar.transform.localPosition = new Vector3((float)this.titleBarEffectStartPosX, (float)num3, 0f);
		iTween.Stop(base.gameObject);
		iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
		{
			"easetype",
			iTween.EaseType.easeOutCubic,
			"from",
			0,
			"to",
			1,
			"time",
			0.5f,
			"onupdate",
			"UpdateFadeIn",
			"oncomplete",
			"OnEndFadeIn"
		}));
		this.panel.alpha = 1f;
	}

	private void UpdateFadeIn(float value)
	{
		int num = (int)((float)this.titleBarAddPosX * value);
		Vector3 localPosition = this.titleBar.transform.localPosition;
		this.titleBar.transform.localPosition = new Vector3((float)(this.titleBarEffectStartPosX + num), localPosition.y, 0f);
	}

	private void OnEndFadeIn()
	{
		Vector3 localPosition = this.titleBar.transform.localPosition;
		this.titleBar.transform.localPosition = new Vector3((float)(this.titleBarEffectStartPosX + this.titleBarAddPosX), localPosition.y, 0f);
		iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
		{
			"easetype",
			iTween.EaseType.easeOutCubic,
			"delay",
			this.titleBarDisplayTime,
			"from",
			1,
			"to",
			0,
			"time",
			0.5f,
			"onupdate",
			"UpdateFadeOut",
			"oncomplete",
			"OnEndFadeOut"
		}));
	}

	private void UpdateFadeOut(float value)
	{
		this.panel.alpha = value;
	}

	private void OnEndFadeOut()
	{
		this.panel.alpha = 0f;
	}

	[SerializeField]
	public GameObject titleBar;

	[SerializeField]
	public float titleBarDisplayTime;

	private UIPanel panel;

	private int titleBarEffectStartPosX;

	private int titleBarAddPosX;
}
