當前位置: 首頁>>代碼示例>>C#>>正文


C# WorldRenderer.GetPaletteIndex方法代碼示例

本文整理匯總了C#中OpenRA.Graphics.WorldRenderer.GetPaletteIndex方法的典型用法代碼示例。如果您正苦於以下問題:C# WorldRenderer.GetPaletteIndex方法的具體用法?C# WorldRenderer.GetPaletteIndex怎麽用?C# WorldRenderer.GetPaletteIndex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OpenRA.Graphics.WorldRenderer的用法示例。


在下文中一共展示了WorldRenderer.GetPaletteIndex方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DrawSprite

 public void DrawSprite(Sprite s, float2 location, WorldRenderer wr, string palette, float2 size)
 {
     DrawSprite(s, location, wr.GetPaletteIndex(palette), size);
 }
開發者ID:maruchinu,項目名稱:OpenRA,代碼行數:4,代碼來源:SpriteRenderer.cs

示例2: DrawShroud

        void DrawShroud( WorldRenderer wr, Rectangle clip, Sprite[,] s, string pal )
        {
            var shroudPalette = wr.GetPaletteIndex(pal);

            for (var j = clip.Top; j < clip.Bottom; j++)
            {
                var starti = clip.Left;
                var last = shadowBits[0x0f];
                for (var i = clip.Left; i < clip.Right; i++)
                {
                    if ((s[i, j] == shadowBits[0x0f] && last == shadowBits[0x0f])
                        || (s[i, j] == shadowBits[0] && last == shadowBits[0]))
                        continue;

                    if (starti != i)
                    {
                        s[starti, j].DrawAt(
                            Game.CellSize * new float2(starti, j),
                            shroudPalette,
                            new float2(Game.CellSize * (i - starti), Game.CellSize));
                        starti = i + 1;
                    }

                    s[i, j].DrawAt(
                        Game.CellSize * new float2(i, j),
                        shroudPalette);
                    starti = i + 1;
                    last = s[i, j];
                }

                if (starti < clip.Right)
                    s[starti, j].DrawAt(
                        Game.CellSize * new float2(starti, j),
                        shroudPalette,
                        new float2(Game.CellSize * (clip.Right - starti), Game.CellSize));
            }
        }
開發者ID:sonygod,項目名稱:OpenRA-Dedicated-20120504,代碼行數:37,代碼來源:ShroudRenderer.cs

示例3: RenderBeforeWorld

        public void RenderBeforeWorld( WorldRenderer wr, World world )
        {
            var position = Game.viewport.ViewToWorld(Viewport.LastMousePos);
            var topLeft = position - FootprintUtils.AdjustForBuildingSize( BuildingInfo );

            var actorInfo = Rules.Info[Building];
            foreach (var dec in actorInfo.Traits.WithInterface<IPlaceBuildingDecoration>())
                dec.Render(wr, world, actorInfo, Traits.Util.CenterOfCell(position));	/* hack hack */

            var cells = new Dictionary<CPos, bool>();
            // Linebuild for walls.
            // Assumes a 1x1 footprint; weird things will happen for other footprints
            if (Rules.Info[Building].Traits.Contains<LineBuildInfo>())
            {
                foreach( var t in BuildingUtils.GetLineBuildCells( world, topLeft, Building, BuildingInfo ) )
                    cells.Add( t, BuildingInfo.IsCloseEnoughToBase( world, world.LocalPlayer, Building, t ) );
            }
            else
            {
                foreach (var r in Preview)
                    r.Sprite.DrawAt(topLeft.ToPPos().ToFloat2() + r.Pos,
                                    wr.GetPaletteIndex(r.Palette),
                                    r.Scale*r.Sprite.size);

                var res = world.WorldActor.Trait<ResourceLayer>();
                var isCloseEnough = BuildingInfo.IsCloseEnoughToBase(world, world.LocalPlayer, Building, topLeft);
                foreach (var t in FootprintUtils.Tiles(Building, BuildingInfo, topLeft))
                    cells.Add( t, isCloseEnough && world.IsCellBuildable(t, BuildingInfo) && res.GetResource(t) == null );
            }

            foreach( var c in cells )
                ( c.Value ? buildOk : buildBlocked ).DrawAt(wr, c.Key.ToPPos().ToFloat2(), "terrain" );
        }
開發者ID:Iran,項目名稱:ClassicRA,代碼行數:33,代碼來源:PlaceBuildingOrderGenerator.cs

示例4: DrawShroud

        void DrawShroud( WorldRenderer wr, int minx, int miny, int maxx, int maxy, Sprite[,] s, string pal )
        {
            var shroudPalette = wr.GetPaletteIndex(pal);

            for (var j = miny; j < maxy; j++)
            {
                var starti = minx;
                for (var i = minx; i < maxx; i++)
                {
                    if (s[i, j] == shadowBits[0x0f])
                        continue;

                    if (starti != i)
                    {
                        s[starti, j].DrawAt(
                            Game.CellSize * new float2(starti, j),
                            shroudPalette,
                            new float2(Game.CellSize * (i - starti), Game.CellSize));
                        starti = i + 1;
                    }

                    s[i, j].DrawAt(
                        Game.CellSize * new float2(i, j),
                        shroudPalette);
                    starti = i + 1;
                }

                if (starti < maxx)
                    s[starti, j].DrawAt(
                        Game.CellSize * new float2(starti, j),
                        shroudPalette,
                        new float2(Game.CellSize * (maxx - starti), Game.CellSize));
            }
        }
開發者ID:geckosoft,項目名稱:OpenRA,代碼行數:34,代碼來源:ShroudRenderer.cs

示例5: RenderBeforeWorld

        public void RenderBeforeWorld( WorldRenderer wr, World world )
        {
            var position = Game.viewport.ViewToWorld(Viewport.LastMousePos).ToInt2();
            var topLeft = position - FootprintUtils.AdjustForBuildingSize( BuildingInfo );

            var cells = new Dictionary<int2, bool>();
            // Linebuild for walls.
            // Assumes a 1x1 footprint; weird things will happen for other footprints
            if (Rules.Info[Building].Traits.Contains<LineBuildInfo>())
            {
                foreach( var t in BuildingUtils.GetLineBuildCells( world, topLeft, Building, BuildingInfo ) )
                    cells.Add( t, BuildingInfo.IsCloseEnoughToBase( world, world.LocalPlayer, Building, t ) );
            }
            else
            {
                foreach (var r in Preview)
                    r.Sprite.DrawAt(Game.CellSize*topLeft + r.Pos,
                                    wr.GetPaletteIndex(r.Palette ?? world.LocalPlayer.Palette),
                                    r.Scale*r.Sprite.size);

                var res = world.WorldActor.Trait<ResourceLayer>();
                var isCloseEnough = BuildingInfo.IsCloseEnoughToBase(world, world.LocalPlayer, Building, topLeft);
                foreach (var t in FootprintUtils.Tiles(Building, BuildingInfo, topLeft))
                    cells.Add( t, isCloseEnough && world.IsCellBuildable(t, BuildingInfo.WaterBound) && res.GetResource(t) == null );
            }

            wr.uiOverlay.DrawGrid( wr, cells );
        }
開發者ID:patthoyts,項目名稱:OpenRA,代碼行數:28,代碼來源:PlaceBuildingOrderGenerator.cs

示例6: RenderBeforeWorld

            public void RenderBeforeWorld(WorldRenderer wr, World world)
            {
                var xy = Game.viewport.ViewToWorld(Viewport.LastMousePos);

                // Source tiles
                foreach (var t in world.FindTilesInCircle(sourceLocation, range))
                    sourceTile.DrawAt( wr, t.ToPPos().ToFloat2(), "terrain" );

                // Destination tiles
                foreach (var t in world.FindTilesInCircle(xy, range))
                    sourceTile.DrawAt( wr, t.ToPPos().ToFloat2(), "terrain" );

                // Unit previews
                foreach (var unit in power.UnitsInRange(sourceLocation))
                {
                    if (manager.self.Owner.Shroud.IsTargetable(unit)) {
                        var targetCell = unit.Location + (xy - sourceLocation);
                        foreach (var r in unit.Render())
                            r.Sprite.DrawAt(r.Pos - Traits.Util.CenterOfCell(unit.Location).ToFloat2() + Traits.Util.CenterOfCell(targetCell).ToFloat2(),
                                wr.GetPaletteIndex(r.Palette),
                                r.Scale*r.Sprite.size);
                    }
                }

                // Unit tiles
                foreach (var unit in power.UnitsInRange(sourceLocation))
                {
                    if (manager.self.Owner.Shroud.IsTargetable(unit)) {
                        var targetCell = unit.Location + (xy - sourceLocation);
                        var canEnter = ((manager.self.Owner.Shroud.IsExplored(targetCell) || manager.self.Owner.HasFogVisibility())&& unit.Trait<Chronoshiftable>().CanChronoshiftTo(unit,targetCell));
                        var tile = canEnter ? validTile : invalidTile;
                        tile.DrawAt( wr, targetCell.ToPPos().ToFloat2(), "terrain" );
                    }
                }
            }
開發者ID:VrKomarov,項目名稱:OpenRA,代碼行數:35,代碼來源:ChronoshiftPower.cs


注:本文中的OpenRA.Graphics.WorldRenderer.GetPaletteIndex方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。