public void Update(GameTime gameTime, GraphicsDeviceManager graphics) { UpdateInput(); if (activarcamara == ActivarCamara.fps) { cameraSurface.UpdateInput(gameTime, graphics); view = cameraSurface.view; projection = cameraSurface.projection; //tank.view = cameraSurfaceFollow.view; //tank.projection = cameraSurfaceFollow.projection; } else if (activarcamara == ActivarCamara.free) { cameraAula.UpdateInput(gameTime, graphics); view = cameraAula.view; projection = cameraAula.projection; worldMatrix = cameraAula.worldMatrix; //tank.view = camera.view; //tank.projection = camera.projection; } else { //cameraSurfaceFollow.updateCamera(); //cameraTank.UpdateInput(gameTime, graphics,tank.getPosition()); cameraTank.updateCamera(tank.getPosition(), tank.getWorldMAtrix(), tank.view, tank); view = cameraTank.view; projection = cameraTank.projection; worldMatrix = cameraTank.worldMatrix; } }
/// <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) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } escolherCamara(); if (cameraAtiva == CameraAtiva.fps) { cameraSurfaceFollow.UpdateInput(gameTime, graphics); } else if (cameraAtiva == CameraAtiva.free) { camera.UpdateInput(gameTime, graphics); } else { cameraTank.updateCamera(tank.getPosition(), tank.getWorldMAtrix(), tank.view, tank); } tank.Update(gameTime, tank, listaTanques); tankEnimigo.Update(gameTime, tank, listaTanques); tankEnimigo2.Update(gameTime, tank, listaTanques); tankEnimigo3.Update(gameTime, tank, listaTanques); BulletManager.UpdateBalas(gameTime); colisionManager.UpdateColisions(tank); base.Update(gameTime); }
/// <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); //Criar e definir o resterizerState a utilizar para desenhar a geometria RasterizerState rasterizerState = new RasterizerState(); //rasterizerState.CullMode = CullMode.None; //rasterizerState.FillMode = FillMode.WireFrame; rasterizerState.MultiSampleAntiAlias = true; GraphicsDevice.RasterizerState = rasterizerState; // TODO: use this.Content to load your game content here //Camera.Initialize(GraphicsDevice); mapaAlturas = Content.Load<Texture2D>("mapaAlturas"); textura = Content.Load<Texture2D>("grass50x50"); terreno = new Terreno(GraphicsDevice, mapaAlturas, mapaAlturas, 1f, textura); //terreno2 = new Terreno2(GraphicsDevice, mapaAlturas, mapaAlturas, 1f, textura); VertexPositionNormalTexture[] vertices = terreno.getVertices(); tank = new Tank(GraphicsDevice, terreno.getVertices(), terreno.larguraMapa,new Vector3(10,20,10), true,Content); tankEnimigo = new Tank(GraphicsDevice, terreno.getVertices(), terreno.larguraMapa,new Vector3(80,20,80) ,false,Content); tankEnimigo2 = new Tank(GraphicsDevice, terreno.getVertices(), terreno.larguraMapa, new Vector3(80, 20, 20), false, Content); tankEnimigo3 = new Tank(GraphicsDevice, terreno.getVertices(), terreno.larguraMapa, new Vector3(70, 20, 50), false, Content); listaTanques.Add(tank); listaTanques.Add(tankEnimigo); listaTanques.Add(tankEnimigo2); listaTanques.Add(tankEnimigo3); colisionManager = new ColisionManager(listaTanques); cameraSurfaceFollow = new CameraSurfaceFollow(graphics, vertices, mapaAlturas.Width); camera = new CameraAula(graphics); cameraTank = new CameraTank(graphics, vertices, mapaAlturas.Width, tank.getPosition(), tank.getWorldMAtrix(),tank.view); camera2 = new CameraVersao2(); effect = new BasicEffect(GraphicsDevice); mousePosition = new Vector2(0, 0); IsMouseVisible = false; cameraAtiva = CameraAtiva.free; //float aspectRatio = (float)GraphicsDevice.Viewport.Width / GraphicsDevice.Viewport.Height; //effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspectRatio, 0.1f, 1000.0f); tank.LoadContent(Content); tankEnimigo.LoadContent(Content); tankEnimigo2.LoadContent(Content); tankEnimigo3.LoadContent(Content); BulletManager.Initialize(tank,Content); IA.Initialize(); }
/// <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); //Criar e definir o resterizerState a utilizar para desenhar a geometria RasterizerState rasterizerState = new RasterizerState(); //rasterizerState.CullMode = CullMode.None; //rasterizerState.FillMode = FillMode.WireFrame; rasterizerState.MultiSampleAntiAlias = true; GraphicsDevice.RasterizerState = rasterizerState; // TODO: use this.Content to load your game content here //Camera.Initialize(GraphicsDevice); mapaAlturas = Content.Load <Texture2D>("mapaAlturas"); textura = Content.Load <Texture2D>("grass50x50"); terreno = new Terreno(GraphicsDevice, mapaAlturas, mapaAlturas, 1f, textura); //terreno2 = new Terreno2(GraphicsDevice, mapaAlturas, mapaAlturas, 1f, textura); VertexPositionNormalTexture[] vertices = terreno.getVertices(); tank = new Tank(GraphicsDevice, terreno.getVertices(), terreno.larguraMapa, new Vector3(10, 20, 10), true, Content); tankEnimigo = new Tank(GraphicsDevice, terreno.getVertices(), terreno.larguraMapa, new Vector3(80, 20, 80), false, Content); tankEnimigo2 = new Tank(GraphicsDevice, terreno.getVertices(), terreno.larguraMapa, new Vector3(80, 20, 20), false, Content); tankEnimigo3 = new Tank(GraphicsDevice, terreno.getVertices(), terreno.larguraMapa, new Vector3(70, 20, 50), false, Content); listaTanques.Add(tank); listaTanques.Add(tankEnimigo); listaTanques.Add(tankEnimigo2); listaTanques.Add(tankEnimigo3); colisionManager = new ColisionManager(listaTanques); cameraSurfaceFollow = new CameraSurfaceFollow(graphics, vertices, mapaAlturas.Width); camera = new CameraAula(graphics); cameraTank = new CameraTank(graphics, vertices, mapaAlturas.Width, tank.getPosition(), tank.getWorldMAtrix(), tank.view); camera2 = new CameraVersao2(); effect = new BasicEffect(GraphicsDevice); mousePosition = new Vector2(0, 0); IsMouseVisible = false; cameraAtiva = CameraAtiva.free; //float aspectRatio = (float)GraphicsDevice.Viewport.Width / GraphicsDevice.Viewport.Height; //effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspectRatio, 0.1f, 1000.0f); tank.LoadContent(Content); tankEnimigo.LoadContent(Content); tankEnimigo2.LoadContent(Content); tankEnimigo3.LoadContent(Content); BulletManager.Initialize(tank, Content); IA.Initialize(); }