/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { this.Exit(); } // TODO: Add your update logic here // po.update(gameTime); camera.update(gameTime, people, this); //monster1.update(gameTime); terrain.checkBoundary(people); processInput(gameTime); //Cizhen collide detect performed when main character is active if (people.isActive) { BoundingSphere shipSphere = new BoundingSphere( people.modelPosition, people.myModel.Meshes[0].BoundingSphere.Radius / 20); for (int i = 0; i < characterList.Length; i++) { BoundingSphere b = new BoundingSphere(characterList[i].modelPosition, characterList[i].myModel.Meshes[0].BoundingSphere.Radius * 0.8f); if (b.Intersects(shipSphere)) { if (Math.Abs(characterList[i].modelPosition.X - people.modelPosition.X) <= 0.1f && Math.Abs(characterList[i].modelPosition.Z - people.modelPosition.Z) <= 0.1f) { if (characterList[i].isActive) { characterList[i].isActive = false; } } else { characterList[i].update(gameTime, people.modelPosition.X, people.modelPosition.Z); } //monster1.modelPosition.X += 0.01f ; } } } base.Update(gameTime); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { this.Exit(); } // TODO: Add your update logic here model_character.update(gameTime); camera.update(gameTime, people, this); processInput(gameTime); base.Update(gameTime); }