public static void CreateFire(int x, int y, StateSpaceComponents spaceComponents, DungeonTile[,] dungeonGrid) { dungeonGrid[x, y].ChanceToIgnite = 0; spaceComponents.DelayedActions.Add(new Action(() => { dungeonGrid[x, y].Type = TileType.TILE_FIRE; dungeonGrid[x, y].Symbol = Tiles.FireSymbol; dungeonGrid[x, y].SymbolColor = Tiles.FireSymbolColor; dungeonGrid[x, y].TurnsToBurn = spaceComponents.random.Next(3, 10); dungeonGrid[x, y].ChanceToIgnite = Tiles.FireIgniteChance; if (dungeonGrid[x, y].AttachedEntity == Guid.Empty) { Guid idFire = spaceComponents.CreateEntity(); spaceComponents.Entities.Where(c => c.Id == idFire).First().ComponentFlags = Component.COMPONENT_POSITION | Component.COMPONENT_SIGHTRADIUS; spaceComponents.PositionComponents[idFire] = new PositionComponent() { Position = new Vector2(x, y) }; spaceComponents.SightRadiusComponents[idFire] = new SightRadiusComponent() { DrawRadius = true, CurrentRadius = 5, MaxRadius = 5 }; dungeonGrid[x, y].AttachedEntity = idFire; foreach (Guid id in spaceComponents.PositionComponents.Where(z => z.Value.Position == new Vector2(x, y)).Select(z => z.Key)) { if (spaceComponents.SkillLevelsComponents.ContainsKey(id)) { StatusSystem.ApplyBurnEffect(spaceComponents, id, StatusEffects.Burning.Turns, StatusEffects.Burning.MinDamage, StatusEffects.Burning.MaxDamage); } } } })); }
public static bool TryToMove(StateSpaceComponents spaceComponents, DungeonTile[,] dungeonGrid, PositionComponent newPosition, Guid attemptingEntity) { bool canMove = true; foreach (Guid id in spaceComponents.Entities.Where(x => (x.ComponentFlags & ComponentMasks.Collidable) == ComponentMasks.Collidable).Select(x => x.Id)) { if ((int)spaceComponents.PositionComponents[id].Position.X == (int)newPosition.Position.X && (int)spaceComponents.PositionComponents[id].Position.Y == (int)newPosition.Position.Y && id != attemptingEntity) { spaceComponents.CollisionComponents[attemptingEntity].CollidedObjects.Add(id); spaceComponents.GlobalCollisionComponent.EntitiesThatCollided.Add(attemptingEntity); if (spaceComponents.CollisionComponents[id].Solid && spaceComponents.CollisionComponents[attemptingEntity].Solid) { canMove = false; } } } if (canMove) { spaceComponents.PositionComponents[attemptingEntity] = newPosition; if (dungeonGrid[(int)newPosition.Position.X, (int)newPosition.Position.Y].Type == TileType.TILE_TALLGRASS && (spaceComponents.Entities.Where(x => (x.Id == attemptingEntity)).First().ComponentFlags & ComponentMasks.Observer) != ComponentMasks.Observer) { dungeonGrid[(int)newPosition.Position.X, (int)newPosition.Position.Y].Type = TileType.TILE_FLATTENEDGRASS; dungeonGrid[(int)newPosition.Position.X, (int)newPosition.Position.Y].Symbol = Tiles.FlatGrassSymbol; dungeonGrid[(int)newPosition.Position.X, (int)newPosition.Position.Y].SymbolColor = Tiles.FlatGrassSymbolColor; dungeonGrid[(int)newPosition.Position.X, (int)newPosition.Position.Y].ChanceToIgnite = Tiles.FlatGrassIgniteChance; } if (dungeonGrid[(int)newPosition.Position.X, (int)newPosition.Position.Y].Type == TileType.TILE_FIRE && (spaceComponents.Entities.Where(x => (x.Id == attemptingEntity)).First().ComponentFlags & ComponentMasks.Observer) != ComponentMasks.Observer) { spaceComponents.DelayedActions.Add(new Action(() => { //Burn effect damage is hardcoded for now StatusSystem.ApplyBurnEffect(spaceComponents, attemptingEntity, StatusEffects.Burning.Turns, StatusEffects.Burning.MinDamage, StatusEffects.Burning.MaxDamage); })); } } return(canMove); }