public static Vector2Int Parse(string input) { var m = vec_reg.Match(input); if (m.Success) { Vector2Int val = new Vector2Int(); val.x = int.Parse(m.Groups["X"].Value); val.x = int.Parse(m.Groups["Y"].Value); return val; } else throw new FormatException("Input string was not in correct format"); }
public static bool TryParse(string input, out Vector2Int ret) { var m = vec_reg.Match(input); ret = new Vector2Int(); if (m.Success) { if(int.TryParse(m.Groups["X"].Value, out ret.x)) return int.TryParse(m.Groups["Y"].Value, out ret.y); else return false; } else return false; }
public static int Dot(Vector2Int a, Vector2Int b) { return a.x * b.x + a.y * b.y; }