public void FireShot(Vector2 location, Vector2 velocity, bool playerFired) { Sprite thisShot = new Sprite(texture, location, initialFrame, velocity); thisShot.Velocity *= shotSpeed; for (int x = 1; x < frameCount; x++) { thisShot.AddFrame(new Rectangle(initialFrame.X + (initialFrame.Width * x), initialFrame.Y, initialFrame.Width, initialFrame.Height)); } thisShot.collisionRadius = collisionRadius; shots.Add(thisShot); if (playerFired) { // TODO: Add player shot sound FX } }
public void generateReward() { int checkLocation = rand.Next(0, hills.pixelCount); if (hills.HillsPixels[checkLocation].Location.X > 790.0f) { rewardType = rand.Next(0, 4); //rewardType = 2;//bd test switch (rewardType) { case 0: //generate a gold bar pile goldSprite = new Sprite( new Vector2(500, 400), texture, new Rectangle(0, goldBarSpriteOffset, goldBarFrameWidth, goldBarFrameHeight), Vector2.Zero); for (int x = 1; x < goldBarFrameCount; x++) { goldSprite.AddFrame( new Rectangle( goldBarFrameIndex + (goldBarFrameWidth * x), goldBarSpriteOffset, goldBarFrameWidth, goldBarFrameHeight)); } goldSprite.Scale = 0.5f; goldSprite.HillIndex = checkLocation; goldSprite.Location.X = hills.HillsPixels[goldSprite.HillIndex].Location.X - (goldBarFrameWidth / 2); goldSprite.Location.Y = hills.HillsPixels[goldSprite.HillIndex].Location.Y - (goldBarFrameHeight / 2) - 20.0f; goldSprite.Rotation = (float)Math.Atan(hills.getSlope((int)goldSprite.Location.X)); goldSprite.CollisionRadius = goldBarRadius; rewardsList.Add(goldSprite); break; case 1: //generate a battery power pod batterySprite = new Sprite( new Vector2(500, 400), texture, new Rectangle(0, batterySpriteOffset, batteryFrameWidth, batteryFrameHeight), Vector2.Zero); for (int x = 1; x < batteryFrameCount; x++) { batterySprite.AddFrame( new Rectangle( batteryFrameIndex + (batteryFrameWidth * x), batterySpriteOffset, batteryFrameWidth, batteryFrameHeight)); } batterySprite.Scale = 0.5f; batterySprite.HillIndex = checkLocation; batterySprite.Location.X = hills.HillsPixels[batterySprite.HillIndex].Location.X - (batteryFrameWidth / 2); batterySprite.Location.Y = hills.HillsPixels[batterySprite.HillIndex].Location.Y - (batteryFrameHeight / 2) - 20.0f; batterySprite.Rotation = (float)Math.Atan(hills.getSlope((int)batterySprite.Location.X)); batterySprite.CollisionRadius = batteryRadius; rewardsList.Add(batterySprite); break; case 2: //generate a saw sawSprite = new Sprite( new Vector2(0, 0), texture, new Rectangle(0, sawSpriteOffset, sawFrameWidth, sawFrameHeight), Vector2.Zero); for (int x = 1; x < sawFrameCount; x++) { sawSprite.AddFrame( new Rectangle( sawFrameIndex + (sawFrameWidth * x), sawSpriteOffset, sawFrameWidth, sawFrameHeight)); } sawSprite.Scale = 0.4f; sawSprite.HillIndex = checkLocation; sawSprite.Location.X = hills.HillsPixels[sawSprite.HillIndex].Location.X - (sawFrameWidth / 2); sawSprite.Location.Y = hills.HillsPixels[sawSprite.HillIndex].Location.Y - (sawFrameHeight / 2) - 20.0f; sawSprite.Rotation = (float)Math.Atan(hills.getSlope((int)sawSprite.Location.X)); sawSprite.CollisionRadius = sawRadius; rewardsList.Add(sawSprite); break; } } }