コード例 #1
0
        /// <summary>
        /// Returns a reference to the <see cref="Tracker"/> class object.
        /// </summary>
        /// <param name="solver">The solver to be used by the returned tracker.</param>
        /// <param name="geocoder">The geocoder to be used by the returned tracker.</param>
        /// <param name="messageReporter">The messageReporter to be used by the returned
        /// tracker.</param>
        /// <returns>A new <see cref="Tracker"/> class instance.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="solver"/>,
        /// <paramref name="geocoder"/> or <paramref name="messageReporter"/> is a null
        /// reference.</exception>
        public Tracker GetTracker(
            IVrpSolver solver,
            IGeocoder geocoder,
            IMessageReporter messageReporter)
        {
            CodeContract.RequiresNotNull("solver", solver);
            CodeContract.RequiresNotNull("geocoder", geocoder);
            CodeContract.RequiresNotNull("messageReporter", messageReporter);

            _CheckSettings(_settings);

            var settings = new TrackingSettings
            {
                BreakTolerance = _settings.TrackingSettings.BreakTolerance ?? 0,
            };

            var uri     = new Uri(_settings.TrackingServiceInfo.RestUrl);
            var service = FeatureService.Create(uri, Server);
            var trackingServiceClient = new TrackingServiceClient(service);

            var trackingService        = new TrackingServiceClient(service);
            var synchronizationService = new SynchronizationService(trackingServiceClient);

            return(new Tracker(
                       settings,
                       trackingService,
                       synchronizationService,
                       solver,
                       geocoder,
                       messageReporter));
        }
コード例 #2
0
		public UpdatedPackageViewModelFactory(
			IPackageManagementService packageManagementService,
			ILicenseAcceptanceService licenseAcceptanceService,
			IMessageReporter messageReporter)
			: base(packageManagementService, licenseAcceptanceService, messageReporter)
		{
		}
コード例 #3
0
 public UpdatedPackageViewModelFactory(
     IPackageManagementService packageManagementService,
     ILicenseAcceptanceService licenseAcceptanceService,
     IMessageReporter messageReporter)
     : base(packageManagementService, licenseAcceptanceService, messageReporter)
 {
 }
コード例 #4
0
		public PackageUpdatesViewModel(
			IPackageManagementService packageManagementService,
			IMessageReporter messageReporter,
			ITaskFactory taskFactory)
			: base(packageManagementService, messageReporter, taskFactory)
		{
			this.packageManagementService = packageManagementService;
		}
コード例 #5
0
ファイル: PlayerBot.cs プロジェクト: Sequenta/SpurRoguelike
        public Turn MakeTurn(LevelView levelView, IMessageReporter messageReporter)
        {
            messageReporter.ReportMessage("Hey ho! I'm still breathing");



            return(Turn.Step((StepDirection)levelView.Random.Next(4)));
        }
コード例 #6
0
 public PackageUpdatesViewModel(
     IPackageManagementService packageManagementService,
     IMessageReporter messageReporter,
     ITaskFactory taskFactory)
     : base(packageManagementService, messageReporter, taskFactory)
 {
     this.packageManagementService = packageManagementService;
 }
コード例 #7
0
 public PackageViewModelFactory(
     IPackageManagementService packageManagementService,
     ILicenseAcceptanceService licenseAcceptanceService,
     IMessageReporter messageReport)
 {
     this.packageManagementService = packageManagementService;
     this.licenseAcceptanceService = licenseAcceptanceService;
     this.messageReporter          = messageReport;
 }
コード例 #8
0
 public UpdatedPackageViewModel(
     IPackage package,
     IPackageManagementService packageManagementService,
     ILicenseAcceptanceService licenseAcceptanceService,
     IMessageReporter messageReporter)
     : base(package, packageManagementService, licenseAcceptanceService, messageReporter)
 {
     this.packageManagementService = packageManagementService;
 }
コード例 #9
0
 public AvailablePackagesViewModel(
     IPackageManagementService packageManagementService,
     IMessageReporter messageReporter,
     ITaskFactory taskFactory)
     : base(packageManagementService, messageReporter, taskFactory)
 {
     IsSearchable       = true;
     ShowPackageSources = packageManagementService.HasMultiplePackageSources;
 }
コード例 #10
0
		public PackageViewModelFactory(
			IPackageManagementService packageManagementService,
			ILicenseAcceptanceService licenseAcceptanceService,
			IMessageReporter messageReporter)
		{
			this.PackageManagementService = packageManagementService;
			this.LicenseAcceptanceService = licenseAcceptanceService;
			this.MessageReporter = messageReporter;
		}
コード例 #11
0
		public AvailablePackagesViewModel(
			IPackageManagementService packageManagementService,
			IMessageReporter messageReporter,
			ITaskFactory taskFactory)
			: base(packageManagementService, messageReporter, taskFactory)
		{
			IsSearchable = true;
			ShowPackageSources = packageManagementService.HasMultiplePackageSources;
		}
コード例 #12
0
		public RecentPackagesViewModel(
			IPackageManagementService packageManagementService,
			IMessageReporter messageReporter,
			ITaskFactory taskFactory)
			: base(packageManagementService, messageReporter, taskFactory)
		{
			recentPackageRepository = packageManagementService.RecentPackageRepository;
			packageManagementService.PackageInstalled += PackageInstalled;
			packageManagementService.PackageUninstalled += PackageUninstalled;
		}
コード例 #13
0
ファイル: Slave.cs プロジェクト: KpyTuBepTu/SpurRoguelike
        public Turn MakeTurn(LevelView levelView, IMessageReporter messageReporter)
        {
            if (levelView.Player.Location == levelView.Field.GetCellsOfType(CellType.PlayerStart).Single())
            {
                lvlCount++;
                slave = new Slave(ref levelView, messageReporter, lvlCount);
            }

            return(slave.SlaveObjectives.Peek()());
        }
コード例 #14
0
 public RecentPackagesViewModel(
     IPackageManagementService packageManagementService,
     IMessageReporter messageReporter,
     ITaskFactory taskFactory)
     : base(packageManagementService, messageReporter, taskFactory)
 {
     recentPackageRepository = packageManagementService.RecentPackageRepository;
     packageManagementService.PackageInstalled   += PackageInstalled;
     packageManagementService.PackageUninstalled += PackageUninstalled;
 }
コード例 #15
0
        public Turn MakeTurn(LevelView levelView, IMessageReporter messageReporter)
        {
            UpdateInfo(levelView);
            if (State == null)
            {
                State = new StateIdle(this);
            }

            return(State.MakeTurn(levelView));
        }
コード例 #16
0
		public PackageUpdatesViewModel(
			IPackageManagementService packageManagementService,
			IMessageReporter messageReporter,
			ITaskFactory taskFactory)
			: this(
				packageManagementService,
				messageReporter,
				new LicenseAcceptanceService(),
				taskFactory)
		{
		}
コード例 #17
0
		public InstalledPackagesViewModel(
			IPackageManagementService packageManagementService,
			IMessageReporter messageReporter,
			ITaskFactory taskFactory)
			: base(packageManagementService, messageReporter, taskFactory)
		{
			packageManagementService.PackageInstalled += PackageInstalled;
			packageManagementService.PackageUninstalled += PackageUninstalled;
			
			GetActiveProjectManager();
		}
コード例 #18
0
 public PackageUpdatesViewModel(
     IPackageManagementService packageManagementService,
     IMessageReporter messageReporter,
     ITaskFactory taskFactory)
     : this(
         packageManagementService,
         messageReporter,
         new LicenseAcceptanceService(),
         taskFactory)
 {
 }
コード例 #19
0
        public Turn MakeTurn(LevelView levelView, IMessageReporter messageReporter)
        {
            var turn = gui.AskPlayerInput();

            if (turn == null)
            {
                gui.Exit();
            }

            return(turn);
        }
コード例 #20
0
        public InstalledPackagesViewModel(
            IPackageManagementService packageManagementService,
            IMessageReporter messageReporter,
            ITaskFactory taskFactory)
            : base(packageManagementService, messageReporter, taskFactory)
        {
            packageManagementService.PackageInstalled   += PackageInstalled;
            packageManagementService.PackageUninstalled += PackageUninstalled;

            GetActiveProjectManager();
        }
コード例 #21
0
 public PackagesViewModel(
     IPackageManagementService packageManagementService,
     ILicenseAcceptanceService licenseAcceptanceService,
     IMessageReporter messageReporter,
     ITaskFactory taskFactory)
     : this(
         packageManagementService,
         new PackageViewModelFactory(packageManagementService, licenseAcceptanceService, messageReporter),
         taskFactory)
 {
 }
コード例 #22
0
 public PackageUpdatesViewModel(
     IPackageManagementService packageManagementService,
     IMessageReporter messageReporter,
     ILicenseAcceptanceService licenseAcceptanceService,
     ITaskFactory taskFactory)
     : base(
         packageManagementService,
         new UpdatedPackageViewModelFactory(packageManagementService, licenseAcceptanceService, messageReporter),
         taskFactory)
 {
     this.packageManagementService = packageManagementService;
 }
コード例 #23
0
        protected ContentGenerator(IMessageReporter messageReporter,
                                   Configuration configuration)
        {
            _includeTopicTag = true;

            _context         = new Context(messageReporter, configuration);
            _configuration   = configuration;
            _messageReporter = messageReporter;

            MediaItems = new List <MediaItem>();
            TopicFiles = new List <string>();
        }
コード例 #24
0
		public PackageUpdatesViewModel(
			IPackageManagementService packageManagementService,
			IMessageReporter messageReporter,
			ILicenseAcceptanceService licenseAcceptanceService,
			ITaskFactory taskFactory)
			: base(
				packageManagementService,
				new UpdatedPackageViewModelFactory(packageManagementService, licenseAcceptanceService, messageReporter),
				taskFactory)
		{
			this.packageManagementService = packageManagementService;
		}
コード例 #25
0
ファイル: FastKillAi.cs プロジェクト: anaym/kontur.shpora
        public Turn Iteration(LevelView level, IMessageReporter messageReporter, out bool isAttack)
        {
            isAttack = false;
            var             monsterMap = new EnemyMap(level, 1);
            var             trapMap    = new TrapMap(level);
            var             travelMap  = Map.Sum(trapMap, WallMap);
            var             pathMap    = Map.Sum(monsterMap, travelMap);
            List <Location> path       = null;

            if (level.Player.Health < 50 && level.HealthPacks.Any())
            {
                path = pathMap.FindPath(level.Player.Location, level.HealthPacks.OrderBy(h => h.Location.Distance(level.Player.Location)).First().Location);
                messageReporter.ReportMessage("Healing");
            }
            else if (level.Monsters.Any(m => m.Location.IsInRange(level.Player.Location, 1)))
            {
                messageReporter.ReportMessage("Attack");
                isAttack = false;
                return(Turn.Attack(level.Monsters.First(m => m.Location.IsInRange(level.Player.Location, 1)).Location - level.Player.Location));
            }
            else if (level.Monsters.Any())
            {
                int i = 0;
                path = travelMap.FindPath(level.Player.Location, level
                                          .Monsters.OrderBy(h => h.Location.Distance(level.Player.Location)).First().Location);
                if (i > 10)
                {
                    return(Turn.None);
                }
                messageReporter.ReportMessage("Far attack");
            }
            else if (level.Player.Health < 100 && level.HealthPacks.Any())
            {
                messageReporter.ReportMessage("100 Healing");
                path = pathMap.FindPath(level.Player.Location, level.HealthPacks.OrderBy(h => h.Location.Distance(level.Player.Location)).First().Location);
            }
            else if (Math.Max(BestItem(level).AttackBonus, BestItem(level).DefenceBonus) > Math.Max(level.Player.TotalAttack - level.Player.Attack, level.Player.TotalDefence - level.Player.Defence))
            {
                path = pathMap.FindPath(level.Player.Location, BestItem(level).Location);
            }
            else
            {
                messageReporter.ReportMessage("Leave");
                var leaveMap = Map.Sum(travelMap, new BadObjectMap(level, (view, location) => level.Items.Any(i => i.Location.Equals(location)), view => level.Items.Select(i => i.Location), 1));
                path = leaveMap.FindPath(level.Player.Location, Exit);
            }
            if (path != null)
            {
                return(Turn.Step(path[1] - path[0]));
            }
            return(Turn.None);
        }
コード例 #26
0
        public PackageViewModel(
            IPackage package,
            IPackageManagementService packageManagementService,
            ILicenseAcceptanceService licenseAcceptanceService,
            IMessageReporter messageReporter)
        {
            this.package = package;
            this.sourcePackageRepository  = packageManagementService.ActivePackageRepository;
            this.packageManagementService = packageManagementService;
            this.licenseAcceptanceService = licenseAcceptanceService;
            this.messageReporter          = messageReporter;

            CreateCommands();
        }
コード例 #27
0
        public Turn MakeTurn(LevelView levelView, IMessageReporter messageReporter)
        {
            if (Ai == null || !levelView.Field.GetCellsOfType(CellType.Exit).First().Equals(Ai.Exit) || MonsterCount < levelView.Monsters.Count())
            {
                LevelIndex++;
                if (IsLastLevel(levelView))
                {
                    Ai = new ArenaDestroyerAi(levelView);
                }
                else if (AiFactories.ContainsKey(LevelIndex))
                {
                    Ai = AiFactories[LevelIndex].CreateBot(levelView, LevelIndex);
                }
                else
                {
                    Ai = AiFactories[AiFactories.Keys.OrderBy(k => Math.Abs(k - LevelIndex)).First()].CreateBot(levelView, LevelIndex);
                }
                history = new Queue <Location>(historySize);
            }
            MonsterCount = levelView.Monsters.Count();

            var isAttack = false;
            var action   = Ai.Iteration(levelView, messageReporter, out isAttack);

            if (!isAttack)
            {
                history.Enqueue(levelView.Player.Location);
                if (history.Count > historySize)
                {
                    history.Dequeue();
                    if (new HashSet <Location>(history).Count < (historySize * Ai.CriticalPercentageInactivity / 100))
                    {
                        messageReporter.ReportMessage("T");
                        history.Clear();
                        if (levelView.Monsters.Any(m => m.Location.IsInRange(levelView.Player.Location, 1)))
                        {
                            messageReporter.ReportMessage("A");
                            return(Turn.Attack(levelView.Monsters.First(m => m.Location.IsInRange(levelView.Player.Location, 1)).Location - levelView.Player.Location));
                        }
                        var solve = Ai.HandleCycle(levelView);
                        if (solve != null)
                        {
                            return(solve);
                        }
                        return(Turn.Step((StepDirection) new Random().Next(0, 4)));
                    }
                }
            }
            return(action);
        }
コード例 #28
0
ファイル: PlayerBot.cs プロジェクト: wingrime/SpurBot
        public Turn MakeTurn(LevelView levelView, IMessageReporter messageReporter)
        {
            level          = levelView;
            health         = levelView.Player.Health;
            playerLocation = levelView.Player.Location;
            totalAttack    = levelView.Player.TotalAttack;
            totalDefence   = levelView.Player.TotalDefence;
            selectedTurn   = Turn.None;
            levelView.Player.TryGetEquippedItem(out equippedItem);
            objective  = default(IView);
            pathFinder = new PathFinder(level, playerLocation);
            ResetTarget(ref targetMonster);

            Tick();
            return(selectedTurn);
        }
コード例 #29
0
        public Context(IMessageReporter messageReporter, Configuration configuration)
        {
            ProblemReporter = new ProblemReporter(messageReporter);
            Configuration   = configuration;

            SchemaSetManager = new SchemaSetManager(this);
            SchemaSetManager.Initialize();

            SourceCodeManager = new SourceCodeManager(this);
            SourceCodeManager.Initialize();

            TopicManager = new TopicManager(this);
            TopicManager.Initialize();

            DocumentationManager = new DocumentationManager(this);
            DocumentationManager.Initialize();
        }
コード例 #30
0
ファイル: Context.cs プロジェクト: sergey-steinvil/xsddoc
        public Context(IMessageReporter messageReporter, Configuration configuration)
        {
            ProblemReporter = new ProblemReporter(messageReporter);
            Configuration = configuration;

            SchemaSetManager = new SchemaSetManager(this);
            SchemaSetManager.Initialize();

            SourceCodeManager = new SourceCodeManager(this);
            SourceCodeManager.Initialize();

            TopicManager = new TopicManager(this);
            TopicManager.Initialize();

            DocumentationManager = new DocumentationManager(this);
            DocumentationManager.Initialize();
        }
コード例 #31
0
ファイル: Slave.cs プロジェクト: KpyTuBepTu/SpurRoguelike
        public Slave(ref LevelView level, IMessageReporter messageReporter, int lvl)
        {
            SlaveObjectives      = new Stack <Func <Turn> >();
            map                  = new Map(ref level);
            this.messageReporter = messageReporter;
            levelView            = level;
            this.lvl             = lvl;
            panicHealthValue     = 15 * lvl;
            isFinalRoom          = level.Monsters.Count() == 1 ? true : false;

            objectives = new List <Func <Turn> >();
            objectives.Add(GoToExit);
            objectives.Add(FindBestEquip);
            objectives.Add(MakeYourselfStronger);
            objectives.Add(GoHealYourself);

            NewLvlObjectives();
        }
コード例 #32
0
ファイル: SmartAi.cs プロジェクト: anaym/kontur.shpora
        public Turn Iteration(LevelView level, IMessageReporter reporter, out bool isAttack)
        {
            isAttack = false;
            Enviroment.Update(level, 3);
            var bonusIgnore = new BadObjectMap(level, (view, location) => level.Items.Any(i => i.Location.Equals(location)), view => level.Items.Select(i => i.Location), 1);
            var attackMap   = Map.Sum(Enviroment.WallMap, Enviroment.TrapMap, bonusIgnore);
            var travelMap   = Map.Sum(attackMap, Enviroment.EnemyMap);

            foreach (var heuristic in Heuristics)
            {
                var solve = heuristic.Solve(level, Enviroment, out isAttack);
                if (solve != null)
                {
                    return(solve);
                }
            }
            return(Turn.None);
        }
コード例 #33
0
        public Turn MakeTurn(LevelView levelView, IMessageReporter messageReporter)
        {
            messageReporter.ReportMessage("Hey ho! I'm still breathing");

            if (levelView.Random.NextDouble() < 0.1)
            {
                return(Turn.None);
            }

            var nearbyMonster = levelView.Monsters.FirstOrDefault(m => IsInAttackRange(levelView.Player.Location, m.Location));

            if (nearbyMonster.HasValue)
            {
                return(Turn.Attack(nearbyMonster.Location - levelView.Player.Location));
            }

            return(Turn.Step((StepDirection)levelView.Random.Next(4)));
        }
コード例 #34
0
ファイル: Tracker.cs プロジェクト: valuecreation/RoutePlanner
        /// <summary>
        /// Initializes a new instance of the <see cref="Tracker"/> class.
        /// </summary>
        /// <param name="settings">Settings to be used by the tracker.</param>
        /// <param name="trackingService">The tracking service client to be used to communicate
        /// with the tracking server.</param>
        /// <param name="synchronizationService">The synchronization service to be used for
        /// synchronizing data in the project and at the tracking service.</param>
        /// <param name="solver">The VRP solver to be used by the tracker.</param>
        /// <param name="geocoder">The geocoder to be used by the tracker.</param>
        /// <param name="messageReporter">The message reporter to be used for reporting
        /// tracking errors.</param>
        /// <exception cref="ArgumentNullException"><paramref name="settings"/>,
        /// <paramref name="trackingService"/>, <paramref name="synchronizationService"/>,
        /// <paramref name="solver"/>, <paramref name="geocoder"/> or
        /// <paramref name="messageReporter"/> is a null reference.</exception>
        internal Tracker(
            TrackingSettings settings,
            ITrackingService trackingService,
            ISynchronizationService synchronizationService,
            IVrpSolver solver,
            IGeocoder geocoder,
            IMessageReporter messageReporter)
        {
            CodeContract.RequiresNotNull("settings", settings);
            CodeContract.RequiresNotNull("trackingService", trackingService);
            CodeContract.RequiresNotNull("synchronizationService", synchronizationService);
            CodeContract.RequiresNotNull("solver", solver);
            CodeContract.RequiresNotNull("geocoder", geocoder);
            CodeContract.RequiresNotNull("messageReporter", messageReporter);

            _settings               = settings;
            _trackingService        = trackingService;
            _synchronizationService = synchronizationService;

            _solver = solver;

            _geocoder        = geocoder;
            _messageReporter = messageReporter;
        }
コード例 #35
0
 public ProblemReporter(IMessageReporter messageReporter)
 {
     _messageReporter = messageReporter;
 }
コード例 #36
0
        /// <summary>
        /// Returns a reference to the <see cref="Tracker"/> class object.
        /// </summary>
        /// <param name="solver">The solver to be used by the returned tracker.</param>
        /// <param name="geocoder">The geocoder to be used by the returned tracker.</param>
        /// <param name="messageReporter">The messageReporter to be used by the returned
        /// tracker.</param>
        /// <returns>A new <see cref="Tracker"/> class instance.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="solver"/>,
        /// <paramref name="geocoder"/> or <paramref name="messageReporter"/> is a null
        /// reference.</exception>
        public Tracker GetTracker(
            IVrpSolver solver,
            IGeocoder geocoder,
            IMessageReporter messageReporter)
        {
            CodeContract.RequiresNotNull("solver", solver);
            CodeContract.RequiresNotNull("geocoder", geocoder);
            CodeContract.RequiresNotNull("messageReporter", messageReporter);

            _CheckSettings(_settings);

            var settings = new TrackingSettings
            {
                BreakTolerance = _settings.TrackingSettings.BreakTolerance ?? 0,
            };

            var uri = new Uri(_settings.TrackingServiceInfo.RestUrl);
            var service = FeatureService.Create(uri, Server);
            var trackingServiceClient = new TrackingServiceClient(service);

            var trackingService = new TrackingServiceClient(service);
            var synchronizationService = new SynchronizationService(trackingServiceClient);

            return new Tracker(
                settings,
                trackingService,
                synchronizationService,
                solver,
                geocoder,
                messageReporter);
        }
コード例 #37
0
 public ContentGenerator(IMessageReporter messageReporter, Configuration configuration)
 {
     _context = new Context(messageReporter, configuration);
     MediaItems = new List<MediaItem>();
     TopicFiles = new List<string>();
 }
コード例 #38
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Tracker"/> class.
        /// </summary>
        /// <param name="settings">Settings to be used by the tracker.</param>
        /// <param name="trackingService">The tracking service client to be used to communicate
        /// with the tracking server.</param>
        /// <param name="synchronizationService">The synchronization service to be used for
        /// synchronizing data in the project and at the tracking service.</param>
        /// <param name="solver">The VRP solver to be used by the tracker.</param>
        /// <param name="geocoder">The geocoder to be used by the tracker.</param>
        /// <param name="messageReporter">The message reporter to be used for reporting
        /// tracking errors.</param>
        /// <exception cref="ArgumentNullException"><paramref name="settings"/>,
        /// <paramref name="trackingService"/>, <paramref name="synchronizationService"/>,
        /// <paramref name="solver"/>, <paramref name="geocoder"/> or
        /// <paramref name="messageReporter"/> is a null reference.</exception>
        internal Tracker(
            TrackingSettings settings,
            ITrackingService trackingService,
            ISynchronizationService synchronizationService,
            IVrpSolver solver,
            IGeocoder geocoder,
            IMessageReporter messageReporter)
        {
            CodeContract.RequiresNotNull("settings", settings);
            CodeContract.RequiresNotNull("trackingService", trackingService);
            CodeContract.RequiresNotNull("synchronizationService", synchronizationService);
            CodeContract.RequiresNotNull("solver", solver);
            CodeContract.RequiresNotNull("geocoder", geocoder);
            CodeContract.RequiresNotNull("messageReporter", messageReporter);

            _settings = settings;
            _trackingService = trackingService;
            _synchronizationService = synchronizationService;

            _solver = solver;

            _geocoder = geocoder;
            _messageReporter = messageReporter;
        }
コード例 #39
0
        public Turn Iteration(LevelView level, IMessageReporter reporter, out bool isAttack)
        {
            Enviroment.Update(level, 3);
            var bonusIgnore = new BadObjectMap(level, (view, location) => level.Items.Any(i => i.Location.Equals(location)), view => level.Items.Select(i => i.Location), 1);
            var attackMap   = Map.Sum(Enviroment.WallMap, Enviroment.TrapMap, bonusIgnore);
            var travelMap   = Map.Sum(attackMap, Enviroment.EnemyMap, bonusIgnore);

            if (level.Monsters.Any())
            {
                var monster        = level.Monsters.First();
                var enemyHp        = monster.Health;
                var healingHpLevel = 50;
                if (enemyHp < MonsterStartHp * 0.6) //если враг пытается отрегениться - забираем его аптечку))
                {
                    healingHpLevel = 60;
                }
                if (level.Player.Health < healingHpLevel && level.HealthPacks.Any())
                {
                    var path = travelMap.FindPath(level.Player.Location,
                                                  level.HealthPacks.OrderBy(h => h.Location.Distance(level.Player.Location)).First().Location);
                    isAttack = false;
                    if (path != null && path.Count > 1)
                    {
                        return(Turn.Step(path[1] - path[0]));
                    }
                    return(Turn.None);
                }
            }

            if (level.Monsters.Any(m => m.Location.IsInRange(level.Player.Location, 1)))
            {
                var monster = level.Monsters.Where(m => m.Location.IsInRange(level.Player.Location, 1)).OrderBy(m => m.Health).First();
                isAttack = true;
                return(Turn.Attack(monster.Location - level.Player.Location));
            }
            if (level.Monsters.Any())
            {
                var target  = level.Monsters.First().Location;
                var targets = target
                              .Near(3)
                              .Where(
                    p =>
                    p.X >= 0 && p.Y >= 0 && p.X < Enviroment.TravelMap.Width &&
                    p.Y < Enviroment.TravelMap.Height)
                              .Where(p => Enviroment.TravelMap.IsTravaible(p))
                              .OrderBy(p => p.Distance(target));

                foreach (var location in targets)
                {
                    var path = attackMap.FindPath(level.Player.Location, location);
                    isAttack = false;
                    if (path != null && path.Count > 1)
                    {
                        return(Turn.Step(path[1] - path[0]));
                    }
                }
            }
            if (!ExitIsClosed(level))
            {
                Enviroment = new Enviroment(level, 2);
                var path = travelMap.FindPath(level.Player.Location, Exit);
                isAttack = false;
                if (path == null || path.Count < 2)
                {
                    return(Turn.None);
                }
                return(Turn.Step(path[1] - path[0]));
            }
            isAttack = false;
            return(Turn.None);
        }
コード例 #40
0
ファイル: PlayerBot.cs プロジェクト: qoter/GameBot
 public Turn MakeTurn(LevelView levelView, IMessageReporter messageReporter)
 {
     return(automaton.CurrentAction.Invoke(levelView));
 }
コード例 #41
0
 public ContentGenerator(IMessageReporter messageReporter, Configuration configuration)
 {
     _context   = new Context(messageReporter, configuration);
     MediaItems = new List <MediaItem>();
     TopicFiles = new List <string>();
 }
コード例 #42
0
 public ShfbContentGenerator(IMessageReporter messageReporter,
                             Configuration configuration) : base(messageReporter, configuration)
 {
 }
コード例 #43
0
        // Contructor in case of custom culture info

        /// <summary>
        /// Initializes a new instance of the <see cref="TradeParser"/> class.
        /// </summary>
        /// <param name="cultureInfo">The culture information.</param>
        public TradeParser(string cultureInfo, IMessageReporter reporter = null)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo(cultureInfo);
            this.reporter = reporter ?? new DefaultReporter();
        }