public Prize(Game game, Vector3 pos, Vector3 rot, Model model, bool textured, Matrix[] transforms, float scale, bool immovable) : base(game, pos, rot, model, textured, transforms, scale, immovable) { m_body.ApplyGravity = true; m_controller = new physController(); m_controller.Initialize(m_body); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); //Load font fontToUse = Content.Load<SpriteFont>("Game font"); //Load models m_UFOCatcherBoxModel = Content.Load<Model>("True crane game with prize block"); m_GlassModel = Content.Load<Model>("Glass"); m_UFOModel = Content.Load<Model>("UFO"); m_prize = Content.Load<Model>("Prize model"); m_Floor = Content.Load<Model>("Floor"); //Set up the Game objects m_UFOCatcherBox = new GameObject(this, new Vector3(0, 0, 0), new Vector3(0, 0, 0), m_UFOCatcherBoxModel, true,SetupEffectTransformDefaults(m_UFOCatcherBoxModel, true), 10, true); m_Glass = new GameObject(this, new Vector3(0, 0, 0), new Vector3(0, 0, 0), m_GlassModel, true, SetupEffectTransformDefaults(m_GlassModel, true), 10, true); m_UFO = new UFO(this, new Vector3(-16, 26, 6), new Vector3(0, 0, 0), m_UFOModel, true, SetupEffectTransformDefaults(m_UFOModel, true), 4, false); m_prizeFloor = new Floor(this, new Vector3(-12, -30, 0), new Vector3(0, 0, 0), m_Floor, true, SetupEffectTransformDefaults(m_Floor, true), 700, true); //Add bounding box for the UFO m_UFO.AddPhysicsPrimitive(new Box(new Vector3(-16, 26, 6), Matrix.Identity, new Vector3(7.0f,5.0f,7.0f)), new MaterialProperties(0.0f,0.0f,0.0f)); //Register collision skin to check for collisions m_UFO.m_skin.callbackFn += (UFOCollisionDetection); //Add bounding box to check for the prizes m_prizeFloor.AddPhysicsPrimitive(new Box(m_prizeFloor.m_body.Position, Matrix.Identity, new Vector3(40.0f, 10.0f, 40.0f)), new MaterialProperties(0.0f, 0.4f, 0.9f)); //Register collision skin to check for collisions m_prizeFloor.m_skin.callbackFn += (PrizeCollisionDetection); //Register prize floor in XNA component system Components.Add(m_prizeFloor); //Add objects to list in the right order from back to front m_GameObjects.Add(m_prizeFloor); m_GameObjects.Add(m_UFOCatcherBox); m_GameObjects.Add(m_UFO); //Random number generator Random rand = new Random(); //Generate a prize and add it to both lists for (int i = 0; i < GameVariables.numberOfPrizes; i++) { Prize prize = new Prize(this, new Vector3(5 + rand.Next(20), 0, -(float)rand.Next(12)), new Vector3(0, 0, 0), m_prize, true, SetupEffectTransformDefaults(m_prize, true), 8, false); prize.AddPhysicsPrimitive(new Box(prize.m_body.Position, Matrix.Identity, new Vector3(4.0f, 1.5f, 7.0f)), new MaterialProperties(0.0f, 0.4f, 0.9f)); Components.Add(prize); m_prizesList.Add(prize); m_GameObjects.Add(prize); } //Add glass m_GameObjects.Add(m_Glass); //Create collision boundarys for the walls of the box CreateMachineWalls(); //Add UFO to Component system Components.Add(m_UFO); //Create a controller to enable forces to be applyed to a body(part of the physics engine) m_UFOController = new physController(); m_UFOController.Initialize(m_UFO.m_body); //Load music m_mainTheme = Content.Load<Song>("F03"); MediaPlayer.Play(m_mainTheme); MediaPlayer.IsRepeating = true; //Load sound effects m_insertCoinSE = Content.Load<SoundEffect>("Insert Coin Sound Effect"); m_UFObeamingSE = Content.Load<SoundEffect>("reimanzeta"); // TODO: use this.Content to load your game content here }