Esempio n. 1
0
File: Canvas.cs Progetto: kijun/art
        public void Fill(Color color)
        {
            Rect rect = currZoomToWorldScale;
            var  rp   = new RectParams {
                position = rect.center, scale = rect.size, level = zoomStack.Count, color = color
            };

            var r = NoteFactory.CreateRect(rp);
            //rect = NodeFactory.CreateRect(
        }
Esempio n. 2
0
    public static Animatable2 CreateRect(RectParams rp, MotionParams mp = new MotionParams())
    {
        var p = CreatePlane(rp.scale, rp.rotation);

        p.localScale = rp.scale;
        p.position   = rp.position;
        // must come after position
        p.level    = rp.level;
        p.velocity = mp.velocity;
        p.color    = rp.color;
        return(p);
    }
Esempio n. 3
0
    public static Animatable2 CreateRectInViewport(float x, float y, float width, float height, Color color, float rotation = 0, float level = 0, Vector2 velocity = new Vector2())
    {
        var position = CameraHelper.ViewportToWorldPoint(x, y);
        var scale    = CameraHelper.ViewportToWorldScale(width, height);
        var lp       = new RectParams {
            position = position,
            scale    = scale,
            color    = color,
            rotation = rotation,
            level    = level
        };

        var mp = new MotionParams {
            velocity = velocity
        };

        return(CreateRect(lp, mp));
    }
Esempio n. 4
0
File: Agent.cs Progetto: kijun/art
    /***** PUBLIC STATIC METHOD *****/
    public static Tile[,] CreateBoard(int cols, int rows, float length)
    {
        Debug.Log("Creating board " + cols + " " + rows);
        var board    = new Tile[cols, rows]; // x, y
        var diagonal = length * 1.414f;
        var xmin     = -(diagonal * (cols - 1)) / 2;
        var ymin     = -(diagonal * (rows - 1)) / 2;

        for (int i = 0; i < cols; i++)
        {
            for (int j = 0; j < rows; j++)
            {
                var rp = new RectParams {
                    x      = xmin + i * diagonal,
                    y      = ymin + j * diagonal,
                    width  = length,
                    height = length,
                    color  = new Color32(1, 104, 200, 255)
                };

                var anim = NoteFactory.CreateRect(rp);
                var tile = anim.gameObject.AddComponent <Tile>();
                board[i, j] = tile;
            }
        }

        for (int x = 0; x < cols; x++)
        {
            for (int y = 0; y < rows; y++)
            {
                var tile = (Tile)board.GetValue2(x, y);
                tile.AddAdjacentTile(Location.TopLeft, (Tile)board.GetValue2(x - 1, y - 1));
                tile.AddAdjacentTile(Location.Top, (Tile)board.GetValue2(x, y - 1));
                tile.AddAdjacentTile(Location.TopRight, (Tile)board.GetValue2(x + 1, y - 1));
                tile.AddAdjacentTile(Location.Left, (Tile)board.GetValue2(x - 1, y));
                tile.AddAdjacentTile(Location.Right, (Tile)board.GetValue2(x + 1, y));
                tile.AddAdjacentTile(Location.BottomLeft, (Tile)board.GetValue2(x - 1, y + 1));
                tile.AddAdjacentTile(Location.Bottom, (Tile)board.GetValue2(x, y + 1));
                tile.AddAdjacentTile(Location.BottomRight, (Tile)board.GetValue2(x + 1, y + 1));
            }
        }

        return(board);
    }