示例#1
0
        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));
                }
            }
        }
示例#2
0
            public void RenderBeforeWorld(WorldRenderer wr, World world)
            {
                var xy = Game.viewport.ViewToWorld(Viewport.LastMousePos).ToInt2();

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

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

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

                // Unit tiles
                foreach (var unit in power.UnitsInRange(sourceLocation))
                {
                    var targetCell = unit.Location + xy - sourceLocation;
                    var canEnter = unit.Trait<Chronoshiftable>().CanChronoshiftTo(unit,targetCell, false);
                    var tile = canEnter ? validTile : invalidTile;
                    tile.DrawAt( wr, Game.CellSize * targetCell, "terrain" );
                }
            }
示例#3
0
 public void DrawSprite(Sprite s, float2 location, WorldRenderer wr, string palette, float2 size)
 {
     DrawSprite(s, location, wr.GetPaletteIndex(palette), size);
 }
        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));
            }
        }
        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" );
        }
示例#6
0
        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));
            }
        }
示例#7
0
 public void DrawSprite(Sprite s, float2 location, WorldRenderer wr, string palette, float2 size)
 {
     DrawSprite(s, location, wr.GetPaletteIndex(palette), size);
 }
        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 );
        }
示例#9
0
            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" );
                    }
                }
            }