using UnityEngine;

namespace WS
{
	public static class Game
	{
		private static ObjectPool objectPool;
		///<summary>类对象池</summary>
		public static ObjectPool ObjectPool
		{
			get
			{
				if (objectPool == null)
				{
					objectPool = new ObjectPool();
				}
				return objectPool;
			}
		}

		private static EventSystem eventSystem;
		///<summary>事件系统</summary>
		public static EventSystem EventSystem
		{
			get
			{
				if (eventSystem == null)
				{
					eventSystem = new EventSystem();
				}
				return eventSystem;
			}
		}

		private static Scene scene;
		///<summary>组件挂载器</summary>
		public static Scene Scene
		{
			get
			{
				if (scene == null)
				{
					scene = new Scene();
				}
				return scene;
			}
		}

		private static Transform init;
		///<summary>Init游戏物体</summary>
		public static Transform Init
		{
			get { return init; }
			set { init = value; }
		}

		private static Camera uiCamera;
		///<summary>UI相机</summary>
		public static Camera UICamera
        {
			get 
			{
				if (uiCamera == null)
				{
					uiCamera = init.Find("UI/UICamera").GetComponent<Camera>();
				}
				return uiCamera;
			}
		}

		public static void Close()
		{
			objectPool?.Dispose();
			objectPool = null;

			eventSystem?.Dispose();
			eventSystem = null;

			scene?.Dispose();
			scene = null;
		}
	}
}