Esempio n. 1
0
        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;
        }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
 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;
 }
Esempio n. 4
0
        public void ForceRefresh()
        {
            GridPointMatrixes matrixes = _surface.Buffer.DrawSource;

            if (matrixes != null && matrixes.Count != 0)
            {
                matrixes[0].RefreshQueue.AddPixelRangeToRefreshQueue(_bounds, true);
            }

            _dirty = true;
        }
Esempio n. 5
0
 /// <summary>
 /// Clear all EngineState collection properties associated with the Engine class
 /// </summary>
 public void Clear()
 {
     ValueBag.Clear();
     EngineResourceFile.ClearAll();
     Tilesheet.ClearAllTilesheets();
     Cycle.ClearAllAnimationCycles();
     GridPointMatrixes.ClearAllGridPointMatrixes();
     GridPointMatrix.ClearAllGridPointMatrix();
     Gondwana.Common.Drawing.Sprites.Sprites.Clear();
     MediaFile.DisposeAll();
 }
Esempio n. 6
0
        public override void Bind(GridPointMatrixes layers)
        {
            GridPointMatrixes oldBind = Buffer.DrawSource;

            ((Backbuffer)Buffer).DrawSource = layers;

            if (VisibleSurfaceBind != null)
            {
                VisibleSurfaceBind(new VisibleSufaceBindEventArgs(this, oldBind, layers));
            }
        }
Esempio n. 7
0
        public DirectDrawing(VisibleSurfaceBase surface, Rectangle bounds)
        {
            _instances.Add(this);

            _surface = surface;
            _bounds  = bounds;
            _zOrder  = 0;
            _Name    = Guid.NewGuid().ToString();

            _drawSource = _surface.Buffer.DrawSource;

            ForceRefresh();
        }
Esempio n. 8
0
        private static void ClearRefreshQueues()
        {
            // step through all GridPointMatrixes objects
            foreach (GridPointMatrixes grids in GridPointMatrixes.GetAllGridPointMatrixes())
            {
                // clear each queue, mark as no refresh needed
                foreach (GridPointMatrix matrix in grids)
                {
                    matrix.RefreshQueue.ClearRefreshQueue();
                }

                grids.RefreshNeeded = MatrixesRefreshType.None;
            }
        }
Esempio n. 9
0
 private void source_Disposing(GridPointMatrixesDisposingEventArgs e)
 {
     source = null;
 }
Esempio n. 10
0
 protected internal GridPointMatrixesDisposingEventArgs(GridPointMatrixes matrixLayers)
 {
     Matrixes = matrixLayers;
 }
Esempio n. 11
0
        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;
                }
            }
        }
Esempio n. 12
0
 abstract public void Bind(GridPointMatrixes layers);
 public VisibleSufaceBindEventArgs(VisibleSurfaceBase surface, GridPointMatrixes oldBind, GridPointMatrixes newBind)
 {
     Surface      = surface;
     OldBindValue = oldBind;
     NewBindValue = newBind;
 }
 protected internal GridPointMatrixAddRemoveEventArgs(GridPointMatrixes grids, GridPointMatrix grid)
 {
     Layers = grids;
     Layer  = grid;
 }
Esempio n. 15
0
        private static void DrawRefreshQueues()
        {
            foreach (VisibleSurfaceBase surface in VisibleSurfaces.AllVisibleSurfaces)
            {
                IBackbuffer       backbuffer = surface.Buffer;
                GridPointMatrixes grids      = backbuffer.DrawSource;

                if (grids == null || grids.Count == 0)
                {
                    // clear the entire backbuffer each pass
                    backbuffer.Erase();

                    // force refresh of all DirectDrawing objects
                    foreach (DirectDrawing drawing in DirectDrawing.AllDirectDrawings)
                    {
                        drawing.ForceRefresh();
                    }
                }
                else
                {
                    switch (grids.RefreshNeeded)
                    {
                    case MatrixesRefreshType.None:
                        // do nothing
                        return;

                    case MatrixesRefreshType.Queue:
                        // erase any DirectDrawing that intersects with a refresh area
                        foreach (DirectDrawing direct in DirectDrawing.AllDirectDrawings)
                        {
                            if (grids.BackmostVisibleLayer.RefreshQueue.AreaIntersectsRefreshArea(direct.Bounds))
                            {
                                direct.ForceRefresh();
                            }
                        }

                        // erase the existing areas in queue
                        backbuffer.Erase(grids.BackmostVisibleLayer.RefreshQueue.GetDirtyRectangles());

                        // draw from back to front from visible layers array
                        for (int i = grids.CountOfVisibleLayers - 1; i >= 0; i--)
                        {
                            surface.Buffer.DrawTiles(grids.VisibleGridPointMatrixList[i].RefreshQueue.Tiles);
                        }

                        break;

                    case MatrixesRefreshType.All:
                        // erase the entire backbuffer
                        backbuffer.Erase();

                        // force refresh of all DirectDrawing objects
                        foreach (DirectDrawing drawing in DirectDrawing.AllDirectDrawings)
                        {
                            drawing.ForceRefresh();
                        }

                        // draw from back to front from visible layers array
                        for (int i = grids.CountOfVisibleLayers - 1; i >= 0; i--)
                        {
                            // refreshing entire back buffer, so clear any partial queue...
                            grids.VisibleGridPointMatrixList[i].RefreshQueue.ClearRefreshQueue();

                            // find and add all Tile objects in range to queue
                            grids.VisibleGridPointMatrixList[i].RefreshQueue.AddPixelRangeToRefreshQueue(
                                new Rectangle(0, 0, surface.Width, surface.Height), false);

                            // draw to backbuffer
                            surface.Buffer.DrawTiles(grids.VisibleGridPointMatrixList[i].RefreshQueue.Tiles);
                        }

                        break;

                    default:
                        // shouldn't get here
                        continue;
                    }
                }

                // draw all DirectDrawing objects that overlap with dirty rectangles and are "dirty"
                DirectDrawing.RenderAll();
            }
        }