Beispiel #1
0
    public static FreeCoordinate StringToFreeCoordinate(string str)
    {
        FreeCoordinate ret = new FreeCoordinate(NONE, NONE);

        string[] cStr = str.Split(SUB_CELL_DIVIDER);

        if (cStr.Length != 2)
        {
            Debug.LogWarning("Cannot parse string to coordinate: " + str);
        }
        else
        {
            int x = NONE, y = NONE;

            if (!int.TryParse(cStr[0], out x))
            {
                Debug.LogWarning("Cannot parse string to coordinate: " + str + " X component: " + cStr[0]);
            }

            if (!int.TryParse(cStr[1], out y))
            {
                Debug.LogWarning("Cannot parse string to coordinate: " + str + " Y component: " + cStr[1]);
            }

            ret.Reset(x, y);
        }

        return(ret);
    }
Beispiel #2
0
    public static string FreeCoordinateToString(FreeCoordinate c)
    {
        _stringBuilder.Remove(0, _stringBuilder.Length);

        _stringBuilder.Append(c.x);
        _stringBuilder.Append(SUB_CELL_DIVIDER);
        _stringBuilder.Append(c.y);

        return(_stringBuilder.ToString());
    }
Beispiel #3
0
    public FreeCoordinate(FreeCoordinate cloneCoordinate)
    {
        if (cloneCoordinate == null)
        {
            Debug.Log("Cloning null coordinate!");
        }

        this.x = cloneCoordinate.x;
        this.y = cloneCoordinate.y;
    }
Beispiel #4
0
    public override bool Equals(object obj)
    {
        FreeCoordinate coordinate = obj as FreeCoordinate;

        if (coordinate != null)
        {
            return(coordinate.x == x && coordinate.y == y);
        }

        return(false);
    }