示例#1
0
        private async Task LimitPlayArea()
        {
            var remainingTiles = Locations.Count(x => !x.IsDeadly);

            if (remainingTiles == 1)
            {
                return;
            }

            await Task.Delay(1000);

            if (remainingTiles == 4 || remainingTiles == 2)
            {
                var location = Locations.Where(x => !x.IsDeadly).OrderBy(x => Guid.NewGuid()).FirstOrDefault();
                if (location != null)
                {
                    location.IsDeadly    = true;
                    location.Environment = location.Directions.FirstOrDefault(x => x.Value.IsDeadly).Value.Environment;
                    Notificator.GameAreaIsReduced();
                }

                return;
            }

            if (remainingTiles == 3)
            {
                var location = Locations.Where(x => !x.IsDeadly).FirstOrDefault(x => x.Directions.Count(y => y.Value.IsDeadly) == 3);

                if (location != null)
                {
                    location.IsDeadly    = true;
                    location.Environment = location.Directions.FirstOrDefault(x => x.Value.IsDeadly).Value.Environment;
                    Notificator.GameAreaIsReduced();
                }

                return;
            }

            foreach (var location in Locations.Where(x => x.IsDeadly).ToList())
            {
                foreach (var next in location.Directions)
                {
                    next.Value.IsDeadly    = true;
                    next.Value.Environment = location.Environment;
                }
            }

            Notificator.GameAreaIsReduced();
            Logger.Log(this, "Området er redusert");
        }