Esempio n. 1
0
        private void Start()
        {
            fb         = GetComponent <FieldBehaviour>();
            controller = new GameInputProcessor(fb);

            var savedExePath = PlayerPrefs.GetString(PrefKeyBotExe, "");

            if (savedExePath != "")
            {
                botExePath          = savedExePath;
                manager             = new BotManager(botExePath, controller, botIndex);
                botExePathText.text = System.IO.Path.GetFileName(botExePath);
            }

            fb.ResetField += () => {
                manager?.Dispose();
            };

            fb.Initialized += () => {
                if (!string.IsNullOrEmpty(botExePath))
                {
                    manager = new BotManager(botExePath, controller, botIndex);
                    manager.Launch(fb);
                }
            };
        }
Esempio n. 2
0
 public BotManager(string pathToExecutable, GameInputProcessor controller, int botIndex)
 {
     this.botIndex         = botIndex;
     this.pathToExecutable = pathToExecutable;
     this.controller       = controller;
     semaphore             = new SemaphoreSlim(1, 1);
     logPathDir            = System.IO.Path.GetDirectoryName(Application.consoleLogPath);
 }
        public static void InitFiltedInput(PlayerEntity player, IGameStateProcessorFactory gameStateProcessorFactory)
        {
            var stateProviderPool = gameStateProcessorFactory.GetProviderPool() as StateProviderPool;
            var statePool         = gameStateProcessorFactory.GetStatePool();

            if (null != stateProviderPool)
            {
                stateProviderPool.AddStateProvider(player, statePool);
            }
            else
            {
                Logger.Error("state provider pool is null !!");
            }
            var gameInputProcessor = new GameInputProcessor(new UserCommandMapper(),
                                                            new StateProvider(new PlayerStateAdapter(player), statePool),
                                                            new FilteredInput());

            player.AddUserCmdFilter(gameInputProcessor);
        }