示例#1
0
        /// <summary>
        /// Creates the image for the given type.
        /// </summary>
        private void CreateTileImage(IIsoTileType type)
        {
            Bitmap   baseTerrainA         = new Bitmap(TILE_SIZE, TILE_SIZE);
            Graphics baseTerrainAGraphics = Graphics.FromImage(baseTerrainA);

            baseTerrainAGraphics.Clear(this.terrainColors[type.TerrainA.Name]);
            this.maskImages[type.Combination].MakeTransparent(TERRAIN_A_MASK);
            baseTerrainAGraphics.DrawImageUnscaled(this.maskImages[type.Combination], 0, 0);

            if (type.Combination == TerrainCombination.Simple)
            {
                baseTerrainAGraphics.Dispose();
                this.tileImages.Add(type, baseTerrainA);
                return;
            }

            Bitmap   baseTerrainB         = new Bitmap(TILE_SIZE, TILE_SIZE);
            Graphics baseTerrainBGraphics = Graphics.FromImage(baseTerrainB);

            baseTerrainBGraphics.Clear(this.terrainColors[type.TerrainB.Name]);
            baseTerrainA.MakeTransparent(TERRAIN_B_MASK);
            baseTerrainBGraphics.DrawImageUnscaled(baseTerrainA, 0, 0);

            baseTerrainAGraphics.Dispose();
            baseTerrainBGraphics.Dispose();
            baseTerrainA.Dispose();

            this.tileImages.Add(type, baseTerrainB);
        }
示例#2
0
        /// <summary>
        /// Initializes the isometric tile at the given quadratic coordinates with the given tile type and variant.
        /// </summary>
        /// <param name="quadCoords">The quadratic coordinates of the isometric tile.</param>
        /// <param name="tileType">The tile type to initialize with.</param>
        /// <param name="variantIdx">The index of the tile variant to initialize with.</param>
        public void InitIsoTile(RCIntVector quadCoords, IIsoTileType tileType, int variantIdx)
        {
            if (this.status != MapStatus.Opening)
            {
                throw new InvalidOperationException(string.Format("Invalid operation! Map status: {0}", this.status));
            }
            if (quadCoords == RCIntVector.Undefined)
            {
                throw new ArgumentNullException("quadCoords");
            }
            if (quadCoords.X < 0 || quadCoords.Y < 0 || quadCoords.X >= this.size.X || quadCoords.Y >= this.size.Y)
            {
                throw new ArgumentOutOfRangeException("quadCoords");
            }

            this.quadTiles[quadCoords.X, quadCoords.Y].GetPrimaryIsoTile().SetTileType(tileType, variantIdx);
        }
示例#3
0
        /// TODO: Check if necessary!
        /// <summary>
        /// Sets the given tile type of this isometric tile.
        /// </summary>
        /// <param name="type">The tile type to be set.</param>
        /// <param name="variantIdx">The index of the variant to be set.</param>
        /// <exception cref="InvalidOperationException">If a tile type has already been set for this isometric tile.</exception>
        public void SetTileType(IIsoTileType type, int variantIdx)
        {
            if (this.parentMap.Status != MapStructure.MapStatus.Opening)
            {
                throw new InvalidOperationException(string.Format("Invalid operation! Map status: {0}", this.parentMap.Status));
            }
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            if (variantIdx < 0)
            {
                throw new ArgumentOutOfRangeException("variantIdx", "Variant index must be non-negative!");
            }
            if (this.type != null)
            {
                throw new InvalidOperationException(string.Format("Tile type already set for isometric tile at {0}!", this.mapCoords));
            }

            this.type       = type;
            this.variantIdx = variantIdx;
        }
示例#4
0
        /// <see cref="IIsoTile.ExchangeType"/>
        public void ExchangeType(IIsoTileType newType)
        {
            if (this.parentMap.Status != MapStructure.MapStatus.ExchangingTiles)
            {
                throw new InvalidOperationException(string.Format("Invalid operation! Map status: {0}", this.parentMap.Status));
            }
            if (newType == null)
            {
                throw new ArgumentNullException("newType");
            }

            this.type = newType;

            this.parentMap.OnIsoTileExchanged(this);
            foreach (IsoTile neighbour in this.neighbours)
            {
                if (neighbour != null)
                {
                    this.parentMap.OnIsoTileExchanged(neighbour);
                }
            }
        }