public Debris(Hero hero, List<Enemy> enemies, float minX, float maxX) { float padding = size; float randomX = XNACS1Base.RandomFloat(minX + padding, maxX - padding); float randomY = XNACS1Base.RandomFloat(GameWorld.bottomEdge + padding, GameWorld.topEdge - padding); texture = new XNACS1Rectangle(new Vector2(randomX, randomY), size, size); switch (XNACS1Base.RandomInt(3)) { case 0: texture.Texture = "Beak"; break; case 1: texture.Texture = "Window"; break; case 2: texture.Texture = "Wing2"; texture.Width = texture.Height * 1.8f; break; } obstacle = new Obstacle(hero, enemies, texture.Center, texture.Width * .9f, texture.Height * .9f); }
private void fillPlatform(int offset, float leftEdge, bool continuous) { // set up platform float Ypos = ((offset * 1f) / Stargate.GATE_COUNT) * GameWorld.topEdge; if (continuous) { float Xpos = leftEdge + (Stargate.width / 2); Obstacle obstacle = new Obstacle(hero, enemies, new Vector2(Xpos, Ypos), Stargate.width + mask, height); obstacles.Add(obstacle); } else { // randomly fill platform float width = Stargate.width / SEGMENT_COUNT; Obstacle obstacle; int consecutiveChance = 10; bool platform = true; for (int i = 0; i < SEGMENT_COUNT; i++) { if (platform) { float Xpos = (width * 0.5f) + leftEdge + (i * width); obstacle = new Obstacle(hero, enemies, new Vector2(Xpos, Ypos), width + mask, height); obstacles.Add(obstacle); } consecutiveChance -= 2; if (XNACS1Base.RandomInt(consecutiveChance) == 0) { platform = !platform; consecutiveChance = 10; } } } }
private void setBoundaries() { // determine the maximum horizontal boundary for the hero List<Enemy> emptyList = new List<Enemy>(); float width = (1 - rightBoundaryLimit) * GameWorld.rightEdge; float boundaryX = GameWorld.rightEdge - (width / 2); float boundaryY = GameWorld.topEdge / 2; Obstacle boundary = new Obstacle(this, emptyList, new Vector2(boundaryX, boundaryY), width, GameWorld.topEdge); boundaries.Add(boundary); // determine minumum vertical and horizontal, and maximum vertical boundaries for hero float screenCenterX = (GameWorld.rightEdge - GameWorld.leftEdge) / 2; float screenCenterY = (GameWorld.topEdge - GameWorld.bottomEdge) / 2; boundary = new Obstacle(this, emptyList, new Vector2(screenCenterX, GameWorld.bottomEdge - screenCenterY), screenCenterX * 2, screenCenterY * 2); boundaries.Add(boundary); boundary = new Obstacle(this, emptyList, new Vector2(screenCenterX, GameWorld.topEdge + screenCenterY), screenCenterX * 2, screenCenterY * 2); boundaries.Add(boundary); boundary = new Obstacle(this, emptyList, new Vector2(GameWorld.leftEdge - screenCenterX, screenCenterY), screenCenterX * 2, screenCenterY * 2); boundaries.Add(boundary); }