コード例 #1
0
        public static SymbolsImage GetCellImage(IAreaMapCell cell)
        {
            if (cell == null)
            {
                return(EmptyImage);
            }

            var objectsImages = cell.Objects
                                .Where(obj => obj.IsVisible)
                                .OrderBy(obj => obj.ZIndex)
                                .Select(GetObjectImage)
                                .Where(img => img != null)
                                .ToArray();

            var image = objectsImages.FirstOrDefault();

            if (image == null)
            {
                return(EmptyImage);
            }

            foreach (var objectImage in objectsImages.Skip(1))
            {
                image = CombineImages(image, objectImage);
            }

            image = LightLevelManager.ApplyLightLevel(image, cell.LightLevel);
            return(ApplyObjectEffects(cell, image));
        }
コード例 #2
0
 public bool CheckRequirements(IAreaMapCell cell)
 {
     if (requirements.Count == 0)
     {
         return(true);
     }
     return(requirements.All(requirement => requirement(cell)));
 }
コード例 #3
0
        private void ApplyOilyStatus(IAreaMapCell cell)
        {
            var destroyableObjects = cell.Objects.OfType <IDestroyableObject>();

            foreach (var destroyable in destroyableObjects)
            {
                destroyable.Statuses.Add(new OilyObjectStatus());
            }
        }
コード例 #4
0
        private void DrawMagicEnergy(int x, int y, IAreaMapCell cell)
        {
            if (cell == null)
            {
                return;
            }

            Surface.Print(x, y, new ColoredString(cell.MagicEnergyLevel().ToString(), Color.Blue, Color.Black));
            Surface.Print(x, y + 1, new ColoredString(cell.MagicDisturbanceLevel().ToString(), Color.Blue, Color.Black));
        }
コード例 #5
0
        private void DrawCell(int mapX, int mapY, IAreaMapCell cell)
        {
            var image = CellImageHelper.GetCellImage(cell);

            var realX = mapX * Program.MapCellImageSize;
            var realY = mapY * Program.MapCellImageSize;

            Surface.DrawImage(realX, realY, image, DefaultForegroundColor, DefaultBackgroundColor);

            DrawDebugData(realX, realY, cell);
        }
コード例 #6
0
        private void DrawTemperature(int x, int y, IAreaMapCell cell)
        {
            if (cell == null)
            {
                return;
            }

            var value = cell.Temperature() / 10;

            Surface.Print(x, y, new ColoredString(value.ToString(), Color.Red, Color.Black));
        }
コード例 #7
0
        private void DrawLightLevel(int x, int y, IAreaMapCell cell)
        {
            if (cell == null)
            {
                return;
            }

            var value = (int)cell.LightLevel;

            Surface.Print(x, y, new ColoredString(value.ToString(), Color.Yellow, Color.Black));
        }
コード例 #8
0
ファイル: AbstractLiquid.cs プロジェクト: Gvin/CodeMagic
        private void ProcessFreezing(Point position, IAreaMapCell cell)
        {
            var missingTemperature = Configuration.FreezingPoint - cell.Temperature();
            var volumeToRaiseTemp  = (int)Math.Floor(missingTemperature * Configuration.FreezingTemperatureMultiplier);
            var volumeToFreeze     = Math.Min(volumeToRaiseTemp, Volume);
            var heatGain           = (int)Math.Floor(volumeToFreeze / Configuration.FreezingTemperatureMultiplier);

            cell.Environment.Cast().Temperature += heatGain;
            Volume -= volumeToFreeze;

            CurrentGame.Map.AddObject(position, CreateIce(volumeToFreeze));
        }
コード例 #9
0
        private void ProcessBurning(IAreaMapCell cell)
        {
            if (cell.Temperature() < BurningTemperature)
            {
                var temperatureDiff   = BurningTemperature - cell.Temperature();
                var temperatureChange = Math.Min(temperatureDiff, heatSpeed);
                cell.Environment.Cast().Temperature += temperatureChange;
            }

            var burnedVolume = (int)Math.Ceiling(cell.Temperature() * burningRate);

            Volume -= burnedVolume;
        }
コード例 #10
0
ファイル: ShockSpellAction.cs プロジェクト: Gvin/CodeMagic
        private void ApplyShockToCell(int value, IAreaMapCell cell, Point position)
        {
            var heat = value * heatMultiplier;

            cell.Environment.Cast().Temperature += heat;

            var destroyableObjects = cell.Objects.OfType <IDestroyableObject>();

            foreach (var destroyable in destroyableObjects)
            {
                destroyable.Damage(position, value, Element.Electricity);
                CurrentGame.Journal.Write(new EnvironmentDamageMessage(destroyable, value, Element.Electricity), destroyable);
            }
        }
コード例 #11
0
 private void DrawDebugData(int realX, int realY, IAreaMapCell cell)
 {
     if (Settings.Current.DebugDrawTemperature)
     {
         DrawTemperature(realX, realY, cell);
     }
     if (Settings.Current.DebugDrawLightLevel)
     {
         DrawLightLevel(realX, realY + 1, cell);
     }
     if (Settings.Current.DebugDrawMagicEnergy)
     {
         DrawMagicEnergy(realX, realY + 1, cell);
     }
 }
コード例 #12
0
ファイル: AbstractLiquid.cs プロジェクト: Gvin/CodeMagic
        private void ProcessBoiling(Point position, IAreaMapCell cell)
        {
            var excessTemperature   = cell.Temperature() - Configuration.BoilingPoint;
            var volumeToLowerTemp   = (int)Math.Floor(excessTemperature * Configuration.EvaporationTemperatureMultiplier);
            var volumeToBecomeSteam = Math.Min(volumeToLowerTemp, Volume);
            var heatLoss            = (int)Math.Floor(volumeToBecomeSteam * Configuration.EvaporationTemperatureMultiplier);

            cell.Environment.Cast().Temperature -= heatLoss;
            Volume -= volumeToBecomeSteam;

            var steamVolume = volumeToBecomeSteam * Configuration.EvaporationMultiplier;

            cell.Environment.Cast().Pressure += steamVolume * Configuration.Steam.PressureMultiplier;

            CurrentGame.Map.AddObject(position, CreateSteam(steamVolume));
        }
コード例 #13
0
ファイル: AreaMap.cs プロジェクト: Gvin/CodeMagic
        public IAreaMapCell[][] GetMapPart(Point position, int radius)
        {
            var startIndexX    = position.X - radius;
            var startIndexY    = position.Y - radius;
            var visionDiameter = radius * 2 + 1;

            var result = new IAreaMapCell[visionDiameter][];

            for (var y = 0; y < visionDiameter; y++)
            {
                result[y] = new IAreaMapCell[visionDiameter];
                for (var x = 0; x < visionDiameter; x++)
                {
                    result[y][x] = TryGetCell(startIndexX + x, startIndexY + y);
                }
            }

            return(result);
        }
コード例 #14
0
        public AreaMapFragment GetVisibleArea()
        {
            if (cachedVisibleArea != null)
            {
                return(cachedVisibleArea);
            }

            var visibleArea = VisibilityHelper.GetVisibleArea(Player.VisibilityRange, PlayerPosition);

            if (visibleArea == null)
            {
                return(null);
            }

            if (Player.VisibilityRange == Player.MaxVisibilityRange)
            {
                return(visibleArea);
            }

            var visibilityDifference = Player.MaxVisibilityRange - Player.VisibilityRange;
            var visibleAreaDiameter  = Player.MaxVisibilityRange * 2 + 1;
            var result = new IAreaMapCell[visibleAreaDiameter][];

            for (int y = 0; y < visibleAreaDiameter; y++)
            {
                result[y] = new IAreaMapCell[visibleAreaDiameter];
            }

            for (int y = 0; y < visibleArea.Height; y++)
            {
                for (int x = 0; x < visibleArea.Width; x++)
                {
                    var visibleAreaY = y + visibilityDifference;
                    var visibleAreaX = x + visibilityDifference;
                    result[visibleAreaY][visibleAreaX] = visibleArea.GetCell(x, y);
                }
            }

            cachedVisibleArea = new AreaMapFragment(result, visibleAreaDiameter, visibleAreaDiameter);
            return(cachedVisibleArea);
        }
コード例 #15
0
        private static void UpdateCellLightLevel(IAreaMap map, IAreaMapCell cell, Point position)
        {
            var lights = cell.Objects.OfType <ILightObject>()
                         .SelectMany(lightObject => lightObject.LightSources)
                         .Where(source => source.IsLightOn && source.LightPower > LightLevel.Darkness)
                         .ToArray();

            if (lights.Length == 0)
            {
                return;
            }

            var maxLightPower = lights.Max(light => light.LightPower);

            cell.LightLevel = (LightLevel)Math.Max((int)cell.LightLevel, (int)maxLightPower);

            SpreadLightLevel(map, Point.GetPointInDirection(position, Direction.North), maxLightPower);
            SpreadLightLevel(map, Point.GetPointInDirection(position, Direction.South), maxLightPower);
            SpreadLightLevel(map, Point.GetPointInDirection(position, Direction.West), maxLightPower);
            SpreadLightLevel(map, Point.GetPointInDirection(position, Direction.East), maxLightPower);
        }
コード例 #16
0
        private static SymbolsImage ApplyObjectEffects(IAreaMapCell cell, SymbolsImage image)
        {
            var bigObject = cell.Objects.OfType <IDestroyableObject>().FirstOrDefault(obj => obj.BlocksMovement);

            if (bigObject == null || !bigObject.ObjectEffects.Any())
            {
                return(image);
            }

            var latestEffect = bigObject.ObjectEffects
                               .OfType <ObjectEffect>()
                               .Where(rec => rec.CreatedAt + DamageMarksLifeTime > DateTime.Now)
                               .OrderByDescending(obj => obj.CreatedAt)
                               .FirstOrDefault();

            if (latestEffect == null)
            {
                return(image);
            }

            var effectImage = latestEffect.GetEffectImage(image.Width, image.Height, ImagesStorage.Current);

            return(SymbolsImage.Combine(image, effectImage));
        }
コード例 #17
0
 public static int MaxMagicEnergyLevel(this IAreaMapCell cell)
 {
     return(cell.Environment.MaxMagicEnergyLevel());
 }
コード例 #18
0
 public static int MagicDisturbanceLevel(this IAreaMapCell cell)
 {
     return(cell.Environment.MagicDisturbanceLevel());
 }
コード例 #19
0
 public static int Pressure(this IAreaMapCell cell)
 {
     return(cell.Environment.Pressure());
 }
コード例 #20
0
 public static int Temperature(this IAreaMapCell cell)
 {
     return(cell.Environment.Temperature());
 }
コード例 #21
0
 public bool CheckRequirements(int x, int y, IAreaMapCell cell)
 {
     return(pattern[y][x].CheckRequirements(cell));
 }
コード例 #22
0
ファイル: ChaseTargetStrategy.cs プロジェクト: Gvin/CodeMagic
 private IDestroyableObject GetTarget(IAreaMapCell cell)
 {
     return(cell.Objects.OfType <IDestroyableObject>().FirstOrDefault(targetStrategy.IsTarget));
 }
コード例 #23
0
 private static bool RequirementIsAny(IAreaMapCell cell)
 {
     return(true);
 }
コード例 #24
0
 private static bool RequirementIsEmpty(IAreaMapCell cell)
 {
     return(cell.Objects.All(obj => obj is FloorObject));
 }
コード例 #25
0
 private static bool RequirementNotBlocking(IAreaMapCell cell)
 {
     return(!cell.BlocksMovement);
 }
コード例 #26
0
 private static bool RequirementIsWall(IAreaMapCell cell)
 {
     return(cell.BlocksEnvironment && !cell.Objects.OfType <DoorBase>().Any());
 }
コード例 #27
0
ファイル: ShockSpellAction.cs プロジェクト: Gvin/CodeMagic
 private bool GetIfCellContainsWet(IAreaMapCell cell)
 {
     return(cell.Objects.OfType <IDestroyableObject>()
            .Any(obj => obj.Statuses.Contains(WetObjectStatus.StatusType)));
 }
コード例 #28
0
ファイル: ShockSpellAction.cs プロジェクト: Gvin/CodeMagic
 private bool GetIfCellConductsElectricity(IAreaMapCell cell)
 {
     return(GetIfCellContainsWater(cell) || GetIfCellContainsWet(cell));
 }
コード例 #29
0
ファイル: ShockSpellAction.cs プロジェクト: Gvin/CodeMagic
 private bool GetIfCellContainsWater(IAreaMapCell cell)
 {
     return(cell.Objects.OfType <WaterLiquid>().Any());
 }