public Consumable(int x, int y, int speed, Type type, GameManager gameManager) { visionDelayTime = 1000; visionTimer = 0; Destroyed = true; switch (type) { case Type.Health: { imgConsumable = gameManager.gameContent.imgPlusFruit; Health = true; Visible = false; Points = false; break; } case Type.AddPoints: { imgConsumable = gameManager.gameContent.imgFireFly; Points = true; Health = false; Visible = true; numPoints = 50; break; } case Type.MinusPoints: { //imgConsumable = gameContent.imgMinusFruit; //Points = true; //numPoints = -10; break; } } rand = new Random(); this.player = gameManager.player; X = x; Y = y; this.speed = speed; minY = Y + 10; maxY = Y - 10; deltaY = maxY; this.scoreManager = gameManager.scoreManager; this.spriteBatch = gameManager.spriteBatch; consumableRect = new Rectangle((int)X, (int)Y, imgConsumable.Width / 2, imgConsumable.Height / 2); }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here gameContent = new GameContent(Content); screenWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width; screenHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; if (screenWidth >= 1275) { screenWidth = 1275; } if (screenHeight >= 725) { screenHeight = 725; } graphics.PreferredBackBufferWidth = screenWidth; graphics.PreferredBackBufferHeight = screenHeight; graphics.ApplyChanges(); player = new Player(200.0f, 100.0f, this); titleScreen = new TitleScreen(this); scoreManager = new Scoremanager(this); gameOverScreen = new EndingScreen(this); backGround = new RollingBackGround(); backGround.Load(spriteBatch, gameContent); MediaPlayer.Play(gameContent.songbg); MediaPlayer.MediaStateChanged += MediaPlayer_MediaStateChanged; //obstacle code!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! obstacleSpawner = new ObstacleSpawner(50, screenWidth, screenWidth - 100, screenHeight - 100, -200, 700, 200, 9, this); consumableSpawner = new ConsumableSpawner(20, screenWidth, screenWidth - 100, screenHeight - 50, 50, 750, 250, 5, this); soundEffects.Add(Content.Load <SoundEffect>("wings")); soundEffects.Add(Content.Load <SoundEffect>("hit01")); }