Пример #1
0
        public void Render(IGraphicProvider gfx)
        {
            if (bgRendered == false)
            {
                Bitmap b = GenerateEmptyBackground(Color.White);
                gfx.DrawImage(b, 0, 0);
                bgRendered = true;
            }

            for (int i = 0; i < m_Rows; i++)
            {
                List <Corner> row = m_CornerRows[i];
                foreach (Corner c in row)
                {
                    c.Render(gfx);
                }
            }

            foreach (IMove m in m_Moves)
            {
                m.Render(gfx);
            }

            foreach (Box b in m_Boxes)
            {
                b.Render(gfx);
            }

            gfx.Invalidate();
        }
Пример #2
0
        public void Render(IGraphicProvider gfx)
        {
            Point start = (m_Line.Start as Corner).GraphicsPoint;
            Point end   = (m_Line.End as Corner).GraphicsPoint;

            gfx.DrawLine(start, end, m_Player.Color);
        }
Пример #3
0
        public void Render(IGraphicProvider gfx)
        {
            Point start = (m_Line.Start as Corner).GraphicsPoint;
            Point end = (m_Line.End as Corner).GraphicsPoint;

            gfx.DrawLine(start, end, m_Player.Color);
        }
Пример #4
0
        public void Render(IGraphicProvider gfx)
        {
            Xamarin.Forms.Point     ul     = m_Mapper.GetGraphicsPoint(m_Top.Start);
            Xamarin.Forms.Point     lr     = m_Mapper.GetGraphicsPoint(m_Right.End);
            Xamarin.Forms.Rectangle bounds = new Xamarin.Forms.Rectangle(ul, new Xamarin.Forms.Size(lr.X - ul.X, lr.Y - ul.Y));

            //gfx.DrawString(ul, new Font(FontFamily.GenericSansSerif, 10), m_Player.Color, m_Player.Initials);
        }
 public DynamicCacheGraphicProvider(IGraphicProvider provider)
 {
     if (provider == null)
     {
         throw new ArgumentNullException("provider");
     }
     this._provider = provider;
 }
 public void Dispose()
 {
     if (this._provider == null)
     {
         return;
     }
     this._provider.Dispose();
     this._provider = (IGraphicProvider)null;
 }
Пример #7
0
        void AddCursors(IGraphicProvider graphicProvider)
        {
            var cursorGraphics = graphicProvider.GetGraphics(GraphicType.Cursor);

            for (int i = 0; i < cursorGraphics.Count; ++i)
            {
                AddTexture(Layer.Cursor, (uint)i, cursorGraphics[i]);
            }
        }
Пример #8
0
        public void Render(IGraphicProvider gfx)
        {
            Point ul = m_Mapper.GetGraphicsPoint(m_Top.Start);
            Point lr = m_Mapper.GetGraphicsPoint(m_Right.End);

            Rectangle bounds = new Rectangle(ul, new Size(lr.X - ul.X, lr.Y - ul.Y));

            gfx.DrawString(ul, new Font(FontFamily.GenericSansSerif, 10), m_Player.Color, m_Player.Initials);
        }
Пример #9
0
        public static KeyValuePair <TextureAtlasManager, Action> CreateUIOnly(IGraphicProvider graphicProvider, IFontProvider fontProvider)
        {
            var textureAtlasManager = new TextureAtlasManager();

            return(KeyValuePair.Create <TextureAtlasManager, Action>(textureAtlasManager, () =>
            {
                textureAtlasManager.AddUI(graphicProvider, false);
                textureAtlasManager.AddCursors(graphicProvider);
                textureAtlasManager.AddFont(fontProvider);
            }));
        }
Пример #10
0
        public Texture CreatePalette(IGraphicProvider graphicProvider)
        {
            var  paletteBuilder = factory.Create();
            uint index          = 0;

            foreach (var palette in graphicProvider.Palettes)
            {
                paletteBuilder.AddTexture(index++, palette.Value);
            }

            return(paletteBuilder.CreateUnpacked(32, 4).Texture);
        }
Пример #11
0
 public ShadedGraphicProvider(ShaderData shaderData, IGraphicProvider provider)
 {
     if (shaderData == null)
     {
         throw new ArgumentNullException("shaderData");
     }
     if (provider == null)
     {
         throw new ArgumentNullException("provider");
     }
     this._shaderData = shaderData;
     this._provider   = provider;
 }
Пример #12
0
        public void Start(IGraphicProvider gfx)
        {
            m_GameBoard.Render(gfx);

            int playerMovesRemaining = m_MovesPerTurn;

            while (m_GameBoard.MovesRemaining > 0)
            {
                IMove move = null;
                while (true)
                {
                    gfx.ShowUserTurn(CurrentPlayer);
                    move = CurrentPlayer.GetNextMove(m_GameBoard);
                    if (m_GameBoard.IsAvailableMove(move))
                    {
                        break;
                    }
                }

                MoveScore s = m_GameBoard.MakeMove(move, CurrentPlayer);
                playerMovesRemaining--;

                if (FreeMoveOnScore)
                {
                    if (s == MoveScore.One || s == MoveScore.Two)
                    {
                        playerMovesRemaining += m_RewardLines;
                    }
                }

                m_GameBoard.Render(gfx);

                if (playerMovesRemaining == 0)
                {
                    NextPlayer();
                    playerMovesRemaining = m_MovesPerTurn;
                }
            }

            StringBuilder sb = new StringBuilder();

            foreach (Player p in m_Players)
            {
                sb.AppendFormat("{0}: {1}\n", p.DisplayName, p.Score);
            }

            System.Windows.Forms.MessageBox.Show(sb.ToString());
        }
Пример #13
0
        public void Start(IGraphicProvider gfx)
        {
            m_GameBoard.Render(gfx);

            int playerMovesRemaining = m_MovesPerTurn;
            while (m_GameBoard.MovesRemaining > 0)
            {
                IMove move = null;
                while (true)
                {
                    gfx.ShowUserTurn(CurrentPlayer);
                    move = CurrentPlayer.GetNextMove(m_GameBoard);
                    if (m_GameBoard.IsAvailableMove(move))
                    {
                        break;
                    }
                }

                MoveScore s = m_GameBoard.MakeMove(move, CurrentPlayer);
                playerMovesRemaining--;

                if (FreeMoveOnScore)
                {
                    if (s == MoveScore.One || s == MoveScore.Two)
                    {
                        playerMovesRemaining += m_RewardLines;
                    }
                }

                m_GameBoard.Render(gfx);

                if (playerMovesRemaining == 0)
                {
                    NextPlayer();
                    playerMovesRemaining = m_MovesPerTurn;
                }
            }

            StringBuilder sb = new StringBuilder();
            foreach (Player p in m_Players)
            {
                sb.AppendFormat("{0}: {1}\n", p.DisplayName, p.Score);
            }

            System.Windows.Forms.MessageBox.Show(sb.ToString());
        }
Пример #14
0
        void AddUI(IGraphicProvider graphicProvider, bool withLayout = true)
        {
            if (withLayout)
            {
                var layoutGraphics = graphicProvider.GetGraphics(GraphicType.Layout);

                for (int i = 0; i < layoutGraphics.Count; ++i)
                {
                    AddTexture(Layer.UI, Graphics.LayoutOffset + (uint)i, layoutGraphics[i]);
                }
            }

            var uiElementGraphics = graphicProvider.GetGraphics(GraphicType.UIElements);

            for (int i = 0; i < uiElementGraphics.Count; ++i)
            {
                AddTexture(Layer.UI, Graphics.UICustomGraphicOffset + (uint)i, uiElementGraphics[i]);
            }
        }
Пример #15
0
        public CharacterManager(IGameData gameData, IGraphicProvider graphicProvider)
        {
            var npcReader          = new NPCReader();
            var monsterReader      = new MonsterReader(gameData, graphicProvider);
            var monsterGroupReader = new MonsterGroupReader();

            foreach (var npcFile in gameData.Files["NPC_char.amb"].Files)
            {
                npcs.Add((uint)npcFile.Key, NPC.Load((uint)npcFile.Key, npcReader, npcFile.Value, gameData.Files["NPC_texts.amb"].Files[npcFile.Key]));
            }
            foreach (var monsterFile in gameData.Files["Monster_char_data.amb"].Files)
            {
                monsters.Add((uint)monsterFile.Key, Monster.Load((uint)monsterFile.Key, monsterReader, monsterFile.Value));
            }
            foreach (var monsterGroupFile in gameData.Files["Monster_groups.amb"].Files) // load after monsters!
            {
                monsterGroups.Add((uint)monsterGroupFile.Key, MonsterGroup.Load(this, monsterGroupReader, monsterGroupFile.Value));
            }
        }
Пример #16
0
        public IEnumerable <SkyPart> GetSkyParts(Map map, uint hour, uint minute,
                                                 IGraphicProvider graphicProvider, out PaletteReplacement paletteReplacement)
        {
            if (!map.Flags.HasFlag(MapFlags.Outdoor))
            {
                paletteReplacement = null;
                return(null);
            }

            var worldIndex = (int)map.World;

            // 9-18: Day
            // 18-22: Transition to night
            // 22-5: Night
            // 5-9: Transition to day
            Graphic baseGraphic  = null;
            Graphic blendGraphic = null;
            Graphic basePalette  = null;
            Graphic blendPalette = null;
            uint    destFactor   = 0;
            uint    stage        = 0;

            IEnumerable <SkyPart> Cache(uint stage, Func <List <SkyPart> > creator)
            {
                uint key = (uint)worldIndex * 10000 + stage;

                if (skyPartCache.TryGetValue(key, out var parts))
                {
                    return(parts);
                }

                return(skyPartCache[key] = creator());
            }

            PaletteReplacement CachePaletteReplacement(uint stage, Func <PaletteReplacement> creator)
            {
                uint key = map.TilesetOrLabdataIndex * 10000 + stage;

                if (paletteReplaceCache.TryGetValue(key, out var replacement))
                {
                    return(replacement);
                }

                return(paletteReplaceCache[key] = creator());
            }

            if (hour >= 22 || hour < 5) // Night
            {
                stage       = 0;
                baseGraphic = executableData.SkyGradients[worldIndex * 3 + 0];
                basePalette = executableData.DaytimePaletteReplacements[worldIndex * 2 + 0];
            }
            else if (hour >= 9 && hour < 18) // Day
            {
                stage       = 1;
                baseGraphic = executableData.SkyGradients[worldIndex * 3 + 2];
                basePalette = graphicProvider.Palettes[(int)map.PaletteIndex];
            }
            else if (hour >= 18 && hour < 20) // Dawn phase I
            {
                stage        = 1000 + hour * 60 + minute;
                baseGraphic  = executableData.SkyGradients[worldIndex * 3 + 2];
                blendGraphic = executableData.SkyGradients[worldIndex * 3 + 1];
                basePalette  = graphicProvider.Palettes[(int)map.PaletteIndex];
                blendPalette = executableData.DaytimePaletteReplacements[worldIndex * 2 + 1];
                destFactor   = 255 * ((hour - 18) * 60 + minute) / 120;
            }
            else if (hour >= 20 && hour < 22) // Dawn phase II
            {
                stage        = 3000 + hour * 60 + minute;
                baseGraphic  = executableData.SkyGradients[worldIndex * 3 + 1];
                blendGraphic = executableData.SkyGradients[worldIndex * 3 + 0];
                basePalette  = executableData.DaytimePaletteReplacements[worldIndex * 2 + 1];
                blendPalette = executableData.DaytimePaletteReplacements[worldIndex * 2 + 0];
                destFactor   = 255 * ((hour - 20) * 60 + minute) / 120;
            }
            else if (hour >= 5 && hour < 7) // Dusk phase I
            {
                stage        = 5000 + hour * 60 + minute;
                baseGraphic  = executableData.SkyGradients[worldIndex * 3 + 0];
                blendGraphic = executableData.SkyGradients[worldIndex * 3 + 1];
                basePalette  = executableData.DaytimePaletteReplacements[worldIndex * 2 + 0];
                blendPalette = executableData.DaytimePaletteReplacements[worldIndex * 2 + 1];
                destFactor   = 255 * ((hour - 5) * 60 + minute) / 120;
            }
            else if (hour >= 7 && hour < 9) // Dusk phase II
            {
                stage        = 7000 + hour * 60 + minute;
                baseGraphic  = executableData.SkyGradients[worldIndex * 3 + 1];
                blendGraphic = executableData.SkyGradients[worldIndex * 3 + 2];
                basePalette  = executableData.DaytimePaletteReplacements[worldIndex * 2 + 1];
                blendPalette = graphicProvider.Palettes[(int)map.PaletteIndex];
                destFactor   = 255 * ((hour - 7) * 60 + minute) / 120;
            }

            var parts = Cache(stage, () =>
            {
                var parts           = new List <SkyPart>();
                uint lastColor      = uint.MaxValue;
                SkyPart currentPart = null;
Пример #17
0
 public void Render(IGraphicProvider gfx)
 {
     DrawDot(gfx, GraphicsPoint);
 }
Пример #18
0
 void DrawDot(IGraphicProvider g, Point p)
 {
     p.Offset(-1, -1);
     g.DrawRectangle(new Rectangle(p, new Size(3, 3)), m_Color);
 }
Пример #19
0
        static Character2DAnimationInfo AnimationProvider(Game game, Map map, IMapManager mapManager,
                                                          Map.CharacterReference characterReference, IGraphicProvider graphicProvider)
        {
            bool usesTileset = characterReference.CharacterFlags.HasFlag(Flags.UseTileset);

            if (usesTileset)
            {
                var tileset = mapManager.GetTilesetForMap(map);
                var tile    = tileset.Tiles[characterReference.GraphicIndex - 1];

                return(new Character2DAnimationInfo
                {
                    FrameWidth = RenderMap2D.TILE_WIDTH,
                    FrameHeight = RenderMap2D.TILE_HEIGHT,
                    StandFrameIndex = tile.GraphicIndex - 1,
                    SitFrameIndex = 0,
                    SleepFrameIndex = 0,
                    NumStandFrames = (uint)tile.NumAnimationFrames,
                    NumSitFrames = 0,
                    NumSleepFrames = 0,
                    TicksPerFrame = map.TicksPerAnimationFrame * 2,
                    NoDirections = true,
                    IgnoreTileType = true,
                    UseTopSprite = false
                });
            }
            else
            {
                var playerAnimationInfo = game.GetPlayerAnimationInfo();
                return(new Character2DAnimationInfo
                {
                    FrameWidth = 16,  // NPC width
                    FrameHeight = 32, // NPC height
                    StandFrameIndex = Graphics.GetNPCGraphicIndex(map.NPCGfxIndex, characterReference.GraphicIndex, graphicProvider),
                    SitFrameIndex = playerAnimationInfo.SitFrameIndex,
                    SleepFrameIndex = playerAnimationInfo.SleepFrameIndex,
                    NumStandFrames = NumNPCFrames[(graphicProvider.NPCGraphicOffsets.TryGetValue((int)map.NPCGfxIndex, out int offset) ? offset : 0) + characterReference.GraphicIndex],
Пример #20
0
        public RenderView(IContextProvider contextProvider, IGameData gameData, IGraphicProvider graphicProvider,
                          IFontProvider fontProvider, ITextProcessor textProcessor, Func <TextureAtlasManager> textureAtlasManagerProvider,
                          int framebufferWidth, int framebufferHeight, Size windowSize,
                          DeviceType deviceType = DeviceType.Desktop, SizingPolicy sizingPolicy = SizingPolicy.FitRatio,
                          OrientationPolicy orientationPolicy = OrientationPolicy.Support180DegreeRotation)
            : base(new State(contextProvider))
        {
            AspectProcessor        = UpdateAspect;
            GameData               = gameData;
            GraphicProvider        = graphicProvider;
            TextProcessor          = textProcessor;
            RenderArea             = new Rect(0, 0, framebufferWidth, framebufferHeight);
            renderDisplayArea      = new Rect(RenderArea);
            this.windowSize        = new Size(windowSize);
            this.sizingPolicy      = sizingPolicy;
            this.orientationPolicy = orientationPolicy;
            this.deviceType        = deviceType;
            IsLandscapeRatio       = RenderArea.Width > RenderArea.Height;

            Resize(framebufferWidth, framebufferHeight);

            context = new Context(State, renderDisplayArea.Width, renderDisplayArea.Height, 1.0f);

            // factories
            var visibleArea = new Rect(0, 0, Global.VirtualScreenWidth, Global.VirtualScreenHeight);

            spriteFactory      = new SpriteFactory(visibleArea);
            coloredRectFactory = new ColoredRectFactory(visibleArea);
            surface3DFactory   = new Surface3DFactory(visibleArea);
            renderTextFactory  = new RenderTextFactory(visibleArea);
            fowFactory         = new FowFactory(visibleArea);

            camera3D = new Camera3D(State);

            TextureAtlasManager.RegisterFactory(new TextureAtlasBuilderFactory(State));

            var textureAtlasManager = textureAtlasManagerProvider?.Invoke();
            var palette             = textureAtlasManager.CreatePalette(graphicProvider);

            foreach (var layer in Enum.GetValues <Layer>())
            {
                if (layer == Layer.None)
                {
                    continue;
                }

                try
                {
                    var texture     = textureAtlasManager.GetOrCreate(layer)?.Texture;
                    var renderLayer = Create(layer, texture, palette);

                    if (layer != Layer.Map3DBackground && layer != Layer.Map3D && layer != Layer.Billboards3D)
                    {
                        renderLayer.Visible = true;
                    }

                    AddLayer(renderLayer);
                }
                catch (Exception ex)
                {
                    throw new AmbermoonException(ExceptionScope.Render, $"Unable to create layer '{layer}': {ex.Message}");
                }
            }
        }
Пример #21
0
 public MonsterReader(IGameData gameData, IGraphicProvider graphicProvider)
 {
     this.gameData        = gameData;
     this.graphicProvider = graphicProvider;
 }
Пример #22
0
 public void AddUIOnly(IGraphicProvider graphicProvider, IFontProvider fontProvider)
 {
     AddUI(graphicProvider, false);
     AddCursors(graphicProvider);
     AddFont(fontProvider);
 }
 public void Dispose()
 {
     if (this._land != null)
     {
         foreach (Texture texture in this._land.Values)
         {
             texture.Dispose();
         }
         this._land.Clear();
         this._land = (Dictionary <int, Texture>)null;
     }
     if (this._items != null)
     {
         foreach (Texture texture in this._items.Values)
         {
             texture.Dispose();
         }
         this._items.Clear();
         this._items = (Dictionary <int, Texture>)null;
     }
     if (this._gumps != null)
     {
         foreach (Texture texture in this._gumps.Values)
         {
             texture.Dispose();
         }
         this._gumps.Clear();
         this._gumps = (Dictionary <int, Texture>)null;
     }
     if (this._textures != null)
     {
         foreach (Texture texture in this._textures.Values)
         {
             texture.Dispose();
         }
         this._textures.Clear();
         this._textures = (Dictionary <int, Texture>)null;
     }
     if (this._lights != null)
     {
         foreach (Texture texture in this._lights.Values)
         {
             texture.Dispose();
         }
         this._lights.Clear();
         this._lights = (Dictionary <int, Texture>)null;
     }
     if (this._anims != null)
     {
         foreach (Frames frames in this._anims.Values)
         {
             frames.Dispose();
         }
         this._anims.Clear();
         this._anims = (Dictionary <int, Frames>)null;
     }
     if (this._provider == null)
     {
         return;
     }
     this._provider.Dispose();
     this._provider = (IGraphicProvider)null;
 }
Пример #24
0
 public void SetGraphicsProvider(IGraphicProvider value) => m_Graphics = value;
Пример #25
0
 public static uint GetNPCGraphicIndex(uint npcFileIndex, uint npcIndex, IGraphicProvider graphicProvider) =>
 NPCGraphicOffset + (graphicProvider.NPCGraphicOffsets.TryGetValue((int)npcFileIndex, out var offset) ? (uint)offset : 0) + npcIndex;
Пример #26
0
 public void Dispose()
 {
     if (this._land != null)
     {
         for (int index = 0; index < this._land.Length; ++index)
         {
             if (this._land[index] != null)
             {
                 this._land[index].Dispose();
             }
         }
         this._land = (Texture[])null;
     }
     if (this._items != null)
     {
         for (int index = 0; index < this._items.Length; ++index)
         {
             if (this._items[index] != null)
             {
                 this._items[index].Dispose();
             }
         }
         this._items = (Texture[])null;
     }
     if (this._gumps != null)
     {
         for (int index = 0; index < this._gumps.Length; ++index)
         {
             if (this._gumps[index] != null)
             {
                 this._gumps[index].Dispose();
             }
         }
         this._gumps = (Texture[])null;
     }
     if (this._textures != null)
     {
         for (int index = 0; index < this._textures.Length; ++index)
         {
             if (this._textures[index] != null)
             {
                 this._textures[index].Dispose();
             }
         }
         this._textures = (Texture[])null;
     }
     if (this._anims != null)
     {
         foreach (Frames frames in this._anims.Values)
         {
             frames.Dispose();
         }
         this._anims.Clear();
         this._anims = (Dictionary <int, Frames>)null;
     }
     if (this._lights != null)
     {
         for (int index = 0; index < this._lights.Length; ++index)
         {
             if (this._lights[index] != null)
             {
                 this._lights[index].Dispose();
             }
         }
         this._lights = (Texture[])null;
     }
     if (this._provider == null)
     {
         return;
     }
     this._provider.Dispose();
     this._provider = (IGraphicProvider)null;
 }
Пример #27
0
        public void AddAll(IGameData gameData, IGraphicProvider graphicProvider, IFontProvider fontProvider,
                           Dictionary <uint, Graphic> introTextGlyphs, Dictionary <uint, Graphic> introGraphics)
        {
            if (gameData == null)
            {
                throw new ArgumentNullException(nameof(gameData));
            }

            if (graphicProvider == null)
            {
                throw new ArgumentNullException(nameof(graphicProvider));
            }

            #region Map 2D

            for (int i = (int)GraphicType.Tileset1; i <= (int)GraphicType.Tileset8; ++i)
            {
                var tilesetGraphics = graphicProvider.GetGraphics((GraphicType)i);

                for (uint graphicIndex = 0; graphicIndex < tilesetGraphics.Count; ++graphicIndex)
                {
                    AddTexture(Layer.MapBackground1 + i, graphicIndex, tilesetGraphics[(int)graphicIndex]);
                    AddTexture(Layer.MapForeground1 + i, graphicIndex, tilesetGraphics[(int)graphicIndex]);
                }
            }

            #endregion

            #region Player 2D

            var playerGraphics = graphicProvider.GetGraphics(GraphicType.Player);

            if (playerGraphics.Count != 3 * 17)
            {
                throw new AmbermoonException(ExceptionScope.Data, "Wrong number of player graphics.");
            }

            // There are 3 player characters (one for each world, first lyramion, second forest moon, third morag).
            // Each has 17 frames: 3 back, 3 right, 3 front, 3 left, 1 sit back, 1 sit right, 1 sit front, 1 sit left, 1 bed/sleep.
            // All have a dimension of 16x32 pixels.
            for (int i = 0; i < playerGraphics.Count; ++i)
            {
                AddTexture(Layer.Characters, (uint)i, playerGraphics[i]);
            }

            // On world maps the travel graphics are used.
            // Only 4 sprites are used (one for each direction).
            var travelGraphics = graphicProvider.GetGraphics(GraphicType.TravelGfx);

            if (travelGraphics.Count != 11 * 4)
            {
                throw new AmbermoonException(ExceptionScope.Data, "Wrong number of travel graphics.");
            }

            for (int i = 0; i < travelGraphics.Count; ++i)
            {
                AddTexture(Layer.Characters, Graphics.TravelGraphicOffset + (uint)i, travelGraphics[i]);
            }

            var transportGraphics = graphicProvider.GetGraphics(GraphicType.Transports);

            if (transportGraphics.Count != 5)
            {
                throw new AmbermoonException(ExceptionScope.Data, "Wrong number of transport graphics.");
            }

            for (int i = 0; i < transportGraphics.Count; ++i)
            {
                AddTexture(Layer.Characters, Graphics.TransportGraphicOffset + (uint)i, transportGraphics[i]);
            }

            var npcGraphics = graphicProvider.GetGraphics(GraphicType.NPC);

            if (npcGraphics.Count != 34)
            {
                throw new AmbermoonException(ExceptionScope.Data, "Wrong number of NPC graphics.");
            }

            for (int i = 0; i < npcGraphics.Count; ++i)
            {
                AddTexture(Layer.Characters, Graphics.NPCGraphicOffset + (uint)i, npcGraphics[i]);
            }

            #endregion

            #region UI Layout

            AddUI(graphicProvider);

            #endregion

            #region Portraits

            var portraits = graphicProvider.GetGraphics(GraphicType.Portrait);

            for (int i = 0; i < portraits.Count; ++i)
            {
                AddTexture(Layer.UI, Graphics.PortraitOffset + (uint)i, portraits[i]);
            }

            #endregion

            #region Pics 80x80

            var pics80x80Graphics = graphicProvider.GetGraphics(GraphicType.Pics80x80);

            for (int i = 0; i < pics80x80Graphics.Count; ++i)
            {
                AddTexture(Layer.UI, Graphics.Pics80x80Offset + (uint)i, pics80x80Graphics[i]);
            }

            #endregion

            #region Event pix

            var eventGraphics = graphicProvider.GetGraphics(GraphicType.EventPictures);

            for (int i = 0; i < eventGraphics.Count; ++i)
            {
                AddTexture(Layer.UI, Graphics.EventPictureOffset + (uint)i, eventGraphics[i]);
            }

            #endregion

            #region Text

            AddFont(fontProvider);

            #endregion

            #region Items

            var itemGraphics = graphicProvider.GetGraphics(GraphicType.Item);

            for (int i = 0; i < itemGraphics.Count; ++i)
            {
                AddTexture(Layer.Items, (uint)i, itemGraphics[i]);
            }

            #endregion

            #region Cursors

            AddCursors(graphicProvider);

            #endregion

            #region Combat backgrounds

            var combatBackgrounds = graphicProvider.GetGraphics(GraphicType.CombatBackground);

            for (int i = 0; i < combatBackgrounds.Count; ++i)
            {
                AddTexture(Layer.CombatBackground, Graphics.CombatBackgroundOffset + (uint)i, combatBackgrounds[i]);
            }

            #endregion

            #region Combat graphics (without battle field icons)

            var combatGraphics = graphicProvider.GetGraphics(GraphicType.CombatGraphics);

            for (int i = 0; i < combatGraphics.Count; ++i)
            {
                // Note: One graphic is an UI element so we put it into the UI layer. The rest goes into the BattleEffects layer.
                AddTexture(i == (int)CombatGraphicIndex.UISwordAndMace ? Layer.UI : Layer.BattleEffects, Graphics.CombatGraphicOffset + (uint)i, combatGraphics[i]);
            }

            #endregion

            #region Battle field icons

            var battleFieldIcons = graphicProvider.GetGraphics(GraphicType.BattleFieldIcons);

            for (int i = 0; i < battleFieldIcons.Count; ++i)
            {
                AddTexture(Layer.UI, Graphics.BattleFieldIconOffset + (uint)i, battleFieldIcons[i]);
            }

            #endregion

            #region Automap graphics

            var automapGraphics = graphicProvider.GetGraphics(GraphicType.AutomapGraphics);

            for (int i = 0; i < automapGraphics.Count; ++i)
            {
                AddTexture(Layer.UI, Graphics.AutomapOffset + (uint)i, automapGraphics[i]);
            }

            #endregion

            #region Riddlemouth graphics

            var riddlemouthGraphics = graphicProvider.GetGraphics(GraphicType.RiddlemouthGraphics);

            for (int i = 0; i < riddlemouthGraphics.Count; ++i)
            {
                AddTexture(Layer.UI, Graphics.RiddlemouthOffset + (uint)i, riddlemouthGraphics[i]);
            }

            #endregion

            #region Intro Text

            foreach (var introTextGlyph in introTextGlyphs)
            {
                AddTexture(Layer.IntroText, introTextGlyph.Key, introTextGlyph.Value);
            }

            #endregion

            #region Intro Graphics

            foreach (var introGraphic in introGraphics)
            {
                AddTexture(Layer.IntroGraphics, introGraphic.Key, introGraphic.Value);
            }

            #endregion
        }
Пример #28
0
 public GraphicController(IGraphicProvider graphicProvider)
 {
     this.graphicProvider = graphicProvider;
 }