using System;
using UnityEngine;

namespace wf
{
	public static class Parse
	{
		public static Vector2 Vector2(string text)
		{
			Vector2 zero = UnityEngine.Vector2.zero;
			if (string.IsNullOrEmpty(text))
			{
				return zero;
			}
			text = text.Trim();
			string[] array = text.Substring(1, text.Length - 2).Split(new char[]
			{
				','
			});
			if (array.Length == 2)
			{
				zero.x = float.Parse(array[0]);
				zero.y = float.Parse(array[1]);
			}
			return zero;
		}

		public static Vector3 Vector3(string text)
		{
			Vector3 zero = UnityEngine.Vector3.zero;
			if (string.IsNullOrEmpty(text))
			{
				return zero;
			}
			text = text.Trim();
			string[] array = text.Substring(1, text.Length - 2).Split(new char[]
			{
				','
			});
			if (array.Length == 3)
			{
				zero.x = float.Parse(array[0]);
				zero.y = float.Parse(array[1]);
				zero.z = float.Parse(array[2]);
			}
			return zero;
		}

		public static Vector4 Vector4(string text)
		{
			Vector4 zero = UnityEngine.Vector4.zero;
			if (string.IsNullOrEmpty(text))
			{
				return zero;
			}
			text = text.Trim();
			string[] array = text.Substring(1, text.Length - 2).Split(new char[]
			{
				','
			});
			if (array.Length == 4)
			{
				zero.x = float.Parse(array[0]);
				zero.y = float.Parse(array[1]);
				zero.z = float.Parse(array[2]);
				zero.w = float.Parse(array[3]);
			}
			return zero;
		}

		public static Quaternion Quaternion(string text)
		{
			Quaternion identity = UnityEngine.Quaternion.identity;
			if (string.IsNullOrEmpty(text))
			{
				return identity;
			}
			text = text.Trim();
			string[] array = text.Substring(1, text.Length - 2).Split(new char[]
			{
				','
			});
			if (array.Length == 4)
			{
				identity = new Quaternion(float.Parse(array[0]), float.Parse(array[1]), float.Parse(array[2]), float.Parse(array[3]));
			}
			return identity;
		}

		public static Color Color(string text)
		{
			Color result = default(Color);
			if (string.IsNullOrEmpty(text))
			{
				return result;
			}
			text = text.Trim().Replace("RGBA", string.Empty);
			string[] array = text.Substring(1, text.Length - 2).Split(new char[]
			{
				','
			});
			if (array.Length == 4)
			{
				result = new Color(float.Parse(array[0]), float.Parse(array[1]), float.Parse(array[2]), float.Parse(array[3]));
			}
			return result;
		}
	}
}
