Texture2D getTextureFromBlock(Trench block) { switch (block.Type) { case TrenchType.Straight: switch (block.Rotation) { case 0: return(mmStraight[0]); case 90: return(mmStraight[1]); case 180: return(mmStraight[0]); case 270: return(mmStraight[1]); } break; case TrenchType.Elbow: return(mmElbow[(int)(block.Rotation / 90)]); case TrenchType.T: return(mmT[(int)(block.Rotation / 90)]); case TrenchType.Intersection: return(mmIntersection); case TrenchType.Platform: return(mmPlatform); } return(mmPlatform); }
void attemptToCorrect(Dir dir, ref Trench block, bool?isFloor) { //int tries = 0; applyCorrection(dir); //tries++; if (isFloor != null) { var pos = isFloor.Value ? -50 : 0; while (Position.Y <= pos) { applyCorrection(dir); //tries++; } } else { while (block.IsInTrench(OBB)) { applyCorrection(dir); //tries++; } } Game.Camera.Position = Position - Game.Camera.FrontDirection * distanceToCamera + UpDirection * 8; Game.Camera.Pitch = Pitch; Game.Camera.Yaw = Yaw; collided = true; //tries = 0; }
public static Trench[,] GenerateMap(int size) { Trench[,] map = new Trench[size, size]; int xi = size / 2; int yi = 0; //Cantidad de puntos de interes (codo, T, interseccion) var attempt = 0; poiCount = 0; var whiteSpace = 500; while (poiCount < 9 || whiteSpace > 300) { poiCount = 0; attempt++; ClearMap(ref map, size); Debug.WriteLine("----"); map[xi, yi] = new Trench(TrenchType.Straight, 0f); //map[xi, yi] = new Trench(TrenchType.Elbow, 270f); var points = GenLine(ref map, xi, yi, 0f, size); recursiveGen(points, ref map, size); whiteSpace = SetPlatforms(ref map, size, false); } SetPlatforms(ref map, size, true); System.Diagnostics.Debug.WriteLine("attempts: " + attempt + " ws: " + whiteSpace); return(map); }
protected override void LoadContent() { Drawer.Init(); HUD.LoadContent(); SoundManager.LoadContent(); Gizmos.LoadContent(GraphicsDevice); Trench.UpdateTrenches(); var blockSize = MapLimit / MapSize; Camera.MapLimit = MapLimit; Camera.MapSize = MapSize; Camera.BlockSize = blockSize; Camera.Position = new Vector3(MapLimit / 2 - blockSize / 2, 150f, blockSize / 2); Xwing.MapLimit = MapLimit; Xwing.MapSize = MapSize; Xwing.Update(0f, Camera); LightCamera = new LightCamera(Camera.AspectRatio, Xwing.Position - Vector3.Left * 300 + Vector3.Up * (300 * MathF.Tan(MathHelper.ToRadians(30)))); LightCamera.BuildProjection(LightCamera.AspectRatio, 50f, 3000f, LightCamera.DefaultFieldOfViewDegrees); Laser.MapLimit = MapLimit; Laser.MapSize = MapSize; Laser.BlockSize = blockSize; base.LoadContent(); }
void DrawTrenchMRT(Trench t) { Matrix world; foreach (var mesh in t.SelectedModel.Meshes) { world = mesh.ParentBone.Transform * t.SRT; MRTcolor.SetValue(new Vector3(0.5f, 0.5f, 0.5f)); MRTworld.SetValue(world); MRTworldViewProjection.SetValue(world * Game.SelectedCamera.View * Game.SelectedCamera.Projection); MRTinverseTransposeWorld.SetValue(Matrix.Transpose(Matrix.Invert(world))); mesh.Draw(); } foreach (var turret in t.Turrets) { foreach (var mesh in TrenchTurret.Meshes) { world = mesh.ParentBone.Transform * turret.SRT; MRTcolor.SetValue(new Vector3(0.5f, 0.5f, 0.5f)); MRTworld.SetValue(world); MRTworldViewProjection.SetValue(world * Game.SelectedCamera.View * Game.SelectedCamera.Projection); MRTinverseTransposeWorld.SetValue(Matrix.Transpose(Matrix.Invert(world))); mesh.Draw(); } } }
protected override void Initialize() { // La logica de inicializacion que no depende del contenido se recomienda poner en este metodo. // Apago el backface culling. // Esto se hace por un problema en el diseno del modelo del logo de la materia. // Una vez que empiecen su juego, esto no es mas necesario y lo pueden sacar. //var rasterizerState = new RasterizerState(); //rasterizerState.CullMode = CullMode.None; //GraphicsDevice.RasterizerState = rasterizerState; Input = new Input(this); HUD = new HUD(this); Drawer = new Drawer(); BackgroundCombat = new BackgroundCombat(); GameState = GmState.StartScreen; Xwing.World = Matrix.Identity; // Hace que el mouse sea visible. IsMouseVisible = true; IsFixedTimeStep = true; TargetElapsedTime = TimeSpan.FromSeconds(1d / 60); //60); Graphics.IsFullScreen = false; Graphics.PreferredBackBufferWidth = 1280; Graphics.PreferredBackBufferHeight = 720; Graphics.ApplyChanges(); var size = GraphicsDevice.Viewport.Bounds.Size; size.X /= 2; size.Y /= 2; // Creo una camara libre con parametros de pitch, yaw que se puede mover con WASD, y rotar con mouse Camera = new MyCamera(GraphicsDevice.Viewport.AspectRatio, Vector3.Zero, size); LookBack = new MyCamera(GraphicsDevice.Viewport.AspectRatio, Vector3.Zero, size); SelectedCamera = Camera; //Algoritmo de generacion de mapa recursivo (ver debug output) Map = Trench.GenerateMap(MapSize); System.Diagnostics.Debug.WriteLine(Trench.ShowMapInConsole(Map, MapSize)); base.Initialize(); Window.Title = "Star Wars: Trench Run"; Window.IsBorderless = true; }
/*Static elements*/ private static Trench GetNextTrench(Trench input, float rotation) { //Si es bloque de estos y no esta alineado, entonces es un straight if (input.Type.Equals(TrenchType.Intersection) || input.Type.Equals(TrenchType.Elbow) || input.Type.Equals(TrenchType.Intersection) && rotation != input.Rotation) { return(new Trench(TrenchType.Straight, rotation)); } //else // return new Trench(TrenchType.Platform, rotation); Random rnd = new Random(); int val = rnd.Next(0, 100); // 85% chance de que sea derecho, 15% repatirtido en CodoIzq, CodoDer, T, Interseccion. var straightChance = 85; var elbowLeftChance = 5; var elbowRightChance = 5; var tChance = 4; var intersectionChance = 1; if (val < straightChance) { return(new Trench(TrenchType.Straight, rotation)); } if (val < 100 - intersectionChance - tChance - elbowRightChance - elbowLeftChance) { return(new Trench(TrenchType.Elbow, LeftFromAngle(rotation))); } if (val < 100 - intersectionChance - tChance - elbowRightChance) { return(new Trench(TrenchType.Elbow, RightFromAngle(rotation))); } if (val < 100 - intersectionChance - tChance) { return(new Trench(TrenchType.T, rotation)); } if (val < 100 - intersectionChance) { return(new Trench(TrenchType.Intersection, rotation)); } return(new Trench(TrenchType.Straight, 0f)); }
static int SetPlatforms(ref Trench[,] map, int size, bool create) { int p = 0; for (int x = 0; x < size; x++) { for (int y = 0; y < size; y++) { if (map[x, y] == null) { p++; if (create) { map[x, y] = new Trench(TrenchType.Platform, 0f); } } } } return(p); }
public static void UpdateTrenches() { var Game = TGCGame.Instance; //Inicializo valores importantes del mapa float tx = 0; float tz = 0; Matrix S = Matrix.CreateScale(TrenchScale); Matrix R = Matrix.Identity; Matrix T = Matrix.CreateTranslation(new Vector3(0, -35, 0)); float delta = 395.5f; Random rnd = new Random(); for (int x = 0; x < TGCGame.MapSize; x++) { tz = 0; for (int z = 0; z < TGCGame.MapSize; z++) { var r = rnd.Next(0, 100); Trench block = Game.Map[x, z]; block.Models = Drawer.GetModelsFromType(Game.Map[x, z].Type); block.Position = new Vector3(tx, 0, tz); var boxWidth = 175f; var boxDepth = 50f; var deltaOver2 = delta * 0.5f; var BBmin = block.Position - new Vector3(deltaOver2, boxDepth, deltaOver2); var BBmax = block.Position + new Vector3(deltaOver2, 0f, deltaOver2); block.BB = new BoundingBox(BBmin, BBmax); var verticalLeftBoxMin = block.Position + new Vector3(-deltaOver2, -boxDepth, -deltaOver2); var verticalLeftBoxMax = verticalLeftBoxMin + new Vector3(boxWidth, boxDepth, delta); var VerticalLeftBox = new BoundingBox(verticalLeftBoxMin, verticalLeftBoxMax); var verticalRightBoxMin = block.Position + new Vector3(deltaOver2 - boxWidth, -boxDepth, -deltaOver2); var verticalRightBoxMax = verticalRightBoxMin + new Vector3(boxWidth, boxDepth, delta); var VerticalRightBox = new BoundingBox(verticalRightBoxMin, verticalRightBoxMax); var horizontalTopBoxMin = block.Position + new Vector3(-deltaOver2, -boxDepth, deltaOver2 - boxWidth); var horizontalTopBoxMax = horizontalTopBoxMin + new Vector3(delta, boxDepth, boxWidth); var HorizontalTopBox = new BoundingBox(horizontalTopBoxMin, horizontalTopBoxMax); var horizontalBottomBoxMin = block.Position + new Vector3(-deltaOver2, -boxDepth, -deltaOver2); var horizontalBottomBoxMax = horizontalBottomBoxMin + new Vector3(delta, boxDepth, boxWidth); var HorizontalBottomBox = new BoundingBox(horizontalBottomBoxMin, horizontalBottomBoxMax); var BottomLeftBox = new BoundingBox(verticalLeftBoxMin, verticalLeftBoxMin + new Vector3(boxWidth, boxDepth, boxWidth)); var TopLeftBox = new BoundingBox(horizontalTopBoxMin, horizontalTopBoxMin + new Vector3(boxWidth, boxDepth, boxWidth)); var topRightMin = verticalRightBoxMin + new Vector3(0, 0, delta - boxWidth); var TopRightBox = new BoundingBox(topRightMin, topRightMin + new Vector3(boxWidth, boxDepth, boxWidth)); var BottomRightBox = new BoundingBox(verticalRightBoxMin, verticalRightBoxMin + new Vector3(boxWidth, boxDepth, boxWidth)); var VLOOB = OrientedBoundingBox.FromAABB(VerticalLeftBox); var VROOB = OrientedBoundingBox.FromAABB(VerticalRightBox); var HTOOB = OrientedBoundingBox.FromAABB(HorizontalTopBox); var HBOOB = OrientedBoundingBox.FromAABB(HorizontalBottomBox); var TLOOB = OrientedBoundingBox.FromAABB(TopLeftBox); var BLOOB = OrientedBoundingBox.FromAABB(BottomLeftBox); var TROOB = OrientedBoundingBox.FromAABB(TopRightBox); var BROOB = OrientedBoundingBox.FromAABB(BottomRightBox); Vector3[] turretDelta = new Vector3[] { Vector3.Zero, Vector3.Zero }; //var turretDeltaY = 8f; switch (block.Type) { case TrenchType.Platform: R = Matrix.Identity; turretDelta = calculateTurretDelta( block.Rotation, new Vector3(77.3f, 8f, -82.5f), new Vector3(-76.9f, 8f, 82.6f), TrenchType.Platform); break; case TrenchType.Straight: R = Matrix.CreateRotationY(-MathHelper.PiOver2); turretDelta = calculateTurretDelta( block.Rotation, new Vector3(50.5f, 8f, -159f), new Vector3(-83.49f, 8f, -77.5f), TrenchType.Straight); if (block.Rotation == 0f || block.Rotation == 180f) { block.boundingBoxes.Add(VerticalLeftBox); block.boundingBoxes.Add(VerticalRightBox); block.orientedBoundingBoxes.Add(VLOOB); block.orientedBoundingBoxes.Add(VROOB); } else { block.boundingBoxes.Add(HorizontalTopBox); block.boundingBoxes.Add(HorizontalBottomBox); block.orientedBoundingBoxes.Add(HTOOB); block.orientedBoundingBoxes.Add(HBOOB); } break; case TrenchType.T: R = Matrix.CreateRotationY(MathHelper.PiOver2); turretDelta = calculateTurretDelta( block.Rotation, new Vector3(22.4f, 8f, 83f), new Vector3(50.6f, 8f, -159.3f), TrenchType.T); switch (block.Rotation) { case 0f: block.boundingBoxes.Add(HorizontalTopBox); block.boundingBoxes.Add(BottomLeftBox); block.boundingBoxes.Add(BottomRightBox); block.orientedBoundingBoxes.Add(HTOOB); block.orientedBoundingBoxes.Add(BLOOB); block.orientedBoundingBoxes.Add(BROOB); break; case 90f: block.boundingBoxes.Add(VerticalRightBox); block.boundingBoxes.Add(TopLeftBox); block.boundingBoxes.Add(BottomLeftBox); block.orientedBoundingBoxes.Add(VROOB); block.orientedBoundingBoxes.Add(TLOOB); block.orientedBoundingBoxes.Add(BLOOB); break; case 180f: block.boundingBoxes.Add(HorizontalBottomBox); block.boundingBoxes.Add(TopLeftBox); block.boundingBoxes.Add(TopRightBox); block.orientedBoundingBoxes.Add(HBOOB); block.orientedBoundingBoxes.Add(TLOOB); block.orientedBoundingBoxes.Add(TROOB); break; case 270f: block.boundingBoxes.Add(VerticalLeftBox); block.boundingBoxes.Add(TopRightBox); block.boundingBoxes.Add(BottomRightBox); block.orientedBoundingBoxes.Add(VLOOB); block.orientedBoundingBoxes.Add(TROOB); block.orientedBoundingBoxes.Add(BROOB); break; } break; case TrenchType.Elbow: R = Matrix.Identity; turretDelta = calculateTurretDelta( block.Rotation, new Vector3(83f, 8f, 77f), new Vector3(-22f, 8f, -82.3f), TrenchType.Elbow); switch (block.Rotation) { case 0f: block.boundingBoxes.Add(HorizontalTopBox); block.boundingBoxes.Add(VerticalRightBox); block.boundingBoxes.Add(BottomLeftBox); block.orientedBoundingBoxes.Add(HTOOB); block.orientedBoundingBoxes.Add(VROOB); block.orientedBoundingBoxes.Add(BLOOB); break; case 90f: block.boundingBoxes.Add(HorizontalBottomBox); block.boundingBoxes.Add(VerticalLeftBox); block.boundingBoxes.Add(TopRightBox); block.orientedBoundingBoxes.Add(HBOOB); block.orientedBoundingBoxes.Add(VLOOB); block.orientedBoundingBoxes.Add(TROOB); break; case 180f: block.boundingBoxes.Add(HorizontalTopBox); block.boundingBoxes.Add(VerticalLeftBox); block.boundingBoxes.Add(BottomRightBox); block.orientedBoundingBoxes.Add(HTOOB); block.orientedBoundingBoxes.Add(VLOOB); block.orientedBoundingBoxes.Add(BROOB); break; case 270f: block.boundingBoxes.Add(HorizontalBottomBox); block.boundingBoxes.Add(VerticalRightBox); block.boundingBoxes.Add(TopLeftBox); block.orientedBoundingBoxes.Add(HBOOB); block.orientedBoundingBoxes.Add(VROOB); block.orientedBoundingBoxes.Add(TLOOB); break; } break; case TrenchType.Intersection: R = Matrix.Identity; turretDelta = calculateTurretDelta( 0f, new Vector3(82.4f, 8f, -145.7f), new Vector3(-63.3f, 8f, 50.7f), TrenchType.Intersection); block.boundingBoxes.Add(TopLeftBox); block.boundingBoxes.Add(BottomLeftBox); block.boundingBoxes.Add(TopRightBox); block.boundingBoxes.Add(BottomRightBox); block.orientedBoundingBoxes.Add(TLOOB); block.orientedBoundingBoxes.Add(BLOOB); block.orientedBoundingBoxes.Add(TROOB); block.orientedBoundingBoxes.Add(BROOB); break; } if (block.Type.Equals(TrenchType.Intersection)) { block.SRT = S * R * Matrix.CreateTranslation(block.Position) * T; } else { block.SRT = S * R * Matrix.CreateRotationY(MathHelper.ToRadians(block.Rotation)) * Matrix.CreateTranslation(block.Position) * T; } if (r < 30) // %30 chance de tener una torre { block.Turrets.Add(new TrenchTurret()); } if (r < 10) // %10 chance de tener dos { block.Turrets.Add(new TrenchTurret()); } var tsize = 4f; int index = 0; foreach (var turret in block.Turrets) { turret.Position = block.Position + turretDelta[index]; turret.S = S; turret.SRT = S * R * Matrix.CreateTranslation(turret.Position); turret.BoundingBox = new BoundingBox(turret.Position - new Vector3(tsize), turret.Position + new Vector3(tsize)); //turret.BoundingBox = BoundingVolumesExtensions.CreateAABBFrom(TGCGame.TrenchTurret); //turret.BoundingBox index++; } tz += delta; } tx += delta; } Game.MapLimit = tz; }
static List <Vector3> GenLine(ref Trench[,] map, int xi, int yi, float rotation, int size) { int deltaX = 0; int deltaY = 0; int x = xi; int y = yi; int steps = 0; // X,Y,Rotation List <Vector3> pointsOfInterest = new List <Vector3>(); // me muevo en la direccion en la que vengo, hasta el final switch (rotation) { case 0f: deltaY = 1; deltaX = 0; steps = size - yi - 1; break; case 90f: deltaX = 1; deltaY = 0; steps = size - xi - 1; break; case 180f: deltaY = -1; deltaX = 0; steps = yi; break; case 270f: deltaX = -1; deltaY = 0; steps = xi; break; } int prevX, prevY; for (int step = 0; step < steps; step++) { prevX = x; prevY = y; x += deltaX; y += deltaY; //Si hay algo ahi, freno (reemplazo por T? ) Trench prevBlock = map[prevX, prevY]; if (map[x, y] != null) { switch (map[x, y].Type) { case TrenchType.Straight: map[x, y] = new Trench(TrenchType.T, rotation); //Debug.WriteLine("set T (from ST) at (" + x + "," + y + ") rot " + rotation); break; case TrenchType.T: map[x, y] = new Trench(TrenchType.Intersection, rotation); //Debug.WriteLine("set INT at (" + x + "," + y + ") rot " + rotation); break; case TrenchType.Elbow: //check rotation when replacing float elbowRot = map[x, y].Rotation; Debug.WriteLine("set T (from E " + elbowRot + " at " + x + "," + y + " rot " + rotation + " prevR " + prevBlock.Rotation); //correctedRot = RightFromAngle(map[x, y].Rotation); map[x, y] = new Trench(TrenchType.T, OppositeFromAngle(elbowRot)); break; } return(pointsOfInterest); } //Obtengo el siguiente bloque (adelante en el mapa) Trench next = GetNextTrench(prevBlock, rotation); var rotDelta = next.Rotation - prevBlock.Rotation; var sameType = next.Type == prevBlock.Type; if (rotDelta != 0 && sameType && prevBlock.Type == TrenchType.Straight) //Rotacion incorrecta { Debug.WriteLine("fixing " + rotDelta + " at " + prevX + "," + prevY + " -> " + x + "," + y); next = new Trench(TrenchType.Straight, prevBlock.Rotation); } map[x, y] = next; //si es Interseccion o T, voy a tener dos direcciones en las que seguir dibujando (izq, der) if (next.Type.Equals(TrenchType.Intersection) || next.Type.Equals(TrenchType.T)) { pointsOfInterest.Add(new Vector3(x, y, LeftFromAngle(rotation))); pointsOfInterest.Add(new Vector3(x, y, RightFromAngle(rotation))); poiCount++; } //si es un codo, voy a seguir en la direccion en la que este ubicado (izq O der) if (next.Type.Equals(TrenchType.Elbow)) { //if (next.Rotation == rotation) // pointsOfInterest.Add(new Vector3(x, y, LeftFromAngle(rotation))); //else // pointsOfInterest.Add(new Vector3(x, y, RightFromAngle(rotation))); pointsOfInterest.Add(new Vector3(x, y, next.Rotation)); poiCount++; } //Si no es una interseccion, no puedo seguir adelante y tengo que frenar la generacion en esta rama bool stop = !(next.Type.Equals(TrenchType.Straight) || next.Type.Equals(TrenchType.Intersection)); if (stop) { return(pointsOfInterest); } } return(pointsOfInterest); }
protected override void Update(GameTime gameTime) { float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds; Drawer.MasterMRT.Parameters["Time"]?.SetValue(elapsedTime); Input.ProcessInput(); BoundingFrustum.Matrix = SelectedCamera.View * SelectedCamera.Projection; Vector3[] frustumCorners = BoundingFrustum.GetCorners(); var lvp = LightCamera.View * LightCamera.Projection; Vector3 center = Vector3.Zero; foreach (var corner in frustumCorners) { center += corner; } center /= frustumCorners.Length; //var cyr = MathHelper.ToRadians(Camera.Yaw); float dif = -MathF.Atan2(Camera.FrontDirection.X - 1f, Camera.FrontDirection.Z - 0f); if (dif > MathHelper.PiOver2) { dif = MathHelper.Pi - dif; } // [0 - 90] // [700- 200] LightCamera.Offset = 200f; //LightCamera.Offset = MathHelper.Lerp(200, 700, 1f - (dif / MathHelper.PiOver2)); //Debug.WriteLine(" dif "+ MathHelper.ToDegrees(dif) + " off " + LightCamera.Offset); //LightCamera.NearPlane = shadowNear; //LightCamera.FarPlane = shadowFar; LightCamera.Update(gameTime); Vector4 zone = Xwing.GetZone(); switch (GameState) { case GmState.StartScreen: #region startscreen Camera.Yaw += 10f * elapsedTime; Camera.Yaw %= 360; Camera.Pitch += 10f * elapsedTime; Camera.Yaw %= 90; Camera.UpdateVectorView(); #endregion break; case GmState.Running: #region running Drawer.trenchesToDraw.Clear(); Drawer.tiesToDraw.Clear(); Drawer.showXwing = true; Drawer.lasersToDraw.Clear(); Drawer.shipsToDraw.Clear(); elementsDrawn = 0; totalElements = 0; //Update camara Camera.Update(gameTime); //Generacion de enemigos, de ser necesario TieFighter.GenerateEnemies(Xwing); TieFighter.AddAllRequiredToDraw(ref Drawer.tiesToDraw, BoundingFrustum); elementsDrawn += Drawer.tiesToDraw.Count; totalElements += TieFighter.Enemies.Count; //Update Xwing Xwing.Update(elapsedTime, Camera); elementsDrawn += 1; totalElements += 1; BackgroundCombat.UpdateAll(elapsedTime); BackgroundCombat.AddAllRequiredToDraw(ref Drawer.shipsToDraw); Trench.UpdateCurrent(); //enemyLasers.Clear(); for (int x = (int)zone.X; x < zone.Y; x++) { for (int z = (int)zone.Z; z < zone.W; z++) { var block = Map[x, z]; block.Update(elapsedTime); if (BoundingFrustum.Intersects(block.BB)) { Drawer.trenchesToDraw.Add(Map[x, z]); } totalElements++; } } elementsDrawn += Drawer.trenchesToDraw.Count; Laser.UpdateAll(elapsedTime, Xwing); totalElements += Laser.AlliedLasers.Count; totalElements += Laser.EnemyLasers.Count; Laser.AddAllRequiredtoDraw(ref Drawer.lasersToDraw, ref BoundingFrustum); elementsDrawn += Drawer.lasersToDraw.Count; Drawer.MasterMRT.Parameters["OmniLightsRadiusMin"]?.SetValue(RadMin); Drawer.MasterMRT.Parameters["OmniLightsRadiusMax"]?.SetValue(RadMax); Drawer.MasterMRT.Parameters["OmniLightsPos"]?.SetValue(Laser.OmniLightsPos); Drawer.MasterMRT.Parameters["OmniLightsColor"]?.SetValue(Laser.OmniLightsColor); Drawer.MasterMRT.Parameters["OmniLightsCount"]?.SetValue(Laser.OmniLightsCount); //Colisiones Xwing.VerifyCollisions(Laser.EnemyLasers, Map); TieFighter.UpdateEnemies(elapsedTime, Xwing); SoundManager.UpdateRandomDistantSounds(elapsedTime); #endregion break; case GmState.Paused: #region paused Camera.PausedUpdate(elapsedTime, Xwing); Drawer.trenchesToDraw.Clear(); for (int x = (int)zone.X; x < zone.Y; x++) { for (int z = (int)zone.Z; z < zone.W; z++) { var block = Map[x, z]; if (BoundingFrustum.Intersects(block.BB)) { Drawer.trenchesToDraw.Add(Map[x, z]); } } } #endregion break; case GmState.Victory: #region victory Camera.PausedUpdate(elapsedTime, Xwing); #endregion break; case GmState.Defeat: #region defeat Camera.PausedUpdate(elapsedTime, Xwing); Drawer.trenchesToDraw.Clear(); for (int x = (int)zone.X; x < zone.Y; x++) { for (int z = (int)zone.Z; z < zone.W; z++) { var block = Map[x, z]; if (BoundingFrustum.Intersects(block.BB)) { Drawer.trenchesToDraw.Add(Map[x, z]); } } } #endregion break; } Gizmos.UpdateViewProjection(SelectedCamera.View, SelectedCamera.Projection); if (Xwing.Score >= 100) { ChangeGameStateTo(GmState.Victory); } base.Update(gameTime); }