Пример #1
0
    Vector2 RotateArrayVector2(Vector2 pos, Vector2 array_size, float angle)
    {
        //array_size-=Vector2.one;
        var m = Matrix4x4.TRS(Vector3.zero, Quaternion.AngleAxis(angle, Vector3.forward), Vector3.one);
        var v = m.MultiplyVector(new Vector3(pos.x, pos.y));

        int xx = Mathf.RoundToInt(v.x), ax = Mathf.RoundToInt(array_size.x);
        int yy = Mathf.RoundToInt(v.y), ay = Mathf.RoundToInt(array_size.y);

        if (angle == 90 || angle == 180)
        {
            xx--;
        }
        if (angle == 180 || angle == 270)
        {
            yy--;
        }

        int x = Subs.Wrap(xx, 0, ax);
        int y = Subs.Wrap(yy, 0, ay);

        return(new Vector2(x, y));
    }
Пример #2
0
 void addY(int a)
 {
     s_y = Subs.Wrap(s_y + a, 0, Grid.GetLength(1));
 }
Пример #3
0
 void addX(int a)
 {
     s_x = Subs.Wrap(s_x + a, 0, Grid.GetLength(0));
 }