Esempio n. 1
0
        void UpdateShroud(ProjectedCellRegion region)
        {
            foreach (var puv in region)
            {
                var uv = (MPos)puv;
                if (!cellsDirty[uv] || !tileInfos.Contains(uv))
                {
                    continue;
                }

                cellsDirty[uv] = false;

                var tileInfo     = tileInfos[uv];
                var shroudSprite = GetSprite(shroudSprites, GetEdges(puv, visibleUnderShroud), tileInfo.Variant);
                var shroudPos    = tileInfo.ScreenPosition;
                if (shroudSprite != null)
                {
                    shroudPos += shroudSprite.Offset - 0.5f * shroudSprite.Size;
                }

                var fogSprite = GetSprite(fogSprites, GetEdges(puv, visibleUnderFog), tileInfo.Variant);
                var fogPos    = tileInfo.ScreenPosition;
                if (fogSprite != null)
                {
                    fogPos += fogSprite.Offset - 0.5f * fogSprite.Size;
                }

                shroudLayer.Update(uv, shroudSprite, shroudPos);
                fogLayer.Update(uv, fogSprite, fogPos);
            }
        }
Esempio n. 2
0
File: Map.cs Progetto: pchote/OpenRA
        public void SetBounds(PPos tl, PPos br)
        {
            // The tl and br coordinates are inclusive, but the Rectangle
            // is exclusive.  Pad the right and bottom edges to match.
            Bounds = Rectangle.FromLTRB(tl.U, tl.V, br.U + 1, br.V + 1);

            // Directly calculate the projected map corners in world units avoiding unnecessary
            // conversions.  This abuses the definition that the width of the cell is always
            // 1024 units, and that the height of two rows is 2048 for classic cells and 1024
            // for isometric cells.
            var wtop = tl.V * 1024;
            var wbottom = (br.V + 1) * 1024;
            if (Grid.Type == MapGridType.RectangularIsometric)
            {
                wtop /= 2;
                wbottom /= 2;
            }

            ProjectedTopLeft = new WPos(tl.U * 1024, wtop, 0);
            ProjectedBottomRight = new WPos(br.U * 1024 - 1, wbottom - 1, 0);

            ProjectedCellBounds = new ProjectedCellRegion(this, tl, br);
        }