Exemple #1
0
        public void CellPosition(CellClass c)
        {
            var b = c.Bounds2D;

            b.Offset(-ScreenArea.Left, -ScreenArea.Top);

            var pointsToCheck = new Point[] {
                new Point(b.Left, b.Top),
                new Point(b.Left, b.Bottom),
                new Point(b.Right, b.Top),
                new Point(b.Right, b.Bottom),
            };

            if (pointsToCheck.Any(p => ScreenBounds.Contains(p)))
            {
                var tl = c.TileDimensions;
                c.TacticalPosition  = new CellStruct(b.Left - tl.Left, b.Top - tl.Top);
                c.VisibleInTactical = true;
                return;
            }

            c.TacticalPosition  = new CellStruct();
            c.VisibleInTactical = false;
            return;
        }
Exemple #2
0
 public void UpdateCellPosition(CellClass c)
 {
     if (c != null)
     {
         c.PreviouslyVisibleInTactical = c.VisibleInTactical;
         CellPosition(c);
     }
 }
Exemple #3
0
 public void UpdateCellPosition(CellClass c)
 {
     if (c != null) {
         c.PreviouslyVisibleInTactical = c.VisibleInTactical;
         CellPosition(c);
     }
 }
Exemple #4
0
        public void CellPosition(CellClass c)
        {
            var b = c.Bounds2D;

            b.Offset(-ScreenArea.Left, -ScreenArea.Top);

            var pointsToCheck = new Point[] {
                new Point(b.Left, b.Top),
                new Point(b.Left, b.Bottom),
                new Point(b.Right, b.Top),
                new Point(b.Right, b.Bottom),
            };

            if (pointsToCheck.Any(p => ScreenBounds.Contains(p))) {
                var tl = c.TileDimensions;
                c.TacticalPosition = new CellStruct(b.Left - tl.Left, b.Top - tl.Top);
                c.VisibleInTactical = true;
                return;
            }

            c.TacticalPosition = new CellStruct();
            c.VisibleInTactical = false;
            return;
        }
Exemple #5
0
        private void CreateMap()
        {
            var wh = MapSize.Width + MapSize.Height - 1;

            var lineBaseOffset = 0;

            for (var v2 = 0; v2 < 2 * wh + 2; ++v2) {
                for (var v1 = 0; v1 < wh + 2; ++v1) {

                    var v3 = v1 + v2;
                    var v4 = MapRect.Width;
                    if (v3 > v4) {
                        if (v1 - v2 < v4) {
                            if (v2 - v1 < v4) {
                                if (v3 <= v4 + 2 * MapRect.Height) {
                                    var cell = new CellClass() {
                                        X = v1,
                                        Y = v2,
                                        Level = 0
                                    };
                                    Cells[v1 + lineBaseOffset] = cell;
                                }
                            }
                        }
                    }
                }

                lineBaseOffset += 512;
            }

            cellIter = new CellIterator(this);

            foreach (var c in cellIter.Range()) {
                var x = c.X;
                var y = c.Y;

                var W = MapSize.Width;

                if (x + y < W - 2 * MapSize.Top + 1
                    || y - x > W + 2 * MapSize.Left - 1
                    || x + y > W + 2 * ((2 * MapSize.Height - 8) - MapSize.Top)
                    || x - y > W + 2 * (- MapSize.Left - 1)) {

                    var idxCell = x + (y << 9);
                    var newC = new CellClass() {
                        X = x,
                        Y = y,
                        IsoTileTypeIndex = 65535,
                        IsoTileTypeSubIndex = 0,
                        Slope = 0,
                        OverlayTypeIndex = -1,
                        Level = 0
                    };
                    Cells[idxCell] = newC;
                }
            }
        }
Exemple #6
0
        private void CreateMap()
        {
            var wh = MapSize.Width + MapSize.Height - 1;

            var lineBaseOffset = 0;

            for (var v2 = 0; v2 < 2 * wh + 2; ++v2)
            {
                for (var v1 = 0; v1 < wh + 2; ++v1)
                {
                    var v3 = v1 + v2;
                    var v4 = MapRect.Width;
                    if (v3 > v4)
                    {
                        if (v1 - v2 < v4)
                        {
                            if (v2 - v1 < v4)
                            {
                                if (v3 <= v4 + 2 * MapRect.Height)
                                {
                                    var cell = new CellClass()
                                    {
                                        X     = v1,
                                        Y     = v2,
                                        Level = 0
                                    };
                                    Cells[v1 + lineBaseOffset] = cell;
                                }
                            }
                        }
                    }
                }

                lineBaseOffset += 512;
            }

            cellIter = new CellIterator(this);

            foreach (var c in cellIter.Range())
            {
                var x = c.X;
                var y = c.Y;

                var W = MapSize.Width;

                if (x + y < W - 2 * MapSize.Top + 1 ||
                    y - x > W + 2 * MapSize.Left - 1 ||
                    x + y > W + 2 * ((2 * MapSize.Height - 8) - MapSize.Top) ||
                    x - y > W + 2 * (-MapSize.Left - 1))
                {
                    var idxCell = x + (y << 9);
                    var newC    = new CellClass()
                    {
                        X = x,
                        Y = y,
                        IsoTileTypeIndex    = 65535,
                        IsoTileTypeSubIndex = 0,
                        Slope            = 0,
                        OverlayTypeIndex = -1,
                        Level            = 0
                    };
                    Cells[idxCell] = newC;
                }
            }
        }