/// <summary> /// Load graphics content for the screen. /// </summary> public override void LoadContent() { m_manager = new GameObjectManager(); m_player = new Player(m_core.Content.Load<Model>("player/soldier2")); m_manager.AddEntity(m_player); man = new CollisionManager(); m_player.Manager = man; for (int i = 0; i < 10; i++) { Enemy e = new Enemy(m_core.Content.Load<Model>("player/zombie_bones")); SkinningData skinningData = e.Model.Tag as SkinningData; if (skinningData == null) throw new InvalidOperationException ("This model does not contain a SkinningData tag."); e.Anim = new AnimationPlayer(skinningData); AnimationClip clip = skinningData.AnimationClips["Animace"]; e.Anim.StartClip(clip); m_manager.AddEntity(e); } GameCore.Camera.Player = (Player)m_manager.GetObject("ZombieSmashGame.Entities.Player"); spriteBatch = new SpriteBatch(m_core.GraphicsDevice); font = m_core.Content.Load<SpriteFont>("gamefont"); }
/// <summary> /// Load graphics content for the screen. /// </summary> public override void LoadContent() { spriteBatch = new SpriteBatch(m_core.GraphicsDevice); m_player = new Player(); m_floor = new Floor(); m_enemy = new Enemy(); // m_building = new Building(); GameCore.Camera.Player = m_player; font = m_core.Content.Load<SpriteFont>("gamefont"); //m_player.Model = m_core.Content.Load<Model>("player/soldier2"); m_player.Model = m_core.Content.Load<Model>("player/vojak_anim"); m_floor.Model = m_core.Content.Load<Model>("other/model2"); //m_enemy.Model = m_core.Content.Load<Model>("player/zombie"); // m_building.Model = m_core.Content.Load<Model>("other/blok_1"); // Look up our custom skinning information. SkinningData skinningDataPlayer = m_player.Model.Tag as SkinningData; if (skinningDataPlayer == null) throw new InvalidOperationException ("This model does not contain a SkinningData tag."); m_player.Anim = new AnimationPlayer(skinningDataPlayer); AnimationClip clip = skinningDataPlayer.AnimationClips["Action"]; m_player.Anim.StartClip(clip); // Load the model. m_enemy.Model = m_core.Content.Load<Model>("player/zombie2_bones"); // Look up our custom skinning information. SkinningData skinningData = m_enemy.Model.Tag as SkinningData; if (skinningData == null) throw new InvalidOperationException ("This model does not contain a SkinningData tag."); // Create an animation player, and start decoding an animation clip. //animationPlayer = new AnimationPlayer(skinningData); m_enemy.Anim = new AnimationPlayer(skinningData); AnimationClip clip2 = skinningData.AnimationClips["Animace"]; m_enemy.Anim.StartClip(clip2); }
/// <summary> /// Render everything in the state /// </summary> public override void Render(GameTime gameTime) { m_core.GraphicsDevice.Clear(Color.BlanchedAlmond); if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.V) == true) { Enemy e = new Enemy(m_core.Content.Load<Model>("player/zombie_bones")); SkinningData skinningData = e.Model.Tag as SkinningData; if (skinningData == null) throw new InvalidOperationException ("This model does not contain a SkinningData tag."); e.Anim = new AnimationPlayer(skinningData); AnimationClip clip = skinningData.AnimationClips["Animace"]; e.Anim.StartClip(clip); m_manager.AddEntity(e); } if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.B) == true) { m_manager.RemoveObjects("ZombieSmashGame.Entities.Enemy"); } DepthStencilState state = new DepthStencilState(); state.DepthBufferEnable = true; m_core.GraphicsDevice.DepthStencilState = state; switch (GameCore.Camera.getCameraState()) { default: case 0: GameCore.Camera.UpdateCamera(m_core.GraphicsDevice.Viewport); break; case 1: GameCore.Camera.UpdateCameraFirstPerson(m_core.GraphicsDevice.Viewport); break; case 2: GameCore.Camera.UpdateCameraThirdPerson(m_core.GraphicsDevice.Viewport); break; } m_manager.Render(); state = null; state = new DepthStencilState(); state.DepthBufferEnable = false; m_core.GraphicsDevice.DepthStencilState = state; spriteBatch.Begin(); spriteBatch.DrawString(font, "V to add enemy", new Vector2(20, 45), Color.Red); spriteBatch.DrawString(font, "B to to remove all enemies", new Vector2(20, 65), Color.Red); spriteBatch.DrawString(font, "PlayerX: " + m_manager.GetObject("ZombieSmashGame.Entities.Player").Position.X, new Vector2(20, 85), Color.Red); spriteBatch.DrawString(font, "PlayerZ: " + m_manager.GetObject("ZombieSmashGame.Entities.Player").Position.Z, new Vector2(20, 105), Color.Red); spriteBatch.End(); }
/// <summary> /// Load graphics content for the screen. /// </summary> public override void LoadContent() { spriteBatch = new SpriteBatch(m_core.GraphicsDevice); m_player = new Player(); m_floor = new Floor(); m_enemy = new Enemy(); m_car = new Car(); m_tree = new Tree(); m_building1 = new Building(); m_building2 = new Building(); m_building3 = new Building(); m_building4 = new Building(); m_building5 = new Building(); m_building6 = new Building(); m_building7 = new Building(); m_building8 = new Building(); m_building9 = new Building(); m_building10 = new Building(); m_building11 = new Building(); m_building12 = new Building(); coll_manager = new CollisionManager(); m_block = new RoadBlock(); GameCore.Camera.Player = m_player; font = m_core.Content.Load<SpriteFont>("gamefont"); m_player.Model = m_core.Content.Load<Model>("player/soldier2"); m_floor.Model = m_core.Content.Load<Model>("other/model2"); m_enemy.Model = m_core.Content.Load<Model>("player/zombie"); m_car.Model = m_core.Content.Load<Model>("other/skoda"); m_tree.Model = m_core.Content.Load<Model>("other/strom"); m_block.Model = m_core.Content.Load<Model>("other/zataras"); m_building1.Model = m_core.Content.Load<Model>("other/budova_skola/blok_a"); m_building2.Model = m_core.Content.Load<Model>("other/budova_skola/blok_a"); m_building3.Model = m_core.Content.Load<Model>("other/budova_skola/blok_a"); m_building4.Model = m_core.Content.Load<Model>("other/budova_skola/blok_a"); m_building5.Model = m_core.Content.Load<Model>("other/budova_skola/blok_b"); m_building6.Model = m_core.Content.Load<Model>("other/budova_skola/blok_c"); m_building7.Model = m_core.Content.Load<Model>("other/budova_skola/blok_c"); m_building8.Model = m_core.Content.Load<Model>("other/budova_skola/blok_c"); m_building9.Model = m_core.Content.Load<Model>("other/budova_skola/blok_vchod_a"); m_building10.Model = m_core.Content.Load<Model>("other/budova_skola/blok_vchod_b"); m_building11.Model = m_core.Content.Load<Model>("other/budova_skola/blok_vchod_a"); m_building12.Model = m_core.Content.Load<Model>("other/budova_skola/blok_podstava"); m_car.Position = new Vector3(0, -6, -20); m_car.setBoundingBox(); coll_manager.AddEntity(m_car); m_block.Position = new Vector3(20, -6, -20); m_block.setBoundingBox(); coll_manager.AddEntity(m_block); m_tree.Position = new Vector3(20, 5, 0); m_tree.setBoundingBox(); coll_manager.AddEntity(m_tree); m_building1.Position = new Vector3(130, 4, 90); m_building2.Position = new Vector3(-30, 4, 90); m_building3.Position = new Vector3(-190, 4, 90); m_building4.Position = new Vector3(290, 4, 90); m_building5.Position = new Vector3(-200, 4, 100); m_building6.Position = new Vector3(-130, 4, 140); m_building7.Position = new Vector3(30, 4, 140); m_building8.Position = new Vector3(190, 4, 140); m_building9.Position = new Vector3(-130, 4, 80); m_building10.Position = new Vector3(30, 4, 80); m_building11.Position = new Vector3(190, 4, 80); m_building12.Position = new Vector3(250, -5, 30); m_building1.setBoundingBox(); m_building2.setBoundingBox(); m_building3.setBoundingBox(); m_building4.setBoundingBox(); m_building5.setBoundingBox(); m_building6.setBoundingBox(); m_building7.setBoundingBox(); m_building8.setBoundingBox(); m_building9.setBoundingBox(); m_building10.setBoundingBox(); m_building11.setBoundingBox(); coll_manager.AddEntity(m_building1); coll_manager.AddEntity(m_building2); coll_manager.AddEntity(m_building3); coll_manager.AddEntity(m_building4); coll_manager.AddEntity(m_building5); coll_manager.AddEntity(m_building6); coll_manager.AddEntity(m_building7); coll_manager.AddEntity(m_building8); coll_manager.AddEntity(m_building9); coll_manager.AddEntity(m_building10); m_player.Manager = coll_manager; }
/// <summary> /// Unload content for the screen. /// </summary> public override void UnloadContent() { font = null; m_player = null; GameCore.Camera.Player = null; spriteBatch = null; m_floor = null; m_enemy = null; // m_building = null; }