예제 #1
0
    public override bool Equals(object other)
    {
        if (!(other is Vector2ixy))
        {
            return(false);
        }
        Vector2ixy vector = (Vector2ixy)other;

        return(this.m_x.Equals(vector.m_x) && this.m_y.Equals(vector.m_y));
    }
예제 #2
0
    /// <summary>
    /// 钻石到交错
    /// </summary>
    /// <returns></returns>
    public static Vector2ixy ConvertDiamondToStaggered(Vector2ixy v1)
    {
        int x1 = v1.m_x;
        int y1 = v1.m_y;
        int x2;
        int y2;

        y2 = x1 - y1;
        if (y2 % 2 == 1)
        {
            x2 = x1 - 1 - y2 / 2;
        }
        else
        {
            x2 = x1 - y2 / 2;
        }
        return(new Vector2ixy(x2, y2));
    }
예제 #3
0
    /// <summary>
    /// 交错转钻石
    /// </summary>
    /// <returns></returns>
    public static Vector2ixy ConvertStaggeredToDiamond(Vector2ixy v2)
    {
        int x2 = v2.m_x;
        int y2 = v2.m_y;
        int x1 = 0;
        int y1 = 0;

        if (y2 % 2 == 1)
        {
            x1 = x2 + y2 / 2 + 1;
            y1 = x1 - y2;
        }
        else
        {
            x1 = x2 + y2 / 2;
            y1 = x1 - y2;
        }
        return(new Vector2ixy(x1, y1));
    }
예제 #4
0
    public static float Distance(Vector2ixy a, Vector2ixy b)
    {
        Vector2ixy vector = new Vector2ixy(a.m_x - b.m_x, a.m_y - b.m_y);

        return(vector.magnitude);
    }
예제 #5
0
    public static Vector2ixy operator -(Vector2ixy a, Vector2ixy b)
    {
        Vector2ixy ret = new Vector2ixy(a.m_x - b.m_x, a.m_y - b.m_y);

        return(ret);
    }
예제 #6
0
 public static float SqrMagnitude(Vector2ixy a)
 {
     return(a.m_x * a.m_x + a.m_y * a.m_y);
 }