public PlayerShotHandler(GraphicsDevice device, ContentManager content, GraphicsDevice graphicsDevice) { laserShotTexture = PngLoader.Load(device, "Content/LaserShotsOrange.png"); this.playerShotDefinitionList = new PlayerLaserShotUpgradeStatusList(); this.spriteBatch = new SpriteBatch(graphicsDevice); this.playerLaserShotList = new List <PlayerLaserShot>(); }
public void LoadBackGround(GraphicsDevice device, ContentManager content) { //Load Background backgroundSprite1 = PngLoader.Load(device, "Content/GalaxyBackgroundLarge_1920x1080.png"); backgroundSprite2 = PngLoader.Load(device, "Content/GalaxyBackgroundLarge_1920x1080.png"); background1Position = new Vector2(0, 0); background2Position = new Vector2(0, 0 - backgroundSprite1.Height); }
public void InitializeAndLoadPlayer(GraphicsDevice device, ContentManager content, Vector2 initalPosition, SpriteBatch hbSpriteBatch) { this.playerPosition = initalPosition; this.playerHealth = 100; this.playerBaseDamage = 25; this.playerDamageMultiplier = 1f; this.playerResultingDamage = (int)(this.playerBaseDamage * this.playerDamageMultiplier); this.playerTexture = PngLoader.Load(device, "Content/SpaceshipPlayer.png"); this.healthbarXCorrection = 5; float hbScale = 0.4f; Vector2 initialPlayerHBPosition = (this.playerPosition + (new Vector2(((((playerTexture.Width * this.shipScale.X) / 2) - (((HealthBar.healthBarTexture.Width * hbScale) / 2) + 5)) + healthbarXCorrection), (playerTexture.Height * this.shipScale.X) + 7))); playerHealthBar = new HealthBar(hbSpriteBatch, initialPlayerHBPosition, this.playerHealth, hbScale); }
public static void ConvertPngToShp(string[] args) { var dest = args[1].Split('-').First() + ".shp"; var frames = args.Skip(1).Select(a => PngLoader.Load(a)); var size = frames.First().Size; if (frames.Any(f => f.Size != size)) { throw new InvalidOperationException("All frames must be the same size"); } using (var destStream = File.Create(dest)) ShpReader.Write(destStream, size, frames.Select(f => f.ToBytes())); Console.WriteLine(dest + " saved."); }
public static void ConvertPngToShp(string[] args) { var src = args[1]; var dest = Path.ChangeExtension(src, ".shp"); var width = int.Parse(args[2]); var srcImage = PngLoader.Load(src); if (srcImage.Width % width != 0) { throw new InvalidOperationException("Bogus width; not a whole number of frames"); } using (var destStream = File.Create(dest)) ShpWriter.Write(destStream, width, srcImage.Height, srcImage.ToFrames(width)); }
public void Run(ModData modData, string[] args) { var inputFiles = GlobArgs(args).OrderBy(a => a).ToList(); var dest = inputFiles[0].Split('-').First() + ".shp"; var frames = inputFiles.Select(a => PngLoader.Load(a)); var size = frames.First().Size; if (frames.Any(f => f.Size != size)) { throw new InvalidOperationException("All frames must be the same size"); } using (var destStream = File.Create(dest)) ShpTDSprite.Write(destStream, size, frames.Select(f => ToBytes(f))); Console.WriteLine(dest + " saved."); }
public SpriteSheet Load(GraphicsDevice device, string imageResource) { var texture = PngLoader.Load(device, $"Content/{imageResource}"); var dataFile = Path.Combine( this.contentManager.RootDirectory, Path.ChangeExtension(imageResource, "txt")); var dataFileLines = this.ReadDataFile(dataFile); var sheet = new SpriteSheet(); foreach ( var cols in from row in dataFileLines where !string.IsNullOrEmpty(row) && !row.StartsWith("#") select row.Split(';')) { if (cols.Length != 10) { throw new InvalidDataException("Incorrect format data in spritesheet data file"); } var isRotated = int.Parse(cols [1]) == 1; var name = cols[0]; var sourceRectangle = new Rectangle( int.Parse(cols[2]), int.Parse(cols[3]), int.Parse(cols[4]), int.Parse(cols[5])); var size = new Vector2( int.Parse(cols[6]), int.Parse(cols[7])); var pivotPoint = new Vector2( float.Parse(cols[8]), float.Parse(cols[9])); var sprite = new SpriteFrame(texture, sourceRectangle, size, pivotPoint, isRotated); sheet.Add(name, sprite); } return(sheet); }