public Puzzle(Graphics dc, string imgFile, int columns, int rows, Size size) { tilesheet = new Tilesheet("picture", imgFile); int tileWidth = (int)((float)tilesheet.Bmp.Width / (float)columns); int tileHeight = (int)((float)tilesheet.Bmp.Height / (float)rows); int adjWidth = tileWidth * columns; int adjHeight = tileHeight * rows; tilesheet.TileSize = new Size(tileWidth, tileHeight); originalSize = tilesheet.Bmp.Size; numColumns = columns; numRows = rows; adjustedSize = new Size(adjWidth, adjHeight); GridPointMatrix matrix = new GridPointMatrix(numColumns, numRows, tileWidth, tileHeight); matrix.CoordinateSystem = new SquareIsoCoordinates(); matrixes = new GridPointMatrixes(matrix); surface = new VisibleSurface(dc, size.Width, size.Height, matrixes); surface.Erase(); InitializeSprites(tileWidth, tileHeight); //Gondwana.Scripting.Parser.WriteToFile("bmpProp_file.gond", System.IO.FileMode.Create, tilesheet); //Engine.ScriptEngineState("file.gond", true); delMoveStart = new SpriteMovementEventHandler(Sprites_SpriteMovementStarted); delMoveStop = new SpriteMovementEventHandler(Sprites_SpriteMovementStopped); Sprites.SpriteMovementStarted += delMoveStart; Sprites.SpriteMovementStopped += delMoveStop; }
public VisibleSurface(Control surface, GridPointMatrixes drawSource) : base(surface.Width, surface.Height) { base.DC = surface.CreateGraphics(); base.Buffer = new Backbuffer(this) { DrawSource = drawSource }; this.RedrawDirtyRectangleOnly = true; }
public VisibleSurface(Graphics graphics, int wdth, int hght, GridPointMatrixes drawSource) : base(wdth, hght) { base.DC = graphics; base.Buffer = new Backbuffer(this) { DrawSource = drawSource }; this.RedrawDirtyRectangleOnly = true; }
public override void Bind(GridPointMatrixes layers) { GridPointMatrixes oldBind = Buffer.DrawSource; ((Backbuffer)Buffer).DrawSource = layers; if (VisibleSurfaceBind != null) VisibleSurfaceBind(new VisibleSufaceBindEventArgs(this, oldBind, layers)); }
public VisibleSufaceBindEventArgs(VisibleSurfaceBase surface, GridPointMatrixes oldBind, GridPointMatrixes newBind) { Surface = surface; OldBindValue = oldBind; NewBindValue = newBind; }
protected internal GridPointMatrixesDisposingEventArgs(GridPointMatrixes matrixLayers) { Matrixes = matrixLayers; }
public abstract void Bind(GridPointMatrixes layers);
private void source_Disposing(GridPointMatrixesDisposingEventArgs e) { source = null; }
protected internal GridPointMatrixAddRemoveEventArgs(GridPointMatrixes grids, GridPointMatrix grid) { Layers = grids; Layer = grid; }
public static void LoadMatrixLayers() { Gondwana.Common.Timers.Timers.Add("matrix_move", TimerType.PreCycle, TimerCycles.Repeating, 0.01).Tick += new Gondwana.Common.EventArgs.TimerEventHandler(Timers_Tick); matrix = new GridPointMatrix(8, 8, 64, 32); matrix.WrapHorizontally = false; matrix.WrapVertically = false; matrix.CoordinateSystem = new SquareIsoCoordinates(); layers = new GridPointMatrixes(matrix); matrix2 = new GridPointMatrix(12, 12, 64, 32); matrix2.CoordinateSystem = new SquareIsoCoordinates(); matrix2.BindScrollingToParentGrid(matrix); layers.AddLayer(matrix2).LayerSyncModifier = (float)0.25; //matrix3 = new GridPointMatrix(12, 12, 64, 32); //layers.AddLayer(matrix3).LayerSyncModifier = (float)0.5; //matrix3.CoordinateSystem = new SquareIsoCoordinates(); //matrix3.BindScrollingToParentGrid(matrix); /* foreach (GridPoint gridPt in matrix) { if (gridPt.GridCoordinates.X < 2 && gridPt.GridCoordinates.Y < 2) { gridPt.EnableFog = false; gridPt.CurrentFrame = new Frame(tilesheet, 2, 7); } } */ //matrix[5, 5].CurrentFrame = new Frame(tilesheet, 2, 7); foreach (GridPoint gridPt in matrix) gridPt.CurrentFrame = new Frame(tilesheet, 0, 0); int i = 0; foreach (GridPoint gridPt in matrix2) { switch (i++ % 3) { case 0: gridPt.CurrentFrame = new Frame(tilesheet, 1, 6); break; case 1: gridPt.CurrentFrame = new Frame(tilesheet, 1, 7); break; case 2: gridPt.CurrentFrame = new Frame(tilesheet, 1, 8); break; default: break; } } }