public void Render() { //Checks to see if Active Camera is going to follow an entity. if (CameraManager.ActiveBehavior is EntityFollowBehavior) { ArcBallCamera _entityCamera = CameraManager.ActiveCamera as ArcBallCamera; EntityFollowBehavior EntityBeh = CameraManager.ActiveBehavior as EntityFollowBehavior; //_entityCamera.Distance = 20f; //Zoom into the entity. if (EntityBeh.Choice == "Team1.Tank") { _entityFollow.Entity = Simulation.Team2.Tank; _entityCamera.Distance = 20f; } else if (EntityBeh.Choice == "Team1.UAV") { _entityFollow.Entity = Simulation.Team2.UAV; _entityCamera.Distance = 80f; _entityCamera.Pitch = 45f; } else if (EntityBeh.Choice == "Team2.Tank") { _entityFollow.Entity = Simulation.Team1.Tank; _entityCamera.Distance = 20f; } else if (EntityBeh.Choice == "Team2.UAV") { _entityFollow.Entity = Simulation.Team1.UAV; _entityCamera.Distance = 80f; _entityCamera.Pitch = 45f; } //else { throw new NotSupportedException(); } CameraManager.Set(_entityCamera, _entityFollow); } // Draw the world Camera camera = CameraManager.ActiveCamera; _world.Draw(_device, camera); CheckLogin(teamLogin); // Draw the entities Position t1 = Simulation.Team1.Tank.Position; Position t2 = Simulation.Team2.Tank.Position; Position u1 = Simulation.Team1.UAV.Position; Position u2 = Simulation.Team2.UAV.Position; float t1h = Simulation.Team1.Tank.CurrentHeading; float t2h = Simulation.Team2.Tank.CurrentHeading; float u1h = Simulation.Team1.UAV.CurrentHeading; float u2h = Simulation.Team2.UAV.CurrentHeading; if (id != 0) { if (id == 1) { _tankModel.Render(camera, new Vector3(t1.X / 10, 0, t1.Y / 10), t1h, Color.Blue); _uavModel.TextureRender(camera, new Vector3(u1.X / 10, 20, u1.Y / 10), u1h); _cone.Render(_device, new Vector2(u1.X / 10, u1.Y / 10), camera, 1, Simulation.Team1.UAV.DetectedTankThisTurn); _ring.Render(_device, new Vector2(t1.X / 10, t1.Y / 10), camera, 1); } else if (id == 2) { _tankModel.Render(camera, new Vector3(t2.X / 10, 0, t2.Y / 10), t2h, Color.Red); _uavModel.TextureRender(camera, new Vector3(u2.X / 10, 20, u2.Y / 10), u2h); _cone.Render(_device, new Vector2(u2.X / 10, u2.Y / 10), camera, 2, Simulation.Team2.UAV.DetectedTankThisTurn); _ring.Render(_device, new Vector2(t2.X / 10, t2.Y / 10), camera, 2); } else if (id == 3) { _tankModel.Render(camera, new Vector3(t1.X / 10, 0, t1.Y / 10), t1h, Color.Blue); _uavModel.TextureRender(camera, new Vector3(u1.X / 10, 20, u1.Y / 10), u1h); _tankModel.Render(camera, new Vector3(t2.X / 10, 0, t2.Y / 10), t2h, Color.Red); _uavModel.TextureRender(camera, new Vector3(u2.X / 10, 20, u2.Y / 10), u2h); _cone.Render(_device, new Vector2(u1.X / 10, u1.Y / 10), camera, 1, Simulation.Team1.UAV.DetectedTankThisTurn); _ring.Render(_device, new Vector2(t1.X / 10, t1.Y / 10), camera, 1); _cone.Render(_device, new Vector2(u2.X / 10, u2.Y / 10), camera, 2, Simulation.Team2.UAV.DetectedTankThisTurn); _ring.Render(_device, new Vector2(t2.X / 10, t2.Y / 10), camera, 2); } } //Draw all missiles for (int i = 0; i < mposList.Count; i++) { _missModel.Render(camera, new Vector3(mposList[i].X / 10, 1, mposList[i].Y / 10), mheadingList[i], Color.Black); } //Derender dead tanks if (gameResult == 1) { _tankModel.Render(camera, new Vector3(t2.X / 10, 0, t2.Y / 10), t1h, Color.Transparent); } if (gameResult == 2) { _tankModel.Render(camera, new Vector3(t1.X / 10, 0, t1.Y / 10), t1h, Color.Transparent); } if (gameResult == 3) { _tankModel.Render(camera, new Vector3(t1.X / 10, 0, t1.Y / 10), t1h, Color.Transparent); _tankModel.Render(camera, new Vector3(t2.X / 10, 0, t2.Y / 10), t1h, Color.Transparent); } // Draw legend _sb.Begin(); _sb.Draw(_blankTex, _lRect, Color.White); _sb.DrawString(_font, "Blue = Team 1 Tank", new Vector2(5, 5), Color.Black, 0, Vector2.Zero, 0.5f, SpriteEffects.None, 0); _sb.DrawString(_font, "Cyan = Team 1 UAV", new Vector2(5, 18), Color.Black, 0, Vector2.Zero, 0.5f, SpriteEffects.None, 0); _sb.DrawString(_font, "Red = Team 2 Tank", new Vector2(5, 31), Color.Black, 0, Vector2.Zero, 0.5f, SpriteEffects.None, 0); _sb.DrawString(_font, "Pink = Team 2 UAV", new Vector2(5, 44), Color.Black, 0, Vector2.Zero, 0.5f, SpriteEffects.None, 0); _sb.DrawString(_font, "Black = Missiles", new Vector2(5, 57), Color.Black, 0, Vector2.Zero, 0.5f, SpriteEffects.None, 0); //Draw a message to annouonce the result if (gameResult != 0) { if (gameResult == 3) { _sb.DrawString(_font, $"Both tanks destroyed. It's a draw!", new Vector2(100, 200), Color.Black, 0, Vector2.Zero, 1, SpriteEffects.None, 0); } else { if (gameResult == 1) { _sb.DrawString(_font, $"Blue Team Wins!", new Vector2(100, 200), Color.Black, 0, Vector2.Zero, 1, SpriteEffects.None, 0); } else if (gameResult == 2) { _sb.DrawString(_font, $"Red Team Wins!", new Vector2(100, 200), Color.Black, 0, Vector2.Zero, 1, SpriteEffects.None, 0); } } } _sb.End(); }