示例#1
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="info">Info about the generated tile sheet.</param>
 /// <param name="collisionInfo">Collision info about the door when closed.</param>
 /// <param name="topLeftTileIndex">The tile index of the start of the animation.</param>
 /// <param name="isFirstFrameIsClosed">Whether the first frame is closed or open.</param>
 public GeneratedDoorTileInfo(GeneratedTileSheetInfo info, Rectangle collisionInfo, int topLeftTileIndex, bool isFirstFrameIsClosed)
 {
     this.TileSheetInfo        = info;
     this.CollisionInfo        = collisionInfo;
     this.TopLeftTileIndex     = topLeftTileIndex;
     this.isFirstFrameIsClosed = isFirstFrameIsClosed;
 }
示例#2
0
        /// <summary>Creates a new texture, updating the relevant state.</summary>
        /// <returns>The asset key and texture that was created.</returns>
        public KeyValuePair <string, Texture2D> CreateNewTexture()
        {
            this.Texture?.SetData(this.TextureData);

            int doorsThatCanFit = Math.Min(DoorGenerationState.MaxDoorsInSheet, this.NumberOfDoorsLeft);
            int numRows         = (int)Math.Ceiling(doorsThatCanFit / 64.0);

            this.Texture     = new Texture2D(this.graphicsDevice, numRows > 1 ? 4096 : doorsThatCanFit *DoorGenerationState.DoorAnimationSize.X, numRows > 1 ? numRows *DoorGenerationState.DoorAnimationSize.Y : DoorGenerationState.DoorAnimationSize.Y);
            this.TextureData = new Color[this.Width * this.Texture.Height];

            this.NumberOfDoorsLeft -= doorsThatCanFit;

            string id = $"z_{this.modId}_{this.locationName}_{this.generatedTextureCount}";

            this.generatedTextureCount++;
            this.tileSheetInfo = new GeneratedTileSheetInfo(new Point(this.Width / 16, this.Texture.Height / 16), id, id);

            return(new KeyValuePair <string, Texture2D>(id, this.Texture));
        }