/// <summary> /// Load graphics, sounds content for the game. Create the level /// </summary> public override void Activate(bool instancePreserved) { if (!instancePreserved) { if (content == null) content = new ContentManager(ScreenManager.Game.Services, "Content"); // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(ScreenManager.GraphicsDevice); _renderContext.GameTime = new GameTime(); _renderContext.SpriteBatch = spriteBatch; _renderContext.GraphicsDevice = ScreenManager.GraphicsDevice; //Set up basic effect for drawing background _renderContext.BasicEffect = new BasicEffect(_renderContext.GraphicsDevice); // TODO: use this.Content to load your game content here //_models.Add("player", Content.Load<Model>("scientist")); _models.Add("BasicBlock", content.Load<Model>("BasicBlock")); _models.Add("BackgroundBlock", content.Load<Model>("BackgroundBlock")); _models.Add("button", content.Load<Model>("Button")); _models.Add("door", content.Load<Model>("Door")); _models.Add("switch", content.Load<Model>("ToggleSwitch")); _models.Add("MoveableBox", content.Load<Model>("MoveableBox")); _models.Add("BlockDropper", content.Load<Model>("BlockDropper")); _models.Add("BlockDropper_Empty", content.Load<Model>("BlockDropper_Empty")); _models.Add("block", content.Load<Model>("block")); _models.Add("Turret", content.Load<Model>("turret")); _models.Add("projectile", content.Load<Model>("projectile")); _models.Add("ExitBlock", content.Load<Model>("ExitBlock")); _models.Add("MovingBlock", content.Load<Model>("MovingBlock")); _textures.Add("MoveableBox", content.Load<Texture2D>("WoodPlanks_Color")); _textures.Add("BlockDropper", content.Load<Texture2D>("Textures/dropper")); // background textures _textures.Add("Pipes2", content.Load<Texture2D>("Textures/Pipes2")); _textures.Add("Pipes1", content.Load<Texture2D>("Textures/Pipes1")); _textures.Add("Vent", content.Load<Texture2D>("Textures/Vent")); _textures.Add("Tile_Black", content.Load<Texture2D>("Textures/Tile_Black")); _textures.Add("Tile_Gray", content.Load<Texture2D>("Textures/Tile_Gray")); _textures.Add("Emcsquare", content.Load<Texture2D>("Textures/Emcsquare")); _textures.Add("atom1", content.Load<Texture2D>("Textures/atom1")); _textures.Add("atom2", content.Load<Texture2D>("Textures/atom2")); _textures.Add("Tile_Gray_Stain", content.Load<Texture2D>("Textures/Tile_Gray_Stain")); _textures.Add("Tile_Gray_Stain1", content.Load<Texture2D>("Textures/Tile_Gray_Stain1")); _textures.Add("Tile_Gray_Stain2", content.Load<Texture2D>("Textures/Tile_Gray_Stain2")); _textures.Add("Tile_Gray_Stain3", content.Load<Texture2D>("Textures/Tile_Gray_Stain3")); _textures.Add("Einstien", content.Load<Texture2D>("Textures/Einstien")); _textures.Add("chalkboard1", content.Load<Texture2D>("Textures/chalkboard1")); _textures.Add("chalkboard2", content.Load<Texture2D>("Textures/chalkboard2")); _textures.Add("chalkboard3", content.Load<Texture2D>("Textures/chalkboard3")); _textures.Add("chalkboard4", content.Load<Texture2D>("Textures/chalkboard4")); _textures.Add("Tile_White", content.Load<Texture2D>("Textures/Tile_White")); _textures.Add("Tile_Fun", content.Load<Texture2D>("Textures/Tile_Fun")); _textures.Add("Exit", content.Load<Texture2D>("Textures/EXIT")); _textures.Add("Complete", content.Load<Texture2D>("Textures/Complete")); _textures.Add("GameOver", content.Load<Texture2D>("Textures/GameOver")); _textures.Add("Arrow", content.Load<Texture2D>("Textures/Arrow")); _textures.Add("A_Button", content.Load<Texture2D>("Textures/Controller/A_Button")); _textures.Add("B_Button", content.Load<Texture2D>("Textures/Controller/B_Button")); _textures.Add("X_Button", content.Load<Texture2D>("Textures/Controller/X_Button")); _textures.Add("Y_Button", content.Load<Texture2D>("Textures/Controller/Y_Button")); _textures.Add("Back_Button", content.Load<Texture2D>("Textures/Controller/Back_Button")); _textures.Add("Start_Button", content.Load<Texture2D>("Textures/Controller/Start_Button")); //_textures.Add("Left_Button", content.Load<Texture2D>("Textures/Controller/Left_Button")); _textures.Add("Right_Button", content.Load<Texture2D>("Textures/Controller/Right_Button")); _textures.Add("DPad", content.Load<Texture2D>("Textures/Controller/DPad")); _textures.Add("Left_DPad", content.Load<Texture2D>("Textures/Controller/Left_DPad")); _textures.Add("Right_DPad", content.Load<Texture2D>("Textures/Controller/Right_DPad")); _textures.Add("Up_DPad", content.Load<Texture2D>("Textures/Controller/Up_DPad")); _textures.Add("Down_DPad", content.Load<Texture2D>("Textures/Controller/Down_DPad")); _textures.Add("UpDown_DPad", content.Load<Texture2D>("Textures/Controller/UpDown_DPad")); _textures.Add("LeftRight_DPad", content.Load<Texture2D>("Textures/Controller/LeftRight_DPad")); _textures.Add("Left_Stick", content.Load<Texture2D>("Textures/Controller/Left_Stick")); _textures.Add("Right_Stick", content.Load<Texture2D>("Textures/Controller/Right_Stick")); _textures.Add("Right_Trigger", content.Load<Texture2D>("Textures/Controller/Right_Trigger")); _textures.Add("LeftRight_Trigger", content.Load<Texture2D>("Textures/Controller/LeftRight_Trigger")); _textures.Add("Gear", content.Load<Texture2D>("Textures/UI/GearTest")); _textures.Add("LaserRed", content.Load<Texture2D>("Textures/UI/LaserRed")); _textures.Add("LaserOrange", content.Load<Texture2D>("Textures/UI/LaserOrange")); _textures.Add("LaserGreen", content.Load<Texture2D>("Textures/UI/LaserGreen")); _textures.Add("LightGreen", content.Load<Texture2D>("Textures/UI/LightBulbGreen")); _textures.Add("LightYellow", content.Load<Texture2D>("Textures/UI/LightBulbYellow")); _textures.Add("LightRed", content.Load<Texture2D>("Textures/UI/LightBulbRed")); _textures.Add("Gear2", content.Load<Texture2D>("Textures/UI/GearTestV2")); _textures.Add("GearHealthBar", content.Load<Texture2D>("Textures/UI/HealthBar")); _textures.Add("MessageBackground", content.Load<Texture2D>("Textures/message_background")); _textures.Add("PlayerPortrait", content.Load<Texture2D>("Textures/UI/PlayerPortrait")); //// _textures.Add("Explosion", content.Load<Texture2D>("Texture/explosion")); _renderContext.Textures = _textures; //Loads sound references _sounds.Add("BoxDrop", content.Load<SoundEffect>("Sounds/BoxDrop")); _sounds.Add("BoxPickup", content.Load<SoundEffect>("Sounds/BoxPickup")); _sounds.Add("Button", content.Load<SoundEffect>("Sounds/Button")); _sounds.Add("DoombaLoop", content.Load<SoundEffect>("Sounds/DoombaLoop")); _sounds.Add("Jump", content.Load<SoundEffect>("Sounds/Jump")); _sounds.Add("Land", content.Load<SoundEffect>("Sounds/Land")); _sounds.Add("LaserShoot", content.Load<SoundEffect>("Sounds/LaserShoot")); _sounds.Add("LaserWhirLoop", content.Load<SoundEffect>("Sounds/LaserWhirLoop")); _sounds.Add("PlayerHit", content.Load<SoundEffect>("Sounds/PlayerHit")); _sounds.Add("ToggleSwitch", content.Load<SoundEffect>("Sounds/ToggleSwitch")); _sounds.Add("Type", content.Load<SoundEffect>("Sounds/Type")); _renderContext.Sounds = _sounds; // Loading shaders healthState = content.Load<Effect>("Shaders/HealthPixel"); //loads the basic level basicLevel = LevelBuilder.MakeBasicLevel(levelData.currentlevelNum, _renderContext); basicLevel.setBackgroundBuffer(_renderContext); //Matt: need to do this now to draw background properly CurrentLevel = basicLevel; //we can handle this through render context eventually. basicLevel.LoadContent(content); player = new Character(basicLevel.PlayerPoint.X, basicLevel.PlayerPoint.Y); player.LoadContent(content); _renderContext.Player = player; _camera.setFollowTarget(player); player.TransAccel = new Vector3(0, -GameConstants.SINGLE_CELL_SIZE * 9, 0); font = content.Load<SpriteFont>("Verdana"); _renderContext.Level = basicLevel; _renderContext.SpriteFont = font; _renderContext.MessageFont = content.Load<SpriteFont>("MessageFont"); basicLevel.PopulateTypeList(_renderContext); _renderContext.Level.collidableObjects.Add(player); // Adding player to list of collidable objects - Steven // Single color texture for minimap rendering dummyTexture = new Texture2D(_renderContext.GraphicsDevice, 1, 1); dummyTexture.SetData(new Color[] { Color.White * 0.8f}); _timer = new GameTimer(_renderContext); _renderContext.GameTimer = _timer; //load fps count content fpsCount.LoadContent(content); //load music levelMusic = content.Load<SoundEffect>("Songs/MusicInGameLoop"); MusicPlayer.SetVolume(1f); MusicPlayer.PlaySong(levelMusic); Quadtree _quadtree = new Quadtree(0, _renderContext.Level.Hitbox); _renderContext.Quadtree = _quadtree; // if game takes long to load. Simulate load by delaying for a // while, giving you a chance to admire the beautiful loading screen. Thread.Sleep(500); // once the load has finished, we use ResetElapsedTime to tell the game's // timing mechanism that we have just finished a very long frame, and that // it should not try to catch up. ScreenManager.Game.ResetElapsedTime(); } }
/* * Splits the node into 4 subnodes */ private void split() { int subWidth = (int)(bounds.Width / 2); int subHeight = (int)(bounds.Height / 2); int x = (int)bounds.X; int y = (int)bounds.Y; nodes[0] = new Quadtree(level+1, new Rectangle(x + subWidth, y, subWidth, subHeight)); nodes[1] = new Quadtree(level+1, new Rectangle(x, y, subWidth, subHeight)); nodes[2] = new Quadtree(level+1, new Rectangle(x, y + subHeight, subWidth, subHeight)); nodes[3] = new Quadtree(level+1, new Rectangle(x + subWidth, y + subHeight, subWidth, subHeight)); }