public ObjectPool(Game1 game) { this.game = game; _instance = this; _pool = new List <GameObject>(); _platforms = new List <GameObject>(); _porings = new List <NPC>(); rng = new Random(); //Systema para gerar uma seed random no começo do jogo for (_height = 3; _height <= 21; _height = _height + 3) { _random = rng.Next(0, 10); if (_random >= 5) //platform big { float Xpos = rng.Next(3, 7); PlatformBig plat = new PlatformBig(game, new Vector2(Xpos, _height)); Body aux = plat.Body; _platforms.Add(plat); _random = rng.Next(0, 10); if (_random >= 5) // Spawn spikes { float posY = _height - 0.5f; SpikesBig sB = new SpikesBig(game, new Vector2(Xpos, posY)); _platforms.Add(sB); Fixture spikes = FixtureFactory.AttachRectangle(sB._size.X, sB._size.Y * 0.1f, 1, new Vector2(0, 0.15f), sB.Body); } _random = rng.Next(0, 10); if (_random >= 5) // Spawn poring { float posY = _height + 0.7f; NPC npc = new NPC(game, new Vector2(Xpos, posY)); _porings.Add(npc); } } else { //platform small float Xpos = rng.Next(3, 7); PlatformSmall plat = new PlatformSmall(game, new Vector2(Xpos, _height)); Body aux = plat.Body; _platforms.Add(plat); _random = rng.Next(0, 10); if (_random >= 5) // Spawn spikes { float posY = _height - 0.5f; SpikesSmall sB = new SpikesSmall(game, new Vector2(Xpos, posY)); _platforms.Add(sB); Fixture spikes = FixtureFactory.AttachRectangle(sB._size.X, sB._size.Y * 0.2f, 1, new Vector2(0, 0.15f), sB.Body); } } } heightaux = 1.5f; }
public void SpawnPlatforms(GameTime gametime) { while (_height < Camera.Target.Y + 11f) { _random = rng.Next(0, 10); if (_random >= 5) //platform big { float Xpos = rng.Next(3, 7); PlatformBig plat = new PlatformBig(game, new Vector2(Xpos, _height)); Body aux = plat.Body; _platforms.Add(plat); _random = rng.Next(0, 10); if (_random >= 5) // Spawn spikes { float posY = _height - 0.5f; SpikesBig sB = new SpikesBig(game, new Vector2(Xpos, posY)); _platforms.Add(sB); Fixture spikes = FixtureFactory.AttachRectangle(sB._size.X, sB._size.Y * 0.1f, 1, new Vector2(0, 0.15f), sB.Body); } if (_random >= 5) // Spawn poring { float posY = _height + 0.7f; NPC npc = new NPC(game, new Vector2(Xpos, posY)); _porings.Add(npc); } } else { //platform small float Xpos = rng.Next(3, 7); PlatformSmall plat = new PlatformSmall(game, new Vector2(Xpos, _height)); Body aux = plat.Body; _platforms.Add(plat); _random = rng.Next(0, 10); if (_random >= 5) // Spawn spikes { float posY = _height - 0.5f; SpikesSmall sB = new SpikesSmall(game, new Vector2(Xpos, posY)); _platforms.Add(sB); Fixture spikes = FixtureFactory.AttachRectangle(sB._size.X, sB._size.Y * 0.2f, 1, new Vector2(0, 0.15f), sB.Body); } } _height = _height + 3; } }