public FireFlowerModel(ItemEnemySpriteFactory itemEnemySpriteFactory, Vector2 coordinates, Vector2 velocity, CollisionGrid collisionGrid) : base(itemEnemySpriteFactory) { Texture = ItemEnemySpriteFactory.GetItemSprite("fireflower"); //Initialize state first CurrentState = new ItemStandardState(this); CurrentState.Enter(null); //Define the characteristics of a brick block here Position = coordinates; CurrentFrame = 0; //If additional frames of QuestionBlocks are added, update Columns Columns = 4; Rows = 1; LayerDepth = 1; Scale = new Vector2(10, 10); Width = Texture.Width / Columns; Height = Texture.Height / Rows; TotalFrames = 4; Velocity = velocity; //Bump Animation variables FixedPosition = Position; CollisionGrid = collisionGrid; }
public GreenMushroomModel(ItemEnemySpriteFactory itemEnemySpriteFactory, Vector2 coordinates, Vector2 velocity, CollisionGrid collisionGrid) : base(itemEnemySpriteFactory) { Texture = ItemEnemySpriteFactory.GetItemSprite("greenmushroom"); //Initialize state first CurrentState = new ItemStandardState(this); IsAnimated = false; CurrentState.Enter(null); //Define the characteristics of a brick block here Position = coordinates; CurrentFrame = 0; //If additional frames of QuestionBlocks are added, update Columns Columns = 1; Rows = 1; LayerDepth = 1; Scale = new Vector2(10, 10); Width = Texture.Width / Columns; Height = Texture.Height / Rows; TotalFrames = 1; Velocity = velocity; //Bump Animation variables FixedPosition = Position; horizontalV = 1; //MoveAwayFactor = new Vector2(50, 0); CollisionGrid = collisionGrid; ItemOutsideBlock = 0; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { Paused = false; //Initialize each argument before sending it to contentloader //Controller initialization keyboardController = new KeyboardController(); keyboardController2 = new KeyboardController(); gamePadController = new GamePadController(); keyboardController2.AddCommand((char)Keys.P, new PauseUnpauseGameCommand(this)); keyboardController2.AddCommand((char)Keys.Q, new QuitCommand(this)); // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); spriteMaster = new SpriteMaster(new SpriteBatch(GraphicsDevice), new SpriteBatch(GraphicsDevice)); //Collision initialization collisionGrid = new CollisionGrid(); //Load font font = Content.Load <SpriteFont>("Font"); //load hud hud = new HUD(GraphicsDevice, font); //New Contentloader method should make Game1 easier to follow. ContentLoader contentLoader = new ContentLoader(Content, GraphicsDevice, this, graphics, spriteMaster, keyboardController, gamePadController, collisionGrid, hud); contentLoader.LoadGameContents(checkpointCoords); //this.camera = contentLoader.GetCamera(); this.spriteMaster = contentLoader.GetSpriteMaster(); }
public void ResetGame() { if (hud.Lives > 0) { spriteBatch.Dispose(); spriteMaster.Dispose(); collisionGrid = null; keyboardController = new KeyboardController(); gamePadController = new GamePadController(); // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); spriteMaster = new SpriteMaster(new SpriteBatch(GraphicsDevice), new SpriteBatch(GraphicsDevice)); //Collision initialization collisionGrid = new CollisionGrid(); //New Contentloader method should make Game1 easier to follow. ContentLoader contentLoader = new ContentLoader(Content, GraphicsDevice, this, graphics, spriteMaster, keyboardController, gamePadController, collisionGrid, hud); contentLoader.LoadGameContents(this.checkpointCoords, hud.Points, hud.Coins, hud.Lives); //this.camera = contentLoader.GetCamera(); this.spriteMaster = contentLoader.GetSpriteMaster(); } else { gameIsOver = true; } }
public WarpPipeEnemyModel(BlockSpriteFactory blockSpriteFactory, Vector2 coordinates, Vector2 velocity, EnemyModelFactory enemyModelFactory, string enemyType, int numOfEnemies, CollisionGrid collisionGrid) : base(blockSpriteFactory) { //Constructor for warppipe that hides enemies //Initialize Texture first Texture = BlockSpriteFactory.GetBlockSprite("pipetop"); CurrentState = new WarpPipeEntityStandardState(this); CurrentState.Enter(null); //Define the characteristics of a pipe block here Position = coordinates; CurrentFrame = 0; Columns = 1; Rows = 1; LayerDepth = 1; Scale = new Vector2(10, 10); Width = Texture.Width / Columns; Height = Texture.Height / Rows; Velocity = velocity; //Enemies EnemyModelFactory = enemyModelFactory; EnemyType = enemyType; CollisionGrid = collisionGrid; EnemyModel = enemyModelFactory.GetEnemyModel(enemyType, coordinates, Velocity); EnemyModel.IsVisible = false; NumOfEnemies = numOfEnemies; }
public CollisionGridCell(CollisionGrid parentGrid, int column, int row, int data) { _parentGrid = parentGrid; Column = column; Row = row; Data = data; Flag = data == 0 ? CollisionGridCellFlag.Empty : CollisionGridCellFlag.Solid; }
public DrawableGrid(Game game, SpriteBatch spriteBatch, float width, float height, int numberOfCellsX, int numberOfCellsY) : base(game) { SpriteBatch = spriteBatch; this.width = width; this.height = height; Grid = new CollisionGrid <Sprite>(width, height, numberOfCellsX, numberOfCellsY); }
public CollisionManager(Scene scene) : base(scene) { grid = new CollisionGrid(2000, 1500, 256); colliders = new HashSet <Collider>(); scene.EntityManager.EntityAdded += EntityAdded; scene.EntityManager.EntityRemoved += EntityRemoved; }
public ScanTask(int s, int e, CollisionGrid g, RTSTeam t, Queue <SeenEntity> q) : base(1) { xs = s; xe = e; cg = g; team = t; queue = q; lastAdded = 0; }
public void SetAllFOW(FogOfWar f, CollisionGrid cg) { int i = f == FogOfWar.Nothing ? HEAT_NONE : (f == FogOfWar.Passive ? HEAT_PASSIVE : HEAT_PASSIVE + 1); for (int y = 0; y < cg.numCells.Y; y++) { for (int x = 0; x < cg.numCells.X; x++) { heat[x, y] = i; cg.SetFogOfWar(x, y, teamIndex, f); } } }
private void PrepareCollisionGrid(TiledMapTileLayer collisionLayer) { //Mapa de tiles colidíveis por padrão é 0 em todas as posições var collisionGridData = new int[this.map.Width * this.map.Height]; //Só mudamos o valor da célula para os tiles colidíveis da camada informada foreach (var c in collisionLayer.Tiles) { collisionGridData[c.X + (c.Y * this.map.Width)] = c.GlobalIdentifier; } this.collisionGrid = this.collisionWorld.CreateGrid(collisionGridData, collisionLayer.Width, collisionLayer.Height, collisionLayer.TileWidth, collisionLayer.TileHeight); }
void Awake() { // MapLoader.loadSector(new Vector2I(0, 0)); //SaveGame.Instance.RefreshScene(); instance = this; _properties = Resources.Load <WorldProperties>("World Properties"); _chunkPool = new Pool <ChunkWorldObject>(); Atlas.initialize(); ItemStore.initialize(); EntityStore.initialize(); RecipeManager.loadRecipes(); CollisionGrid.initialize(this, _properties.worldDimension * _properties.chunkDimension); TileStore.initialize(); Mesher.initialize(); int half = (_properties.worldDimension - 1) / 2; Vector2I spawnPos = new Vector2I(3, 3); _position = spawnPos - new Vector2I(half, half); // Create and initialize the map handler behaviour _mapHandler = new MapHandler(this, spawnPos); //_mapHandler.setPosition(new Vector2I(0, 0)); //_mapHandler.populateSectors(); //_mapHandler.updatePosition(new Vector2I(0, 0)); createWorld(); createLoader(spawnPos); //createLoader(spawnPos); if (SaveGame.Instance.IsSaveGame) { getPlayerPos(); } // TEMP CollisionGrid.rebuildMap(); return; for (int i = 0; i < 4; i++) { EntityItem entity = (EntityItem)EntityStore.createEntity(0); entity.itemID = i; entity.transform.position = new Vector3(5 + i, 10, 5); } }
public override void Update(GameTime gameTime, List <Sprite> sprites, CollisionGrid grid, Rectangle screenBounds) { //base.Update(gameTime, sprites); _timer += (float)gameTime.ElapsedGameTime.TotalSeconds; if (_timer > Lifespan) { IsRemoved = true; } if (OffScreen(screenBounds)) { IsRemoved = true; } Position.Y -= Velocity; }
public void UpdateVisible(CollisionGrid cg) { // All Team Friendly Units Are Visible BoundingFrustum frustum = new BoundingFrustum(Camera.View * Camera.Projection); // Update Units Predicate <RTSUnit> fFVU = (u) => { return(frustum.Intersects(u.BBox)); }; foreach (var um in FriendlyUnitModels) { um.UpdateInstances(G, GameplayController.IsUnitDead, fFVU); } Predicate <RTSUnit> fNFVU = (u) => { Point up = HashHelper.Hash(u.GridPosition, cg.numCells, cg.size); if (cg.GetFogOfWar(up.X, up.Y, teamIndex) != FogOfWar.Active) { return(false); } return(frustum.Intersects(u.BBox)); }; foreach (var um in NonFriendlyUnitModels) { um.UpdateInstances(G, GameplayController.IsUnitDead, UseFOW ? fNFVU : fFVU); } // Update Buildings Predicate <BoundingBox> fFVB = (b) => { return(frustum.Intersects(b)); }; foreach (var bm in FriendlyBuildingModels) { bm.UpdateInstances(G, fFVB); } foreach (var bm in NonFriendlyBuildingModels) { bm.UpdateInstances(G, fFVB); } }
public override void Update(GameTime gameTime, List <Sprite> sprites, CollisionGrid grid, Rectangle screenBounds) { //base.Update(gameTime, sprites); _previousKey = _currentKey; _currentKey = Keyboard.GetState(); //Direction = new Vector2((float)Math.Cos(_)) if (_currentKey.IsKeyDown(Keys.Up)) { Position.Y -= Velocity; } if (_currentKey.IsKeyDown(Keys.Down)) { Position.Y += Velocity; } if (_currentKey.IsKeyDown(Keys.Left)) { Position.X -= Velocity; } if (_currentKey.IsKeyDown(Keys.Right)) { Position.X += Velocity; } if (_currentKey.IsKeyDown(Keys.Space) && _previousKey.IsKeyUp(Keys.Space)) { var bullet = Bullet.Clone() as Bullet; bullet.Direction = this.Direction; bullet.Position = this.Position; bullet.Velocity = this.Velocity * 2; bullet.Lifespan = 2f; bullet.Parent = this; bullet.Type = SpriteType.PlayerBullet; sprites.Add(bullet); } }
public void SetAllFOW(FogOfWar f, CollisionGrid cg) { int i = f == FogOfWar.Nothing ? HEAT_NONE : (f == FogOfWar.Passive ? HEAT_PASSIVE : HEAT_PASSIVE + 1); for(int y = 0; y < cg.numCells.Y; y++) { for(int x = 0; x < cg.numCells.X; x++) { heat[x, y] = i; cg.SetFogOfWar(x, y, teamIndex, f); } } }
public void UpdateVisible(CollisionGrid cg) { // All Team Friendly Units Are Visible BoundingFrustum frustum = new BoundingFrustum(Camera.View * Camera.Projection); // Update Units Predicate<RTSUnit> fFVU = (u) => { return frustum.Intersects(u.BBox); }; foreach(var um in FriendlyUnitModels) um.UpdateInstances(G, GameplayController.IsUnitDead, fFVU); Predicate<RTSUnit> fNFVU = (u) => { Point up = HashHelper.Hash(u.GridPosition, cg.numCells, cg.size); if(cg.GetFogOfWar(up.X, up.Y, teamIndex) != FogOfWar.Active) return false; return frustum.Intersects(u.BBox); }; foreach(var um in NonFriendlyUnitModels) um.UpdateInstances(G, GameplayController.IsUnitDead, UseFOW ? fNFVU : fFVU); // Update Buildings Predicate<BoundingBox> fFVB = (b) => { return frustum.Intersects(b); }; foreach(var bm in FriendlyBuildingModels) bm.UpdateInstances(G, fFVB); foreach(var bm in NonFriendlyBuildingModels) bm.UpdateInstances(G, fFVB); }
public void Update(CollisionGrid map, float dt) { CameraMotionSettings cms = MovementSettings; Scroll(camController.ScrollX, camController.ScrollZ, cms, dt); Orbit(camController.Yaw, camController.Pitch, cms, dt); int z; camController.GetZoom(out z); Zoom(z, dt); camTarget.X = MathHelper.Clamp(camTarget.X, 0, map.size.X); camTarget.Z = MathHelper.Clamp(camTarget.Z, 0, map.size.Y); //camOrigin.Y = Grey.Vox.Region.HEIGHT * 0.5f; // MathHelper.Clamp(camOrigin.Y, 0, Grey.Vox.Region.HEIGHT); camTarget.Y = map.HeightAt(new Vector2(camOrigin.X, camTarget.Z)); bool reset; camController.GetResetDefault(out reset); if(reset) { Yaw = INITIAL_CAMERA_YAW; Pitch = INITIAL_CAMERA_PITCH; ZoomRatio = INITIAL_ZOOM_RATIO; } camOrigin = Tweens.LINEAR.GetValue(camOrigin, camTarget, TWEEN_FACTOR * dt); RecalculateView(map, MathHelper.Lerp(cms.MinDistance, cms.MaxDistance, ZoomRatio)); }
// View Matrix Recalculation public void RecalculateView(CollisionGrid map, float dist) { Matrix rot = Matrix.CreateRotationZ(Pitch) * Matrix.CreateRotationY(Yaw); Vector3 back = Vector3.TransformNormal(Vector3.UnitX, rot); back.Normalize(); Vector3 eye = CamOrigin + back * dist; //if(map != null) { // float h = map.HeightAt(eye.X, eye.Z); // if(eye.Y < h) // eye.Y = h + EYE_HEIGHT_OFFSET; //} View = Matrix.CreateLookAt(eye, CamOrigin, Vector3.Up); }
// TODO: Unstupify This Function // There Is A Straight-Line Path From A To B That Intersects No Collidable Objects (Ignores Dynamic Entities) private bool CoastIsClear(Vector2 a, Vector2 b, float stepSize, float radius, CollisionGrid cg) { Vector2 diff = b - a; float mag = diff.X != 0 && diff.Y != 0 ? diff.LengthSquared() : 1.0f; diff /= mag; Vector2 step = stepSize * diff; float root2 = 1.41421356237f; Func<bool> cont; if(a.X < b.X && a.Y < b.Y) { cont = () => { return a.X < b.X && a.Y < b.Y; }; } else if(a.X < b.X && a.Y > b.Y) { cont = () => { return a.X < b.X && a.Y > b.Y; }; } else if(a.X > b.X && a.Y < b.Y) { cont = () => { return a.X > b.X && a.Y < b.Y; }; } else { cont = () => { return a.X > b.X && a.Y > b.Y; }; } Vector2[] offsets = { new Vector2(radius, 0), new Vector2(radius / 2.0f, 0), new Vector2(-radius, 0), new Vector2(-radius / 2.0f, 0), new Vector2(0, radius), new Vector2(0, radius / 2.0f), new Vector2(0, -radius), new Vector2(0, -radius / 2.0f), (new Vector2(1, 1) / root2) * radius, (new Vector2(1, 1) / root2) * radius / 2.0f, (new Vector2(-1, 1) / root2) * radius, (new Vector2(-1, 1) / root2) * radius / 2.0f, (new Vector2(1, -1) / root2) * radius, (new Vector2(1, -1) / root2) * radius / 2.0f, (new Vector2(-1, -1) / root2) * radius, (new Vector2(-1, -1) / root2) * radius / 2.0f }; while(cont()) { bool collision = cg.GetCollision(a); foreach(var offset in offsets) { collision |= cg.GetCollision(a + offset); } if(collision) return false; a += step; } return true; }
// Clamp The Geometry To The Heightmap public static void CollideHeightmap(ICollidable o, CollisionGrid map) { if(!o.IsStatic) o.Height = map.HeightAt(o.Center); }
// TODO: Unstupify This Function // There Is A Straight-Line Path From A To B That Intersects No Collidable Objects (Ignores Dynamic Entities) private bool CoastIsClear(Vector2 a, Vector2 b, float stepSize, float radius, CollisionGrid cg) { Vector2 diff = b - a; float mag = diff.X != 0 && diff.Y != 0 ? diff.LengthSquared() : 1.0f; diff /= mag; Vector2 step = stepSize * diff; float root2 = 1.41421356237f; Func <bool> cont; if (a.X < b.X && a.Y < b.Y) { cont = () => { return(a.X < b.X && a.Y < b.Y); }; } else if (a.X < b.X && a.Y > b.Y) { cont = () => { return(a.X < b.X && a.Y > b.Y); }; } else if (a.X > b.X && a.Y < b.Y) { cont = () => { return(a.X > b.X && a.Y < b.Y); }; } else { cont = () => { return(a.X > b.X && a.Y > b.Y); }; } Vector2[] offsets = { new Vector2(radius, 0), new Vector2(radius / 2.0f, 0), new Vector2(-radius, 0), new Vector2(-radius / 2.0f, 0), new Vector2(0, radius), new Vector2(0, radius / 2.0f), new Vector2(0, -radius), new Vector2(0, -radius / 2.0f), (new Vector2(1, 1) / root2) * radius, (new Vector2(1, 1) / root2) * radius / 2.0f, (new Vector2(-1, 1) / root2) * radius, (new Vector2(-1, 1) / root2) * radius / 2.0f, (new Vector2(1, -1) / root2) * radius, (new Vector2(1, -1) / root2) * radius / 2.0f, (new Vector2(-1, -1) / root2) * radius, (new Vector2(-1, -1) / root2) * radius / 2.0f }; while (cont()) { bool collision = cg.GetCollision(a); foreach (var offset in offsets) { collision |= cg.GetCollision(a + offset); } if (collision) { return(false); } a += step; } return(true); }
private void SetNetForceAndWaypoint(GameState g) { CollisionGrid cg = g.CGrid; // TODO: Make The Routine Below Fast Enough To Use //int tempIdx = 0; //Vector2 waypoint = Waypoints[tempIdx]; //float r = unit.CollisionGeometry.BoundingRadius; //while(IsValid(tempIdx)) { // // Get The Waypoint Closest To The Goal That This Unit Can Straight-Shot // if(CoastIsClear(unit.GridPosition, waypoint, r, r, cg)) { // CurrentWaypointIndex = tempIdx; // break; // } // tempIdx++; //} Vector2 waypoint = Waypoints[CurrentWaypointIndex]; #if DEBUG Vector2 first = Waypoints[Waypoints.Count - 1]; Vector3 oFirst = new Vector3(first.X, g.CGrid.HeightAt(first), first.Y); g.AddParticle(new AlertParticle(oFirst, 1f, Color.Red, oFirst + Vector3.Up, 0.2f, Color.Green, g.TotalGameTime, 1f)); Vector3 oWP = new Vector3(waypoint.X, g.CGrid.HeightAt(waypoint), waypoint.Y); g.AddParticle(new AlertParticle(oWP, 1f, Color.Blue, oWP + Vector3.Up, 0.2f, Color.Purple, g.TotalGameTime, 3f)); #endif if (Query != null && !Query.IsOld && Query.IsComplete) { Query.IsOld = true; // Only Do This Once Per Query Waypoints = Query.waypoints; CurrentWaypointIndex = Waypoints.Count - 1; } // Set Net Force... NetForce = pForce * UnitForce(unit.GridPosition, waypoint); Point unitCell = HashHelper.Hash(unit.GridPosition, cg.numCells, cg.size); //// Apply Forces From Other Units In This One's Cell //foreach(var otherUnit in cg.EDynamic[unitCell.X, unitCell.Y]) { // NetForce += dForce * UnitForce(unit.GridPosition, otherUnit.GridPosition); //} //// Apply Forces From Buildings And Other Units Near This One //foreach(Point n in Pathfinder.Neighborhood(unitCell)) { // RTSBuilding b = cg.EStatic[n.X, n.Y]; // if(b != null) // NetForce += sForce * UnitForce(unit.GridPosition, b.GridPosition); // foreach(var otherUnit in cg.EDynamic[n.X, n.Y]) { // NetForce += sForce * UnitForce(unit.GridPosition, otherUnit.GridPosition); // } //} // Set Waypoint... Point currWaypointCell = HashHelper.Hash(waypoint, cg.numCells, cg.size); float sqr2 = unit.Squad.Radius(); sqr2 *= sqr2; bool inGoalCell = unitCell.X == currWaypointCell.X && unitCell.Y == currWaypointCell.Y; bool withinCellDistSq = (waypoint - unit.GridPosition).LengthSquared() < cg.cellSize; bool withinSquad = (waypoint - unit.GridPosition).LengthSquared() < 1.5 * sqr2; if (inGoalCell || (!wasStuck && (withinSquad || withinCellDistSq))) { CurrentWaypointIndex--; if (CurrentWaypointIndex < 0) { Waypoints = null; } wasStuck = false; } }
public ScanTask(int s, int e, CollisionGrid g, RTSTeam t, Queue<SeenEntity> q) : base(1) { xs = s; xe = e; cg = g; team = t; queue = q; lastAdded = 0; }
/// <summary> /// Initialize the CollisionChief. /// </summary> /// <param name="worldSize">The size, in pixels, of the map. This defines the size of the collision grid.</param> /// <param name="cellSize">The size, in pixels, of a single cell in the collision grid.</param> public void Initialize(Vector2 worldSize, Vector2 cellSize) { int numXCells; int numYCells; mWorldSize = worldSize; mCellSize = cellSize; numXCells = (int)(mWorldSize.X / mCellSize.X); if (mWorldSize.X % mCellSize.X > 0) { numXCells++; } numYCells = (int)(mWorldSize.Y / mCellSize.Y); if (mWorldSize.Y % mCellSize.Y > 0) { numYCells++; } mCollisionGrid = new CollisionGrid(numXCells, numYCells); mUnitsToUpdate = new List<CollisionUnit>(); mEntitiesToNotify = new List<Entity>(); mCurrTimeStamp = 0; }
public virtual void Update(GameTime gameTime, List <Sprite> sprites, CollisionGrid grid, Rectangle screenBounds) { //if ((Position.X + Width) > screenBounds.Width || Position.X < 0 || (Position.Y + Height) > screenBounds.Height || Position.Y < 0) // IsRemoved = true; }
//Item Factory constructor public EnemyModelFactory(ItemEnemySpriteFactory itemEnemySpriteFactory, CollisionGrid collisionGrid) { ItemEnemySpriteFactory = itemEnemySpriteFactory; CollisionGrid = collisionGrid; }
public override void DoWork(float dt) { RTSTeam team = state.teams[teamIndex]; CollisionGrid cg = state.CGrid; // Generate All The Old FOW int[,] val = new int[cg.numCells.X, cg.numCells.Y]; for (int y = 0; y < cg.numCells.Y; y++) { for (int x = 0; x < cg.numCells.X; x++) { // Set To Passive If There Was Some Visibility if (heat[x, y] > HEAT_NONE) { val[x, y] = HEAT_PASSIVE * 10; } else { val[x, y] = 0; } } } // Add Starting Points To The Queue var queue = new Queue <FOWPoint>(); for (int i = 0; i < team.Units.Count; i++) { Point p = HashHelper.Hash(team.Units[i].GridPosition, cg.numCells, cg.size); int vRadius = (int)(team.Units[i].Data.BaseCombatData.MaxRange / cg.cellSize); vRadius *= 10; if (val[p.X, p.Y] < vRadius) { queue.Enqueue(new FOWPoint(p.X, p.Y, TravelDirection.PXPY, vRadius)); queue.Enqueue(new FOWPoint(p.X, p.Y, TravelDirection.NXNY, vRadius)); queue.Enqueue(new FOWPoint(p.X, p.Y, TravelDirection.NXPY, vRadius)); queue.Enqueue(new FOWPoint(p.X, p.Y, TravelDirection.PXNY, vRadius)); queue.Enqueue(new FOWPoint(p.X, p.Y, TravelDirection.PX, vRadius)); queue.Enqueue(new FOWPoint(p.X, p.Y, TravelDirection.NX, vRadius)); queue.Enqueue(new FOWPoint(p.X, p.Y, TravelDirection.PY, vRadius)); queue.Enqueue(new FOWPoint(p.X, p.Y, TravelDirection.NY, vRadius)); cg.SetFogOfWar(p.X, p.Y, teamIndex, FogOfWar.Active); val[p.X, p.Y] = vRadius; } } for (int i = 0; i < team.Buildings.Count; i++) { Point p = HashHelper.Hash(team.Buildings[i].GridPosition, cg.numCells, cg.size); int vRadius = (int)(team.Buildings[i].Data.SightRadius / cg.cellSize); vRadius *= 10; if (val[p.X, p.Y] < vRadius) { queue.Enqueue(new FOWPoint(p.X, p.Y, TravelDirection.PXPY, vRadius)); queue.Enqueue(new FOWPoint(p.X, p.Y, TravelDirection.NXNY, vRadius)); queue.Enqueue(new FOWPoint(p.X, p.Y, TravelDirection.NXPY, vRadius)); queue.Enqueue(new FOWPoint(p.X, p.Y, TravelDirection.PXNY, vRadius)); queue.Enqueue(new FOWPoint(p.X, p.Y, TravelDirection.PX, vRadius)); queue.Enqueue(new FOWPoint(p.X, p.Y, TravelDirection.NX, vRadius)); queue.Enqueue(new FOWPoint(p.X, p.Y, TravelDirection.PY, vRadius)); queue.Enqueue(new FOWPoint(p.X, p.Y, TravelDirection.NY, vRadius)); cg.SetFogOfWar(p.X, p.Y, teamIndex, FogOfWar.Active); val[p.X, p.Y] = vRadius; } } // Fan Out Heat while (queue.Count > 0) { FOWPoint fp = queue.Dequeue(); if (InBounds(cg.numCells.X, cg.numCells.Y, ref fp) && val[fp.X, fp.Y] < fp.TravelAmount) { val[fp.X, fp.Y] = fp.TravelAmount; AddPoints(cg.numCells.X, cg.numCells.Y, val, queue, ref fp); } } // Set The Fog Of War To The Grid for (int y = 0; y < cg.numCells.Y; y++) { for (int x = 0; x < cg.numCells.X; x++) { FogOfWar f = cg.GetFogOfWar(x, y, teamIndex); val[x, y] /= 10; switch (val[x, y]) { case HEAT_PASSIVE: if (f != FogOfWar.Passive) { cg.SetFogOfWar(x, y, teamIndex, FogOfWar.Passive); } break; case 0: // Black, But Don't Do Anything break; default: // Active if (f != FogOfWar.Active) { cg.SetFogOfWar(x, y, teamIndex, FogOfWar.Active); } break; } } } heat = val; }