Exemplo n.º 1
0
 public void Draw(GameTime gameTime, GraphicsData GraphicsData)
 {
     GraphicsData.SpriteBatch.Begin();
     DrawMap(GraphicsData);
     DrawGrid(GraphicsData);
     GraphicsData.SpriteBatch.End();
 }
Exemplo n.º 2
0
        public void DrawMap(GraphicsData GraphicsData)
        {
            for (int x = 0; x < map.Size.X; x++)
            {
                for (int y = 0; y < map.Size.Y; y++)
                {
                    switch (map.Cells[x, y])
                    {
                    case MapCell.Player:
                        DrawMapObjectCell(GraphicsData, Color.Green, x, y);
                        break;

                    case MapCell.Block:
                        DrawMapObjectCell(GraphicsData, Color.Gray, x, y);
                        break;

                    case MapCell.LiveBlock:
                        DrawMapObjectCell(GraphicsData, Color.GreenYellow, x, y);
                        break;

                    case MapCell.LootBox:
                        DrawMapObjectCell(GraphicsData, Color.White, x, y);
                        break;
                    }
                }
            }
        }
Exemplo n.º 3
0
        //========= CONSTRUCTORS =========
        #region Constructors

        /**<summary>Loads the terrain resources.</summary>*/
        static Terrain()
        {
            GraphicsData graphicsData = GraphicsData.FromBuffer(Resources.Terrain);

            LandTiles = new PaletteImage[5];
            graphicsData.paletteImages.CopyTo(LandTiles);
        }
Exemplo n.º 4
0
        //========= CONSTRUCTORS =========
        #region Constructors

        /**<summary>Loads the water resources.</summary>*/
        static Water()
        {
            GraphicsData graphicsData = GraphicsData.FromBuffer(Resources.Water);

            WaterSprites = new PaletteImage[5];
            graphicsData.CopyTo(WaterSprites);
        }
Exemplo n.º 5
0
        public Game1(string pathForDownloadMap, string outPutPath, int lootBoxCount)
        {
            PathForDownloadMap = pathForDownloadMap;
            OutputPath         = outPutPath;
            LootBoxCount       = lootBoxCount;

            GraphicsData = new GraphicsData {
                Graphics = new GraphicsDeviceManager(this)
            };
        }
Exemplo n.º 6
0
        //=========== LOADING ============
        #region Loading

        /**<summary>Returns a palette loaded from the specified stream.</summary>*/
        public static Palette FromStream(Stream stream)
        {
            BinaryReader   reader         = new BinaryReader(stream);
            ImageDirectory imageDirectory = new ImageDirectory();
            GraphicsData   graphicsData   = new GraphicsData(imageDirectory);

            imageDirectory.Read(reader);
            graphicsData.Read(reader);
            return(graphicsData.GetPalette(0));
        }
Exemplo n.º 7
0
    void DrawLocations(GraphicsData gd)
    {
        Pos pos = gd._pos;

        if (!_locations.ContainsKey(pos))
        {
            GameObject newGo = InstantiateGo(_prefabLocation, pos, gd._location.GetColor());
            _locations[pos] = newGo;
        }
        SetColor(_locations[pos], gd._location.GetColor());
    }
Exemplo n.º 8
0
        public void Draw(GameTime gameTime, GraphicsData graphicsData)
        {
            var coordinate = new Point(
                (graphicsData.Graphics.GraphicsDevice.Viewport.Width - menu.Size.X) / 2,
                (graphicsData.Graphics.GraphicsDevice.Viewport.Height - menu.Size.Y) / 2);

            graphicsData.SpriteBatch.Begin();

            menu.Draw(coordinate, graphicsData);
            graphicsData.SpriteBatch.End();
        }
Exemplo n.º 9
0
 public StaticData(
     GameData gameData,
     GraphicsData graphicsData,
     UIData uiData,
     DataDefaults defaults)
 {
     this.gameData     = gameData;
     this.graphicsData = graphicsData;
     this.uiData       = uiData;
     this.defaults     = defaults;
 }
Exemplo n.º 10
0
        private void DrawGrid(GraphicsData GraphicsData)
        {
            var gridColor = Color.Red;

            cellSize = new Vector2(GraphicsData.Graphics.GraphicsDevice.Viewport.Width / map.Size.X, GraphicsData.Graphics.GraphicsDevice.Viewport.Height / map.Size.Y);  // потом менять только при изменении ока и при инициализации
            for (int h = 0; h <= GraphicsData.Graphics.GraphicsDevice.Viewport.Height; h += (int)cellSize.Y)
            {
                GraphicsData.SpriteBatch.DrawPixel(new Vector2(0, h), new Vector2(GraphicsData.Graphics.GraphicsDevice.Viewport.Width, pixelWidth), gridColor);
            }
            for (int w = 0; w <= GraphicsData.Graphics.GraphicsDevice.Viewport.Width; w += (int)cellSize.X)
            {
                GraphicsData.SpriteBatch.DrawPixel(new Vector2(w, 0), new Vector2(pixelWidth, GraphicsData.Graphics.GraphicsDevice.Viewport.Height), gridColor);
            }
        }
Exemplo n.º 11
0
        public void Draw(Point coordinate, GraphicsData GraphicsData)
        {
            Coordinate = coordinate;
            if (Buttons.Count == 0)
            {
                return;
            }
            int y = coordinate.Y;

            for (int i = 0; i < Buttons.Count; i++)
            {
                Buttons[i].Draw(new Point(((int)coordinate.X + (Size.X - Buttons[i].BoundSize.X) / 4), y), GraphicsData);
                y += Buttons[i].BoundSize.Y;
                y += distanceBetweenButtons;
            }
        }
Exemplo n.º 12
0
        //=========== READING ============
        #region Reading

        /**<summary>Saves the palette image to the specified file path.</summary>*/
        public void Save(string path)
        {
            BinaryWriter   writer         = new BinaryWriter(new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write));
            ImageDirectory imageDirectory = new ImageDirectory();
            GraphicsData   graphicsData   = new GraphicsData(imageDirectory);

            graphicsData.Add(this);

            long imageDirectoryPosition = writer.BaseStream.Position;

            imageDirectory.Write(writer);
            graphicsData.Write(writer);
            writer.BaseStream.Position = imageDirectoryPosition;
            imageDirectory.Write(writer);

            writer.Close();
        }
Exemplo n.º 13
0
        //============ SAVING ============
        #region Saving

        /**<summary>Saves the palette to the specified stream.</summary>*/
        public void Save(Stream stream)
        {
            BinaryWriter   writer         = new BinaryWriter(stream);
            ImageDirectory imageDirectory = new ImageDirectory();
            GraphicsData   graphicsData   = new GraphicsData(imageDirectory);

            graphicsData.Add(this);

            long imageDirectoryPosition = writer.BaseStream.Position;

            imageDirectory.Write(writer);
            graphicsData.Write(writer);

            long endPosition = stream.Position;

            writer.BaseStream.Position = imageDirectoryPosition;
            imageDirectory.Write(writer);

            stream.Position = endPosition;
        }
Exemplo n.º 14
0
        //========= CONSTRUCTORS =========
        #region Constructors

        /**<summary>Loads the color remapping resources.</summary>*/
        static ColorRemapping()
        {
            GraphicsData graphicsData = GraphicsData.FromBytes(Resources.RemapStrips);

            for (int i = 0; i < 32; i++)
            {
                RemapPalette remaps = new RemapPalette(12);
                for (int j = 0; j < 12; j++)
                {
                    remaps.remapIndexes[j] = graphicsData.paletteImages[4915 + i - 4915].Pixels[243 + j, 0];
                }
                RemapPalettes[i] = remaps;
            }
            for (int i = 0; i < 32; i++)
            {
                RemapPalette remaps = new RemapPalette(256);
                for (int j = 0; j < 256; j++)
                {
                    remaps.remapIndexes[j] = graphicsData.paletteImages[5016 + i - 4915].Pixels[j, 0];
                }
                GlassPalettes[i] = remaps;
            }
            for (int i = 0; i < 5; i++)
            {
                RemapPalette remaps = new RemapPalette(256);
                for (int j = 0; j < 256; j++)
                {
                    remaps.remapIndexes[j] = graphicsData.paletteImages[4947 - 4915].Pixels[j, i];
                }
                WaterPalettes[i] = remaps;
            }
            for (int i = 0; i < 4; i++)
            {
                RemapPalette remaps = new RemapPalette(256);
                for (int j = 0; j < 256; j++)
                {
                    remaps.remapIndexes[j] = graphicsData.paletteImages[4951 + i - 4915].Pixels[j, 0];
                }
                DarknessPalettes[i] = remaps;
            }
        }
Exemplo n.º 15
0
    void DrawResources(GraphicsData gd)
    {
        Pos pos = gd._pos;

        if (gd._resource != null)
        {
            if (!_resources.ContainsKey(pos))
            {
                GameObject newGo = InstantiateGo(_prefabResource, pos, gd._resource.GetColor());
                _resources[pos] = newGo;
            }
            SetColor(_resources[pos], gd._resource.GetColor());
        }
        else
        {
            if (_resources.ContainsKey(pos))
            {
                Destroy(_resources[pos]);
                _resources.Remove(pos);
            }
        }
    }
Exemplo n.º 16
0
    public virtual GraphicsData Draw()
    {
        LocationGraphicsData  lgd = _viewer.Draw(this, _stats);
        StructureGraphicsData sgd = null;
        ResourceGraphicsData  rgd = null;

        Player currentPlayer = _game._playerSystem._currentPlayer;

        if (currentPlayer != null)
        {
            bool visibleToPlayer       = _stats._vision._visibility[currentPlayer] == eVisibility.Visible;
            bool visibleBecauseGodMode = _game._viewer._viewType == eView.God;

            if (visibleToPlayer || visibleBecauseGodMode)
            {
                if (_structure != null)
                {
                    sgd = _structure.Draw();
                }
                if (_stats._build._buildingsQueued[currentPlayer] != null)
                {
                    sgd = new StructureGraphicsData(Color.black);
                }
                if (_resource != null)
                {
                    rgd = _resource.Draw();
                }
            }

            GraphicsData gd = new GraphicsData(_pos, lgd, sgd, rgd);

            return(gd);
        }
        else
        {
            return(null);
        }
    }
Exemplo n.º 17
0
        static void OffsetUD_ValueChanged(object sender, EventArgs e)
        {
            if (imageForm.CompressedGraphics)
            {
                if (ROM.CanBeLZ77Decompressed(imageForm.Offset, MaxCompGraphicsSize, 0x1))
                {
                    int offset = imageForm.Offset;
                    int index = datas.IndexOf(x => x.Offset == offset);
                    if (index >= 0)
                    {
                        imageForm.ImageIndex = index;
                        UpdateDisplayedOffsets();
                    }
                    else
                    {
                        GraphicsData data = new GraphicsData();

                        data.Offset = imageForm.Offset;
                        data.PaletteOffset = 0;
                        data.Compressed = true;
                        data.PaletteCompressed = false;
                        datas.Add(data);

                        UpdateRanges();
                    }
                }
            }
        }
Exemplo n.º 18
0
 public void DrawLayer(GameTime time, GraphicsData GraphicsData)
 {
     CurrentLayer.Draw(time, GraphicsData);
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sizeMultible"></param>
 public void Scan(int sizeMultible)
 {
     int[] results = ROM.ScanForMalias2CompressedData(0, ROM.Length, 0x8000, 4, sizeMultible);
     foreach (var item in results)
     {
         var data = new GraphicsData();
         data.Offset = item;
         data.Compressed = true;
         data.PaletteOffset = 0;
         data.PaletteCompressed = false;
         datas.Add(data);
     }
     numericUpDown1.Maximum = datas.Count;
 }
Exemplo n.º 20
0
        public static Window ShowWindow()
        {
            var window = new Window("show", kWidth, kHeight)
            {
                Description = "Шеф-повар \"Сибовар\""
            };

            var line = new TableLine(25);

            line.AddColumn(80);
            line.AddColumn(80);
            line.AddColumn(70);

            line.Text[0].Text = "HgjloGreen";
            line.Text[0].SetFont(Palette.Lime, 20);
            line.Text[0].SetAlign(Align.Left, new GfxPoint(0, 3));
            line.Text[1].Text = "HelloRed";
            line.Text[1].SetFont(Palette.Red, 15);
            line.Text[1].SetAlign(Align.Center);
            line.Text[2].Text = "HgelloBlue";
            line.Text[2].SetFont(Palette.PaleTurquoise, 30);
            line.Text[2].SetAlign(Align.Left, new GfxPoint(0, 4));

            line.Name = "line";


            var table = new Table(window)
            {
                Name = "table"
            };

            table.Move(10, 50);
            table.AddLine(new TableLine(line));
            table.AddLine(new TableLine(line));
            table.AddLine(new TableLine(line));
            table.SetBackground(Palette.Red, Palette.White);
            table.SetBorder(1, Palette.Lime);
            table.OnPress += caller =>
            {
                var rv = table.GetLineByCell(caller);
                if (rv == null)
                {
                    return;
                }

                table.ActiveLine   = rv;
                window.Description = rv.Name;
            };


            var text = new TextArea(window, 10, 180, 325, 50);

            text.SetFont("i260c", Palette.PaleTurquoise, 50);
            text.Text = "0123456789:";

            text.OnPress += caller => window.Description = "Text.Pressed";

            var bar = new ProgressBar(window, 40, 30, 200, 15, 15)
            {
                Percent = 10, Status = { Text = "hello" }
            };

            bar.Status.SetAlign(Align.Center, new GfxPoint(3, 3));
            bar.Status.SetFont(Palette.White, 14);
            bar.Rotate(70);

            text.OnRelease += caller =>
            {
                window.Description = "Text.Released";
                //mApplication.SetFocusedWindow("1");
                line.Move(line.X - 3, line.Y - 3);
                table.ActiveLine = null;
                bar.Percent     -= 1;
            };

            window.OnPaint += delegate { Debug.Print(DateTime.Now.ToString("HH:mm:ss") + ":\tHome update"); };

            var activePath = VG.vgCreatePath(0, VGPathDatatype.VG_PATH_DATATYPE_S_16, 1, 0, 0, 0, VGPathCapabilities.VG_PATH_CAPABILITY_ALL);

            VGU.vguRoundRect(activePath, 0, 0, 60, 100, 20, 20);

            var normalPath = VG.vgCreatePath(0, VGPathDatatype.VG_PATH_DATATYPE_S_16, 1, 0, 0, 0, VGPathCapabilities.VG_PATH_CAPABILITY_ALL);

            VGU.vguRoundRect(normalPath, 0, 0, 100, 50, 20, 20);
            VGU.vguRoundRect(normalPath, 10, 50, 80, 70, 20, 20);



            var activeButton = new VGSolidColor(new Color(0xFF0000FF));
            //var normalButton = new VGSolidColor(new Color(0x00FF00FF));
            var normalButton = new VGLinearGradient(0, 0, 100, 120);

            normalButton.AddColor(0, new Color(0xFF0000FF));
            normalButton.AddColor(100, new Color(0x00FF00FF));

            var button = new Button(window, new VGPath(activePath, null, activeButton), new VGPath(normalPath, null, normalButton));

            button.IsCached = true;
            button.Move(250, 50);
            button.OnPress += delegate { Console.WriteLine("button.OnPress"); };


            var image = new Image(window, 25, 10);

            image.Load("splash.raw");
            image.Scale(0.5f, 0.5f);
            image.RotateCenter = new GfxPoint(image.Width / 2, image.Height / 2);
            //image.Hide();

            window.OnPaint += caller =>
            {
                image.Rotate(mImageRotate);
                mImageRotate += 5;
            };

            var graphicArea = new GraphicArea(window, 200, 200);

            graphicArea.Move(70, 20);
            graphicArea.Background = new Color(0xF0F0F0FF);


            graphicArea.Grid   = new VGPath(activePath, activeButton, null);
            graphicArea.Arrows = new VGPath(normalPath, new VGSolidColor(Palette.PaleTurquoise), null);

            var graphicData1 = new GraphicsData
            {
                Data =
                    new byte[]
                {
                    0, 15, 25, 50, 40, 35, 12, 10, 15, 17, 30, 32, 35, 35, 35, 35, 35, 40,
                    45, 57, 25, 23, 20, 18, 12, 12, 12, 30, 32, 35, 35, 35, 35, 35, 40, 45
                }
            };

            var graphicData2 = new GraphicsData(graphicData1)
            {
                Color = Palette.Lime, Position = new GfxPoint(10, 10)
            };

            graphicArea.AddGrapic(graphicData1);
            graphicArea.AddGrapic(graphicData2);

            return(window);
        }
Exemplo n.º 21
0
 public GameData(GraphicsData graphicsData)
 {
     GraphicsData = graphicsData;
 }
Exemplo n.º 22
0
 public void Draw(Point position, GraphicsData GraphicsData)
 {
     Bound = new Rectangle(position, BoundSize);
     GraphicsData.SpriteBatch.DrawRectangle(position.ToVector2(), BoundSize.ToVector2(), BoundColor);
     GraphicsData.SpriteBatch.DrawString(MessageFont, MessageText, position.ToVector2() + new Vector2(Padding), TextColor);
 }
Exemplo n.º 23
0
 private void DrawMapObjectCell(GraphicsData GraphicsData, Color color, int x, int y)
 {
     GraphicsData.SpriteBatch.DrawPixel(new Vector2(x * cellSize.X + 3, y * cellSize.Y + 3), new Vector2(cellSize.X - 4, cellSize.Y - 4), color);
 }
Exemplo n.º 24
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sizeMultible"></param>
        public static void Scan(int sizeMultible)
        {
            datas.Clear();
            int[] results = ROM.ScanForLZ77CompressedData(0, ROM.Length, 0x8000, 4, sizeMultible);
            foreach (var item in results)
            {
                var data = new GraphicsData();
                data.Offset = item;
                data.Compressed = true;
                data.PaletteOffset = 0;
                data.PaletteCompressed = false;
                datas.Add(data);
            }

            UpdateRanges();
            if (datas.Count > 0)
                imageForm.ImageIndex = 0;
        }
Exemplo n.º 25
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="path"></param>
        public static void LoadNLZFile(string path)
        {
            datas.Clear();
            using (BinaryReader br = new BinaryReader(File.OpenRead(path)))
            {
                int capacity = (int)(br.BaseStream.Length / 8);
                for (int i = 0; i < capacity; i++) // br.BaseStream.Position > br.BaseStream.Length)
                {
                    int graphicsOffset = br.ReadInt32();
                    int paletteOffset = br.ReadInt32();
                    GraphicsData data = new GraphicsData();

                    data.Offset = Math.Abs(graphicsOffset);
                    data.PaletteOffset = Math.Abs(paletteOffset);
                    data.Compressed = graphicsOffset < 0;
                    data.PaletteCompressed = paletteOffset < 0;
                    datas.Add(data);
                }
            }

            UpdateRanges();
        }