Пример #1
0
        /// <summary>
        /// Constructs a cell.
        /// </summary>
        /// <param name="map">The map that this cell belongs to.</param>
        /// <param name="quadCoords">The coordinates of this cell inside it's parent quadratic tile.</param>
        public Cell(MapStructure map, QuadTile quadTile, RCIntVector quadCoords)
        {
            if (map == null)
            {
                throw new ArgumentNullException("map");
            }
            if (quadTile == null)
            {
                throw new ArgumentNullException("quadTile");
            }
            if (quadCoords == RCIntVector.Undefined)
            {
                throw new ArgumentNullException("quadCoords");
            }
            if (quadCoords.X < 0 || quadCoords.X >= MapStructure.NAVCELL_PER_QUAD || quadCoords.Y < 0 || quadCoords.Y >= MapStructure.NAVCELL_PER_QUAD)
            {
                throw new ArgumentOutOfRangeException("mapCoords");
            }

            this.parentMap          = map;
            this.parentQuadTile     = quadTile;
            this.quadCoords         = quadCoords;
            this.walkabilityFlag    = new Stack <bool>();
            this.buildabilityFlag   = new Stack <bool>();
            this.groundLevel        = new Stack <int>();
            this.isLocked           = false;
            this.mapCoords          = this.parentQuadTile.MapCoords * (new RCIntVector(MapStructure.NAVCELL_PER_QUAD, MapStructure.NAVCELL_PER_QUAD)) + this.quadCoords;
            this.neighbours         = new Cell[8];
            this.detachedNeighbours = new List <Tuple <Cell, MapDirection> >();
            this.parentIsoTile      = null;                  /// will be set later
            this.isoIndices         = RCIntVector.Undefined; /// will be set later
        }
Пример #2
0
        /// <summary>
        /// Constructs an isometric tile.
        /// </summary>
        /// <param name="map">The map that this isometric tile belongs to.</param>
        /// <param name="mapCoords">The map coordinates of this isometric tile.</param>
        public IsoTile(MapStructure map, RCIntVector mapCoords)
        {
            if (map == null)
            {
                throw new ArgumentNullException("map");
            }
            if (mapCoords == RCIntVector.Undefined)
            {
                throw new ArgumentNullException("mapCoords");
            }

            this.parentMap                = map;
            this.mapCoords                = mapCoords;
            this.type                     = null;
            this.variantIdx               = -1;
            this.variant                  = null;
            this.isReady                  = false;
            this.neighbours               = new IsoTile[8];
            this.detachedNeighbours       = new List <Tuple <IsoTile, MapDirection> >();
            this.detachedCells            = new List <Cell>();
            this.cuttingQuadTiles         = new RCSet <QuadTile>();
            this.detachedCuttingQuadTiles = new RCSet <QuadTile>();

            this.cells = new Cell[MapStructure.QUAD_PER_ISO_VERT * MapStructure.NAVCELL_PER_QUAD,
                                  MapStructure.QUAD_PER_ISO_HORZ *MapStructure.NAVCELL_PER_QUAD];

            this.referenceCell = null;
        }
Пример #3
0
        /// <summary>
        /// Constructs a quadratic tile.
        /// </summary>
        /// <param name="map">The map that this quadratic tile belongs to.</param>
        /// <param name="primaryIsoTile">Primary isometric tile.</param>
        /// <param name="secondaryIsoTile">Secondary isometric tile or null if doesn't exist.</param>
        /// <param name="mapCoords">The map coordinates of this quadratic tile.</param>
        public QuadTile(MapStructure map, IsoTile primaryIsoTile, IsoTile secondaryIsoTile, RCIntVector mapCoords)
        {
            if (map == null)
            {
                throw new ArgumentNullException("map");
            }
            if (primaryIsoTile == null)
            {
                throw new ArgumentNullException("isoTile");
            }
            if (mapCoords == RCIntVector.Undefined)
            {
                throw new ArgumentNullException("mapCoords");
            }
            if (mapCoords.X < 0 || mapCoords.X >= MapStructure.MAX_MAPSIZE || mapCoords.Y < 0 || mapCoords.Y >= MapStructure.MAX_MAPSIZE)
            {
                throw new ArgumentOutOfRangeException("mapCoords");
            }

            this.parentMap          = map;
            this.primaryIsoTile     = primaryIsoTile;
            this.secondaryIsoTile   = secondaryIsoTile;
            this.terrainObject      = null;
            this.mapCoords          = mapCoords;
            this.neighbours         = new QuadTile[8];
            this.detachedNeighbours = new List <Tuple <QuadTile, MapDirection> >();
            this.isBuildableCache   = new CachedValue <bool>(this.CalculateBuildabilityFlag);
            this.groundLevelCache   = new CachedValue <int>(this.CalculateGroundLevel);

            this.cells = new Cell[MapStructure.NAVCELL_PER_QUAD, MapStructure.NAVCELL_PER_QUAD];
            for (int col = 0; col < MapStructure.NAVCELL_PER_QUAD; col++)
            {
                for (int row = 0; row < MapStructure.NAVCELL_PER_QUAD; row++)
                {
                    this.cells[col, row] = new Cell(this.parentMap, this, new RCIntVector(col, row));
                }
            }

            this.primaryIsoTile.SetCuttingQuadTile(this);
            if (this.secondaryIsoTile != null)
            {
                this.secondaryIsoTile.SetCuttingQuadTile(this);
            }
        }
Пример #4
0
        /// <summary>
        /// Constructs a MapAccess instance.
        /// </summary>
        /// <param name="mapStructure">Reference to the used map structure.</param>
        public MapAccess(string mapName, MapStructure mapStructure)
        {
            if (mapName == null)
            {
                throw new ArgumentNullException("mapName");
            }
            if (mapStructure == null)
            {
                throw new ArgumentNullException("mapStructure");
            }
            if (mapStructure.Status != MapStructure.MapStatus.Closed)
            {
                throw new InvalidOperationException("A map is already opened with this MapStructure!");
            }

            this.mapName        = mapName;
            this.mapStructure   = mapStructure;
            this.terrainObjects = new RCSet <ITerrainObject>();
        }