public override void UnloadContent() { base.UnloadContent(); camera = null; frameCounter = null; font = null; tilemapTexture = null; level = null; pixel = null; backgroundWaterGradientStrip = null; energyBar = null; healthBar = null; player = null; spikesPointingDown = null; spikesPointingUp = null; spikesPointingLeft = null; spikesPointingRight = null; enemies = null; SFX = null; }
public override void LoadContent() { base.LoadContent(); camera = new Camera2D(Vector2.Zero); camera.Zoom = (float)Graphics.PreferredBackBufferHeight * 2.45f / 600f; // the ideal zoom is 2.45 at 600px of screen height font = content.Load <SpriteFont>("Font"); tilemapTexture = this.content.Load <Texture2D>("SpriteSheet"); song = content.Load <Song>("InkStuff"); MediaPlayer.Volume = 0.3f; MediaPlayer.Play(song); MediaPlayer.IsRepeating = true; /* * A single pixel to draw lines and stuff */ pixel = new Texture2D(Graphics.GraphicsDevice, 1, 1); DrawMe.Fill(pixel, Color.White); /* * Load sfx */ SFX.Add("bubble", content.Load <SoundEffect>("sfx_bubble")); SFX.Add("bubble_noise_single", content.Load <SoundEffect>("BubbleNoisesSingle")); SFX.Add("anchor", content.Load <SoundEffect>("Anchor3")); SFX.Add("fall", content.Load <SoundEffect>("Falling")); SFX.Add("enemyDeath", content.Load <SoundEffect>("EnemyDeath")); /* * Player init */ player = new Player(this, tilemapTexture, Vector2.Zero, 32, 32, true); /*player.Animations.CurrentFrame = new Frame(96, 176, 16, 32);*/ // woman player.Animations.CurrentFrame = new Frame(16, 64, 32, 32); // actual player //player.Animations.Add("shooting", new int[] { 147, 149, 151, 153, 155}, 6, true); //player.Animations.Add("woman-run", new int[] { 183, 184, 185, 186, 187, 188 }, 12, true); player.Body.X = 16 * 440; /*330*/ //spawn x player.Body.Y = 16 * 3; //spawn y player.Body.SetSize(16, 32, 0, 0); // woman player.Body.SetSize(10, 26, 11, 3); // actual player //player.Animations.Play("woman-run"); /* * Level init */ XMLLevelLoader XMLloader = new XMLLevelLoader(); level = XMLloader.LoadLevel(this, @"Content\Level1.tmx", tilemapTexture); level.SetCollisionTiles(new int[] { 2, 33, 34, 35, 47, 66, }); /* * parse objects */ foreach (TiledObject obj in level.Objects) { Console.WriteLine("parsing " + obj.Name); if (obj.Name.ToLower() == "jellyfish") { Vector2 center = new Vector2(obj.X + obj.Width / 2, obj.Y + obj.Height / 2); Vector2 radius = new Vector2(obj.Width / 2, obj.Height / 2); float speed = float.Parse(obj.GetProperty("speed")); JellyFish j = new JellyFish(this, tilemapTexture, Vector2.Zero, 16, 32, center, radius, speed); // make it start on the right side of its path if (obj.GetProperty("start_rotation") == "right") { j.FacingDirection = 1; } else { j.FacingDirection = -1; } Console.WriteLine(obj.GetProperty("start_rotation")); enemies.Add(j); Console.WriteLine("added jelly"); } else if (obj.Name.ToLower() == "pufferfish") { Vector2 position = new Vector2(obj.X, obj.Y); float speed = float.Parse(obj.GetProperty("speed")); PufferFish p = new PufferFish(this, tilemapTexture, position, 32, 32, obj.Width, speed); // make it start on the right side of its path if (obj.GetProperty("start_side") == "right") { p.Body.X = obj.X + obj.Width; p.CurrentDistance = obj.Width - 33; } enemies.Add(p); Console.WriteLine("added puffer"); } else if (obj.Name.ToLower() == "goldfish") { goldenFishs.Add(new GoldFish(this, tilemapTexture, new Vector2(obj.X, obj.Y), 16, 16)); } else if (obj.Name.ToLower() == "particles") { ParticleEmitter particleEmitter = new ParticleEmitter(this, obj.X, obj.Y, 256); particleEmitter.EmitterBox.Resize(obj.Width, obj.Height); particleEmitter.MakeParticles(tilemapTexture, 16, 16); particleEmitter.ParticleVelocity = new Vector2(0, -0.01f); particleEmitter.SetAcceleration(0, -0.005f); particleEmitter.XVelocityVariationRange = new Vector2(-20f, 20f); particleEmitter.YVelocityVariationRange = new Vector2(-20f, 0f); particleEmitter.SetTextureCropRectangle(new Rectangle(0, 78, 16, 16)); particleEmitter.SpawnRate = 250f; particleEmitter.ParticleLifespanMilliseconds = 5000f; particleEmitter.ParticleLifespanVariationMilliseconds = 1000f; particleEmitter.InitialScale = 0.1f; particleEmitter.FinalScale = 1.5f; particleEmitter.ForEachParticle(ChangeSpriteTintBlue); backgroundParticles.Add(particleEmitter); Console.WriteLine("added particles"); } else if (obj.Name.ToLower() == "player_spawn") { player.Body.X = obj.X; player.Body.Y = obj.Y; } else if (obj.Name.ToLower() == "change_state_trigger") { triggers.Add(new Trigger(obj.X, obj.Y, obj.Width, obj.Height, obj.GetProperty("value"))); } } // build spikes tiles list spikesPointingDown = level.GetTilesListByID(new int[] { 514 }); spikesPointingUp = level.GetTilesListByID(new int[] { 515 }); foreach (Tile spike in spikesPointingDown) { spike.Body.SetSize(12, 6, 1, 0); } foreach (Tile spike in spikesPointingUp) { spike.Body.SetSize(12, 6, 2, 10); } topWaterTiles = level.GetTilesListByID(new int[] { 97, 98, 99 }); /* * UI Elements init */ healthBar = new EnergyBar(Graphics, new Vector2(16, 16), 256, 16, new Color(0, 255, 0)); energyBar = new EnergyBar(Graphics, new Vector2(16, 32 + 4), 256, 16, new Color(255, 0, 0)); /* * Build Background Gradient */ backgroundWaterGradientStrip = new Texture2D(Graphics.GraphicsDevice, 1, level.Height * level.TileHeight); Color startColor = new Color(57, 92, 181); Color finishColor = new Color(17, 43, 104); Color currentColor; for (int i = 0; i < backgroundWaterGradientStrip.Height; i++) { float ratio = Math2.Map(i, 0f, backgroundWaterGradientStrip.Height, 0f, 1.0f); currentColor = Color.Lerp(startColor, finishColor, ratio); DrawMe.Pixel(backgroundWaterGradientStrip, 0, i, currentColor); } /* * Build Background Gradient */ backgroundSkyGradientStrip = new Texture2D(Graphics.GraphicsDevice, 1, Graphics.PreferredBackBufferHeight / 2); startColor = new Color(61, 28, 111); finishColor = new Color(158, 98, 123); for (int i = 0; i < backgroundSkyGradientStrip.Height; i++) { float ratio = Math2.Map(i, 0f, backgroundSkyGradientStrip.Height, 0f, 1.0f); currentColor = Color.Lerp(startColor, finishColor, ratio); DrawMe.Pixel(backgroundSkyGradientStrip, 0, i, currentColor); } ContentLoaded = true; }
public override void LoadContent() { base.LoadContent(); MediaPlayer.Stop(); camera = new Camera2D(Vector2.Zero); camera.Zoom = (float)Graphics.PreferredBackBufferHeight * 2.45f / 600f; // the ideal zoom is 2.45 at 600px of screen height font = content.Load <SpriteFont>("Font"); tilemapTexture = this.content.Load <Texture2D>("spritesheet-jn"); /* * Player Health & Energy */ texturePlayerHealth = this.content.Load <Texture2D>("HeartDraft"); texturePlayerEnergy = this.content.Load <Texture2D>("EnergyBar"); /* * A single pixel to draw lines and stuff */ pixel = new Texture2D(Graphics.GraphicsDevice, 1, 1); DrawMe.Fill(pixel, Color.White); /* * Load sfx */ SFX.Add("bubble", content.Load <SoundEffect>("sfx_bubble")); SFX.Add("bubble_noise_single", content.Load <SoundEffect>("BubbleNoisesSingle")); SFX.Add("anchor", content.Load <SoundEffect>("Anchor3")); SFX.Add("fall", content.Load <SoundEffect>("Falling")); SFX.Add("enemyDeath", content.Load <SoundEffect>("EnemyDeath")); /* * Player init */ player = new Player(this, tilemapTexture, Vector2.Zero, 32, 32, true); player.Animations.CurrentFrame = new Frame(96, 176, 16, 32); // woman player.Animations.CurrentFrame = new Frame(0, 144, 32, 32); // actual player //player.Animations.Add("robot-idle", new int[] { 177, 178, 179, 180, 181, 182 }, 6, false, true); //player.Animations.Add("woman-run", new int[] { 183, 184, 185, 186, 187, 188 }, 12, true); player.Body.X = 16 * 7; player.Body.Y = 16 * 5; player.Body.SetSize(16, 32, 0, 0); // woman player.Body.SetSize(10, 26, 11, 3); // actual player Karma.maxKarma = 0; Karma.playerShotsFired = 0; Karma.playerTotalDamage = 0f; Karma.playerCollect = 0; //player.Animations.Play("woman-run"); /* * Level init */ XMLLevelLoader XMLloader = new XMLLevelLoader(); level = XMLloader.LoadLevel(this, @"Content\featureTestMap.tmx", tilemapTexture); level.SetCollisionTiles(new int[] { 1, 2, 17, 18, 33, 34 }); /* * parse objects */ foreach (TiledObject obj in level.Objects) { Console.WriteLine("parsing " + obj.Name); if (obj.Name.ToLower() == "jellyfish") { Vector2 center = new Vector2(obj.X + obj.Width / 2, obj.Y + obj.Height / 2); Vector2 radius = new Vector2(obj.Width / 2, obj.Height / 2); float speed = float.Parse(obj.GetProperty("speed")); JellyFish j = new JellyFish(this, tilemapTexture, Vector2.Zero, 16, 32, center, radius, speed); j.Animations.CurrentFrame = new Frame(48, 112, 16, 32); enemies.Add(j); Karma.maxKarma = Karma.DefineMaxKarma(Karma.maxKarma, j.Health); Console.WriteLine("added jelly"); } else if (obj.Name.ToLower() == "pufferfish") { Vector2 position = new Vector2(obj.X, obj.Y); float speed = float.Parse(obj.GetProperty("speed")); PufferFish p = new PufferFish(this, tilemapTexture, position, 32, 32, obj.Width, speed); p.Animations.CurrentFrame = new Frame(0, 112, 32, 32); enemies.Add(p); Karma.maxKarma = Karma.DefineMaxKarma(Karma.maxKarma, p.Health); Console.WriteLine("added puffer"); } else if (obj.Name.ToLower() == "turtlex") { Vector2 position = new Vector2(obj.X, obj.Y); float speed = float.Parse(obj.GetProperty("speed")); TurtleX p = new TurtleX(this, tilemapTexture, position, 32, 32, 64, obj.Width, speed); p.Animations.CurrentFrame = new Frame(96, 112, 32, 32); enemies.Add(p); Karma.maxKarma = Karma.DefineMaxKarma(Karma.maxKarma, p.Health); Console.WriteLine("added turtlex"); } else if (obj.Name.ToLower() == "goldfish") { goldenFishs.Add(new GoldFish(this, tilemapTexture, new Vector2(obj.X, obj.Y), 16, 16)); } else if (obj.Name.ToLower() == "particles") { ParticleEmitter particleEmitter = new ParticleEmitter(this, obj.X, obj.Y, 256); particleEmitter.EmitterBox.Resize(obj.Width, obj.Height); particleEmitter.MakeParticles(tilemapTexture, 16, 16); particleEmitter.ParticleVelocity = new Vector2(0, -0.01f); particleEmitter.SetAcceleration(0, -0.005f); particleEmitter.XVelocityVariationRange = new Vector2(-20f, 20f); particleEmitter.YVelocityVariationRange = new Vector2(-20f, 0f); particleEmitter.SetTextureCropRectangle(new Rectangle(3 * 16, 6 * 16, 16, 16)); particleEmitter.SpawnRate = 250f; particleEmitter.ParticleLifespanMilliseconds = 5000f; particleEmitter.ParticleLifespanVariationMilliseconds = 1000f; particleEmitter.InitialScale = 0.1f; particleEmitter.FinalScale = 1.5f; particleEmitter.ForEachParticle(ChangeSpriteTintBlue); backgroundParticles.Add(particleEmitter); Console.WriteLine("added particles"); } else if (obj.Name.ToLower() == "player_spawn") { player.Body.X = obj.X; player.Body.Y = obj.Y; } else if (obj.Name.ToLower() == "change_state_trigger") { triggers.Add(new Trigger(obj.X, obj.Y, obj.Width, obj.Height, obj.GetProperty("value"))); } } // build spikes tiles list spikesPointingDown = level.GetTilesListByID(new int[] { 97 }); spikesPointingUp = level.GetTilesListByID(new int[] { 98 }); foreach (Tile spike in spikesPointingDown) { spike.Body.SetSize(12, 6, 2, 0); } foreach (Tile spike in spikesPointingUp) { spike.Body.SetSize(12, 6, 2, 10); } topWaterTiles = level.GetTilesListByID(new int[] { 49, 50, 51 }); /* * UI Elements init */ energyBar = new EnergyBar(Graphics, new Vector2(16, 32 + 4), 64, 8, new Color(255, 0, 0)); Karma.karma = Karma.maxKarma; /* * Build Background Gradient */ backgroundWaterGradientStrip = new Texture2D(Graphics.GraphicsDevice, 1, level.Height * level.TileHeight); Color startColor = new Color(57, 92, 181); Color finishColor = new Color(17, 43, 104); Color currentColor; for (int i = 0; i < backgroundWaterGradientStrip.Height; i++) { float ratio = Math2.Map(i, 0f, backgroundWaterGradientStrip.Height, 0f, 1.0f); currentColor = Color.Lerp(startColor, finishColor, ratio); DrawMe.Pixel(backgroundWaterGradientStrip, 0, i, currentColor); } /* * Build Background Gradient */ backgroundSkyGradientStrip = new Texture2D(Graphics.GraphicsDevice, 1, Graphics.PreferredBackBufferHeight / 2); startColor = new Color(61, 28, 111); finishColor = new Color(158, 98, 123); for (int i = 0; i < backgroundSkyGradientStrip.Height; i++) { float ratio = Math2.Map(i, 0f, backgroundSkyGradientStrip.Height, 0f, 1.0f); currentColor = Color.Lerp(startColor, finishColor, ratio); DrawMe.Pixel(backgroundSkyGradientStrip, 0, i, currentColor); } ContentLoaded = true; }
public override void LoadContent() { base.LoadContent(); MediaPlayer.Stop(); camera = new Camera2D(Vector2.Zero); camera.Zoom = 2.45f; font = content.Load <SpriteFont>("Font"); tilemapTexture = this.content.Load <Texture2D>("SpriteSheetDraft"); /* * A single pixel to draw lines and stuff */ pixel = new Texture2D(Graphics.GraphicsDevice, 1, 1); DrawMe.Fill(pixel, Color.White); /* * Player init */ player = new Player(Graphics, tilemapTexture, Vector2.Zero, 32, 32, true); player.TextureBoundingRect = new Rectangle(96, 0, 32, 32); player.Body.X = 16 * 3; player.Body.Y = 16 * 3; player.Body.MaxVelocity = 3f; player.Body.Drag.X = 0.6f; player.Body.Enabled = true; player.Body.Tag = "player"; player.Body.SetSize(16, 29, 9, 2); /* * Enemies */ enemies.Add(new PufferFish(Graphics, tilemapTexture, new Vector2(149 * 16, 11 * 16), 32, 32, 174 * 16 - 149 * 16, 1.5f)); enemies.Add(new PufferFish(Graphics, tilemapTexture, new Vector2(150 * 16, 2 * 16), 32, 32, 174 * 16 - 150 * 16, 1.5f)); enemies.Add(new PufferFish(Graphics, tilemapTexture, new Vector2(191 * 16, 2 * 16), 32, 32, 210 * 16 - 191 * 16, 1.5f)); enemies.Add(new PufferFish(Graphics, tilemapTexture, new Vector2(181 * 16, 11 * 16), 32, 32, 210 * 16 - 181 * 16, 1.5f)); enemies.Add(new PufferFish(Graphics, tilemapTexture, new Vector2(219 * 16, 5 * 16), 32, 32, 235 * 16 - 219 * 16, 1.5f)); enemies.Add(new JellyFish(Graphics, tilemapTexture, Vector2.Zero, 16, 32, new Vector2(60 * 16, 6 * 16), new Vector2(4 * 16, 4 * 16), 0.5f)); enemies.Add(new JellyFish(Graphics, tilemapTexture, Vector2.Zero, 16, 32, new Vector2(120 * 16, 6 * 16), new Vector2(10 * 16, 5 * 16), 0.5f)); /* * Level init */ XMLLevelLoader XMLloader = new XMLLevelLoader(); level = XMLloader.LoadLevel(@"Content\prototipo.tmx", tilemapTexture); level.SetCollisionTiles(new int[] { 1, 2, 4, 6 }); // build spikes tiles list spikesPointingDown = level.GetTilesListByID(new int[] { 3 }); spikesPointingUp = level.GetTilesListByID(new int[] { 5 }); foreach (Tile spike in spikesPointingDown) { spike.Body.SetSize(12, 6, 2, 0); } foreach (Tile spike in spikesPointingUp) { spike.Body.SetSize(12, 6, 2, 10); } /* * UI Elements init */ healthBar = new EnergyBar(Graphics, new Vector2(16, 16), 256, 16, new Color(0, 255, 0)); energyBar = new EnergyBar(Graphics, new Vector2(16, 32 + 4), 256, 16, new Color(255, 0, 0)); /* * Build Background Gradient */ backgroundGradientStrip = new Texture2D(Graphics.GraphicsDevice, 1, level.Height * level.TileHeight); Color startColor = new Color(57, 92, 181); Color finishColor = new Color(17, 43, 104); Color currentColor; for (int i = 0; i < backgroundGradientStrip.Height; i++) { float ratio = Math2.Map(i, 0f, backgroundGradientStrip.Height, 0f, 1.0f); currentColor = Color.Lerp(startColor, finishColor, ratio); DrawMe.Pixel(backgroundGradientStrip, 0, i, currentColor); } ContentLoaded = true; }
public override void LoadContent() { base.LoadContent(); MediaPlayer.Stop(); camera = new Camera2D(Vector2.Zero); camera.Zoom = 4.85f; font = content.Load <SpriteFont>("Font"); tilemapTexture = this.content.Load <Texture2D>("SpriteSheetDraft"); /* * A single pixel to draw lines and stuff */ pixel = new Texture2D(Graphics.GraphicsDevice, 1, 1); DrawMe.Fill(pixel, Color.White); /* * Player init */ player = new Player(this, tilemapTexture, Vector2.Zero, 32, 32, true); player.Animations.CurrentFrame = new Frame(96, 0, 32, 32); player.Body.X = 16 * 3; /*330*/ //spawn x player.Body.Y = 16 * 3; //spawn y player.Body.MaxVelocity = 3f; player.Body.Drag.X = 0.7f; player.Body.Enabled = true; player.Body.Tag = "player"; player.Body.SetSize(11, 27, 10, 2); /* * Enemies */ enemies.Add(new TurtleX(this, tilemapTexture, new Vector2(20 * 16, 8 * 16), 32, 32, 5 * 16, 174 * 16 - 149 * 16, 1.5f)); pufferFish.Add(new PufferFish(this, tilemapTexture, new Vector2(149 * 16, 11 * 16), 32, 32, 174 * 16 - 149 * 16, 1.5f)); pufferFish.Add(new PufferFish(this, tilemapTexture, new Vector2(150 * 16, 2 * 16), 32, 32, 174 * 16 - 150 * 16, 1.5f)); pufferFish.Add(new PufferFish(this, tilemapTexture, new Vector2(191 * 16, 2 * 16), 32, 32, 210 * 16 - 191 * 16, 1.5f)); pufferFish.Add(new PufferFish(this, tilemapTexture, new Vector2(181 * 16, 11 * 16), 32, 32, 210 * 16 - 181 * 16, 1.5f)); pufferFish.Add(new PufferFish(this, tilemapTexture, new Vector2(219 * 16, 5 * 16), 32, 32, 235 * 16 - 219 * 16, 1.5f)); enemies.Add(new JellyFish(this, tilemapTexture, Vector2.Zero, 16, 32, new Vector2(60 * 16, 6 * 16), new Vector2(4 * 16, 4 * 16), 0.5f)); enemies.Add(new JellyFish(this, tilemapTexture, Vector2.Zero, 16, 32, new Vector2(120 * 16, 6 * 16), new Vector2(10 * 16, 5 * 16), 0.5f)); /* * Level init */ XMLLevelLoader XMLloader = new XMLLevelLoader(); level = XMLloader.LoadLevel(this, @"Content\prototipo.tmx", tilemapTexture); level.SetCollisionTiles(new int[] { 1, 2, 4, 6 }); /* * Enemies Init tiled */ foreach (TiledObject obj in level.Objects) { if (obj.Name.ToLower() == "jellyfish") { Vector2 center = new Vector2(obj.X + obj.Width / 2, obj.Y + obj.Height / 2); Vector2 radius = new Vector2(obj.Width / 2, obj.Height / 2); float speed = float.Parse(obj.GetProperty("speed")); JellyFish j = new JellyFish(this, tilemapTexture, Vector2.Zero, 16, 32, center, radius, speed); j.TextureBoundingRect = new Rectangle(192, 0, 16, 32); enemies.Add(j); Console.WriteLine("added jelly"); } else if (obj.Name.ToLower() == "pufferfish") { Vector2 position = new Vector2(obj.X, obj.Y); float speed = float.Parse(obj.GetProperty("speed")); int walkingDirection = int.Parse(obj.GetProperty("direction")); PufferFish p = new PufferFish(this, tilemapTexture, position, 32, 32, obj.Width, speed); //if (walkingDirection == 1) //{ // p.Body.X += obj.Width; // p.CurrentDistance = obj.Width; // p.FacingDirection = -1; //} p.TextureBoundingRect = new Rectangle(9 * 16, 0, 32, 32); enemies.Add(p); Console.WriteLine("added puffer"); } } // // build spikes tiles list spikesPointingDown = level.GetTilesListByID(new int[] { 3 }); spikesPointingUp = level.GetTilesListByID(new int[] { 5 }); //spikesPointingRight = level.GetTilesListByID(new int[] { 35 }); lvl2 foreach (Tile spike in spikesPointingDown) { spike.Body.SetSize(5, 6, 6, 0); } foreach (Tile spike in spikesPointingUp) { spike.Body.SetSize(5, 6, 6, 10); } //foreach (Tile spike in spikesPointingRight) //{ // spike.Body.SetSize(6, 12, 0, 2); dar tweaks ao offset //} /* * UI Elements init */ healthBar = new EnergyBar(Graphics, new Vector2(16, 16), 256, 16, new Color(0, 255, 0)); energyBar = new EnergyBar(Graphics, new Vector2(16, 32 + 4), 256, 16, new Color(255, 0, 0)); /* * Build Background Gradient */ backgroundGradientStrip = new Texture2D(Graphics.GraphicsDevice, 1, level.Height * level.TileHeight); Color startColor = new Color(57, 92, 181); Color finishColor = new Color(17, 43, 104); Color currentColor; for (int i = 0; i < backgroundGradientStrip.Height; i++) { float ratio = Math2.Map(i, 0f, backgroundGradientStrip.Height, 0f, 1.0f); currentColor = Color.Lerp(startColor, finishColor, ratio); DrawMe.Pixel(backgroundGradientStrip, 0, i, currentColor); } ContentLoaded = true; }
public override void LoadContent() { base.LoadContent(); camera = new Camera2D(Vector2.Zero); camera.Zoom = (float)Graphics.PreferredBackBufferHeight * 2.45f / 600f; // the ideal zoom is 2.45 at 600px of screen height font = content.Load <SpriteFont>("Font"); tilemapTexture = this.content.Load <Texture2D>("SpriteSheet"); MediaPlayer.Volume = 0.3f; MediaPlayer.Play(Globals.LevelSong); MediaPlayer.IsRepeating = true; /* * A single pixel to draw lines and stuff */ pixel = new Texture2D(Graphics.GraphicsDevice, 1, 1); DrawMe.Fill(pixel, Color.White); /* * Load sfx */ SFX.Add("bubble", content.Load <SoundEffect>("sfx_bubble")); SFX.Add("bubble_noise_single", content.Load <SoundEffect>("BubbleNoisesSingle")); SFX.Add("anchor", content.Load <SoundEffect>("Anchor3")); SFX.Add("fall", content.Load <SoundEffect>("Falling")); SFX.Add("enemyDeath", content.Load <SoundEffect>("EnemyDeath")); SFX.Add("goldenFish", content.Load <SoundEffect>("GoldenFish2")); SFX.Add("energyWarning", content.Load <SoundEffect>("EnergyEmpty")); //done SFX.Add("turtleExplosion", content.Load <SoundEffect>("TurtleExplosion")); //done SFX.Add("playerHurt", content.Load <SoundEffect>("Player hurt")); //done SFX.Add("playerDeath", content.Load <SoundEffect>("Player Death3")); //done faltar esperar uns segundos antes de fazer reload de state /* * Player init */ player = new Player(this, tilemapTexture, Vector2.Zero, 32, 32, true); /* * Level init */ XMLLevelLoader XMLloader = new XMLLevelLoader(); // se o load do mapa falhar, well shit. vai para o menu. try { level = XMLloader.LoadLevel(this, @"Content\" + Globals.CurrentLevel + ".tmx", tilemapTexture); } catch (Exception e) { Console.WriteLine("Error Loading Map. Error message: " + e.Message); StateManager.Instance.StartGameState("MenuState"); } level.SetCollisionTiles(new int[] { 2, 33, 34, 35, 47, 66, 15, 79 }); /* * parse objects */ foreach (TiledObject obj in level.Objects) { Console.WriteLine("parsing " + obj.Name); if (obj.Name.ToLower() == "jellyfish") { Vector2 center = new Vector2(obj.X + obj.Width / 2, obj.Y + obj.Height / 2); Vector2 radius = new Vector2(obj.Width / 2, obj.Height / 2); float speed = float.Parse(obj.GetProperty("speed")); JellyFish j = new JellyFish(this, tilemapTexture, Vector2.Zero, 16, 32, center, radius, speed); Karma.maxKarma += j.Health; // make it start on the right side of its path if (obj.GetProperty("start_rotation") == "right") { j.FacingDirection = 1; } else { j.FacingDirection = -1; } Console.WriteLine(obj.GetProperty("start_rotation")); enemies.Add(j); } else if (obj.Name.ToLower() == "pufferfish") { Vector2 position = new Vector2(obj.X, obj.Y); float speed = float.Parse(obj.GetProperty("speed")); PufferFish p = new PufferFish(this, tilemapTexture, position, 32, 32, obj.Width, speed); Karma.maxKarma += p.Health; // make it start on the right side of its path if (obj.GetProperty("start_side") == "right") { p.Body.X = obj.X + obj.Width; p.CurrentDistance = obj.Width - 33; } enemies.Add(p); } else if (obj.Name.ToLower() == "turtlex") { Vector2 position = new Vector2(obj.X, obj.Y); float speed = float.Parse(obj.GetProperty("speed")); TurtleX p = new TurtleX(this, tilemapTexture, position, 32, 32, 64, obj.Width, speed); p.Animations.CurrentFrame = new Frame(96, 112, 32, 32); Karma.maxKarma += p.Health; // make it start on the right side of its path if (obj.GetProperty("start_side") == "right") { p.Body.X = obj.X + obj.Width; p.CurrentDistance = obj.Width - 33; } enemies.Add(p); } else if (obj.Name.ToLower() == "goldfish") { goldenFishs.Add(new GoldFish(this, tilemapTexture, new Vector2(obj.X, obj.Y), 16, 16)); } else if (obj.Name.ToLower() == "particles") { if (obj.GetProperty("type") == "dark_ambient") { ParticleEmitter particleEmitter = new ParticleEmitter(this, obj.X, obj.Y, 256); particleEmitter.EmitterBox.Resize(obj.Width, obj.Height); particleEmitter.MakeRandomParticles(tilemapTexture, new Rectangle[] { new Rectangle(128, 257, 3, 3), new Rectangle(132, 257, 3, 3), new Rectangle(136, 257, 3, 3) }); particleEmitter.ParticleVelocity = new Vector2(0, 0); particleEmitter.SetAcceleration(0, 0); particleEmitter.XVelocityVariationRange = new Vector2(-20f, 20f); particleEmitter.YVelocityVariationRange = new Vector2(-20f, 20f); particleEmitter.SpawnRate = 100f; particleEmitter.ParticleLifespanMilliseconds = 5000f; particleEmitter.ParticleLifespanVariationMilliseconds = 1000f; particleEmitter.InitialScale = 1.5f; particleEmitter.FinalScale = 0.5f; backgroundParticles.Add(particleEmitter); } else { ParticleEmitter particleEmitter = new ParticleEmitter(this, obj.X, obj.Y, 256); particleEmitter.EmitterBox.Resize(obj.Width, obj.Height); particleEmitter.MakeParticles(tilemapTexture, 16, 16); particleEmitter.ParticleVelocity = new Vector2(0, -0.01f); particleEmitter.SetAcceleration(0, -0.005f); particleEmitter.XVelocityVariationRange = new Vector2(-20f, 20f); particleEmitter.YVelocityVariationRange = new Vector2(-20f, 0f); particleEmitter.SetTextureCropRectangle(new Rectangle(0, 78, 16, 16)); particleEmitter.SpawnRate = 250f; particleEmitter.ParticleLifespanMilliseconds = 5000f; particleEmitter.ParticleLifespanVariationMilliseconds = 1000f; particleEmitter.InitialScale = 0.1f; particleEmitter.FinalScale = 1.5f; particleEmitter.ForEachParticle(ChangeSpriteTintBlue); backgroundParticles.Add(particleEmitter); } } else if (obj.Name.ToLower() == "player_spawn") { player.Body.X = obj.X; player.Body.Y = obj.Y; } else if (obj.Name.ToLower() == "change_state_trigger") { triggers.Add(new Trigger(obj.X, obj.Y, obj.Width, obj.Height, obj.GetProperty("value"))); } else if (obj.Name.ToLower() == "speedbox") { SpeedBox s = new SpeedBox(obj.X, obj.Y, obj.Width, obj.Height, float.Parse(obj.GetProperty("speedX")), float.Parse(obj.GetProperty("speedY"))); ParticleEmitter particleEmitter = new ParticleEmitter(this, obj.X, obj.Y, 512); particleEmitter.EmitterBox.Resize(obj.Width, obj.Height); particleEmitter.MakeRandomParticles(tilemapTexture, new Rectangle[] { new Rectangle(128, 257, 3, 3), new Rectangle(132, 257, 3, 3), new Rectangle(136, 257, 3, 3), new Rectangle(128 - 16, 257, 3, 3), new Rectangle(132 - 16, 257, 3, 3), new Rectangle(136 - 16, 257, 3, 3) }); particleEmitter.ParticleVelocity = new Vector2(s.SpeedIncrease.X * 10, s.SpeedIncrease.Y * 10); particleEmitter.XVelocityVariationRange = new Vector2(-20f, 20f); particleEmitter.YVelocityVariationRange = new Vector2(-20f, 20f); particleEmitter.SpawnRate = 60f; particleEmitter.ParticleLifespanMilliseconds = 5000f; particleEmitter.ParticleLifespanVariationMilliseconds = 1000f; particleEmitter.InitialScale = 1.0f; particleEmitter.FinalScale = 0.5f; backgroundParticles.Add(particleEmitter); speedBoxes.Add(s); } Console.WriteLine("added " + obj.Name); } // build spikes tiles list spikesPointingDown = level.GetTilesListByID(new int[] { 514 }); spikesPointingUp = level.GetTilesListByID(new int[] { 515 }); spikesPointingLeft = level.GetTilesListByID(new int[] { 516 }); spikesPointingRight = level.GetTilesListByID(new int[] { 517 }); foreach (Tile spike in spikesPointingDown) { spike.Body.SetSize(12, 6, 1, 0); } foreach (Tile spike in spikesPointingUp) { spike.Body.SetSize(12, 6, 2, 10); } foreach (Tile spike in spikesPointingLeft) { spike.Body.SetSize(6, 12, 10, 2); } foreach (Tile spike in spikesPointingRight) { spike.Body.SetSize(6, 12, 0, 2); } topWaterTiles = level.GetTilesListByID(new int[] { 97, 98, 99 }); /* * UI Elements init */ //healthBar = new EnergyBar(Graphics, new Vector2(16, 16), 256, 16, new Color(0, 255, 0)); energyBar = new EnergyBar(Graphics, new Vector2(16 + 6, 16 + 25), 16 * 10 - 9, 16, new Color(255, 0, 0)); //16+2, 16 + 8, 16*10, 32+16 Karma.karma = Karma.maxKarma; Karma.maxCollectables = goldenFishs.Count; /* * Build Background Gradient */ backgroundWaterGradientStrip = new Texture2D(Graphics.GraphicsDevice, 1, level.Height * level.TileHeight); Color startColor = new Color(57, 92, 181); Color finishColor = new Color(17, 43, 104); Color currentColor; for (int i = 0; i < backgroundWaterGradientStrip.Height; i++) { float ratio = Math2.Map(i, 0f, backgroundWaterGradientStrip.Height, 0f, 1.0f); currentColor = Color.Lerp(startColor, finishColor, ratio); DrawMe.Pixel(backgroundWaterGradientStrip, 0, i, currentColor); } /* * Build Background Gradient */ backgroundSkyGradientStrip = new Texture2D(Graphics.GraphicsDevice, 1, Graphics.PreferredBackBufferHeight / 2); startColor = new Color(61, 28, 111); finishColor = new Color(158, 98, 123); for (int i = 0; i < backgroundSkyGradientStrip.Height; i++) { float ratio = Math2.Map(i, 0f, backgroundSkyGradientStrip.Height, 0f, 1.0f); currentColor = Color.Lerp(startColor, finishColor, ratio); DrawMe.Pixel(backgroundSkyGradientStrip, 0, i, currentColor); } ContentLoaded = true; }