Beispiel #1
0
        /// <summary>Renders any sprites stored in the sprites array, and the GameItem stored in gameItem, if present, and the item selection, if applicable.</summary>
        private void RenderMiscSprites(Blitter b)
        {
            ////if (gameItem != null)
            ////    gameItem.Draw(b);


            for (int i = 0; i < this._sprites.Count; i++)
            {
                SpriteListItem item = _sprites[i];
                item.SpriteDefinition.Draw(b, item.Location.X, item.Location.Y, (byte)item.PaletteIndex);
            }

            if (selectedItem != null)
            {
                Rectangle selection = selectedItem.GetCollisionRect(); //new Rectangle(selectedItem.ScreenLocation.X * 16, selectedItem.ScreenLocation.Y * 16, 16,16);
                b.DrawRect(selection, NesPalette.HighlightEntry);
            }
        }
            public override void DoWork()
            {
                ColorPalette bitmapPalette = dest.Palette;
                NesPalette   bgPalette     = display._Level.BgPalette;
                NesPalette   spritePalette = display._Level.SpritePalette;

                // Todo: alt pal support
                //if (display..UseAltPalette && (display._Level.LevelIdentifier == LevelIndex.Brinstar || LevelData.LevelIdentifier == LevelIndex.Norfair))
                //    bgPalette = display._Level.BgAltPalette;

                // Load palettes twice
                bgPalette.ApplyTable(bitmapPalette.Entries);
                bgPalette.ApplyTable(bitmapPalette.Entries, 16);
                spritePalette.ApplyTable(bitmapPalette.Entries, 32);
                spritePalette.ApplyTable(bitmapPalette.Entries, 48);
                // Invert second paletteIndex for selections
                ApplyHighlightFilter(bitmapPalette);
                dest.Palette = bitmapPalette;

                bitmapPalette.Entries[NesPalette.HighlightEntry] = SystemColors.Highlight;


                b.Begin(display.Level.Patterns.PatternImage, dest);

                if (showPhysics)
                {
                    display.RenderPhysics(b);
                    display.RederEnemies(b, sprites);
                }
                else
                {
                    for (int x = 0; x < 32; x++)
                    {
                        for (int y = 0; y < 30; y++)
                        {
                            int tile = display.tiles[x, y];
                            b.BlitTile(tile, x, y, display.colors[x, y]);
                        }
                    }


                    display.RederEnemies(b, sprites);
                    if (doors != null)
                    {
                        foreach (DoorInstance d in doors)
                        {
                            byte pal = 9;
                            if (d.Type == DoorType.Missile)
                            {
                                pal = 8;
                            }
                            else if (d.Type == DoorType.TenMissile)
                            {
                                pal = 10;
                            }

                            if (d.Side == DoorSide.Left)
                            {
                                Graphic.SpriteDefinition.LeftDoor.Draw(b, 2, 0xA, pal);
                            }
                            else
                            {
                                Graphic.SpriteDefinition.RightDoor.Draw(b, 0x1D, 0xA, pal);
                            }
                        }
                    }
                }

                if (!showPhysics)
                {
                    ////if (display.gameItem != null)
                    ////    display.gameItem.Draw(b);


                    for (int i = 0; i < display._sprites.Count; i++)
                    {
                        SpriteListItem item = display._sprites[i];
                        item.SpriteDefinition.Draw(b, item.Location.X, item.Location.Y, (byte)(item.PaletteIndex));
                    }
                }

                b.End();
            }