public void BotStep() { var botMotionEnable = this.BotMotionEnable; if (!botMotionEnable) { return; } BotStepLastTime = Bib3.Glob.StopwatchZaitMiliSictInt(); Task.Run(() => { BotStepLock.IfLockIsAvailableEnter(() => { Bot.Step(Bib3.Glob.StopwatchZaitMiliSictInt(), BrowserService); LogEntryWrite(new LogEntry { BotStepCompleted = Bot.StepLastReport?.Value, }); BotStepLastTime = Bib3.Glob.StopwatchZaitMiliSictInt(); Dispatcher.Invoke(() => { BotControl.Present(Bot); }); }); }); }
public void BotStep() { BotStepLastTime = Bib3.Glob.StopwatchZaitMiliSictInt(); var BotMotionEnable = this.BotMotionEnable; Bot.WindowHandle = PickWindowControl.PickLastWindowHandle; var serviceDelegate = ServiceDelegate; if (null == serviceDelegate) { return; } if (!(BotMotionEnable || TakeScreenshotWhenPaused)) { return; } Task.Run(() => { BotStepLock.InvokeIfNotLocked(() => { Bot.Step(BotMotionEnable, serviceDelegate); BotStepLastTime = Bib3.Glob.StopwatchZaitMiliSictInt(); Dispatcher.Invoke(() => { BotControl.Present(Bot); }); }); }); }
public static void StartBots() { using (var context = new ApplicationContext()) { foreach (var bot in context.Bots.Where(x => x.isWorking).ToList()) { BotControl control = new BotControl(); control.StartBot(bot.Token); } } }
private BotControl RenderBot(BotParticipant BotPlayer) { BotControl botPlayer = new BotControl(); botPlayer.PlayerName.Content = BotPlayer.SummonerName; var uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", BotPlayer.Champion + ".png"), UriKind.RelativeOrAbsolute); botPlayer.ProfileImage.Source = new BitmapImage(uriSource); botPlayer.BanButton.Tag = BotPlayer; botPlayer.BanButton.Click += KickAndBan_Click; return(botPlayer); }
// Use this for initialization protected override void Awake() { base.Awake(); control = gameObject.GetComponent <BotControl>(); doorsState = new Dictionary <int, bool>(); commandBuffer = new Queue <string>(); // Initialize closed doors. List <int> doors = mapWorld.GetDoors(); foreach (int d in doors) { doorsState[d] = false; } }
public async Task <IActionResult> AddBot(BotViewModel model) { BotControl control = new BotControl(); await _context.Bots.AddAsync(new Database.Models.Bot { BotId = control.StartBot(model.Token), isWorking = true, Title = model.Name, Token = model.Token }); await _context.SaveChangesAsync(); return(RedirectToAction("List")); }
private BotControl RenderBot(BotParticipant BotPlayer) { var botPlayer = new BotControl(); champions champ = champions.GetChampion(BotPlayer.SummonerInternalName.Split('_')[1]); var uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "champion", champ.name + ".png")); botPlayer.Width = 400; botPlayer.Margin = new Thickness(0, 0, 0, 5); botPlayer.PlayerName.Content = BotPlayer.SummonerName; botPlayer.ProfileImage.Source = new BitmapImage(uriSource); botPlayer.blueSide = BotPlayer.SummonerInternalName.Split('_')[2] == "100"; botPlayer.difficulty = BotPlayer.BotSkillLevel; botPlayer.cmbSelectDificulty.Visibility = Client.isOwnerOfGame ? Visibility.Visible : Visibility.Hidden; botPlayer.cmbSelectDificulty.Items.Add("Beginner"); botPlayer.cmbSelectDificulty.Items.Add("Intermediate"); botPlayer.cmbSelectDificulty.Items.Add("Doom"); botPlayer.cmbSelectDificulty.Items.Add("Intro"); botPlayer.cmbSelectDificulty.SelectedIndex = BotPlayer.BotSkillLevel; foreach (int bot in bots) { botPlayer.cmbSelectChamp.Items.Add(champions.GetChampion(bot).name); } botPlayer.cmbSelectChamp.Visibility = Client.isOwnerOfGame ? Visibility.Visible : Visibility.Hidden; botPlayer.cmbSelectChamp.SelectedItem = champ.name; botPlayer.BanButton.Visibility = Client.isOwnerOfGame ? Visibility.Visible : Visibility.Hidden; botPlayer.BanButton.Tag = BotPlayer; botPlayer.BanButton.Click += KickAndBan_Click; botPlayer.cmbSelectChamp.SelectionChanged += async(a, b) => { champions c = champions.GetChampion((string)botPlayer.cmbSelectChamp.SelectedValue); await Client.PVPNet.RemoveBotChampion(champ.id, BotPlayer); AddBot(c.id, botPlayer.blueSide, botPlayer.difficulty); }; botPlayer.cmbSelectDificulty.SelectionChanged += async(a, b) => { champions c = champions.GetChampion((string)botPlayer.cmbSelectChamp.SelectedValue); await Client.PVPNet.RemoveBotChampion(champ.id, BotPlayer); AddBot(c.id, botPlayer.blueSide, botPlayer.cmbSelectDificulty.SelectedIndex); }; return(botPlayer); }
public async Task <IActionResult> StartBot(int id) { if (id > 0) { var bot = await _context.Bots.FirstOrDefaultAsync(x => x.Id == id); if (bot != null && !bot.isWorking) { BotControl control = new BotControl(); control.StartBot(bot.Token); bot.isWorking = true; _context.Bots.Update(bot); await _context.SaveChangesAsync(); } } return(RedirectToAction("List")); }
void TimerElapsedLocked() { ProcessInput(); var licenseClientConfig = (ConfigFromViewToModel()?.LicenseClient).CompletedWithDefault().WithRequestLicenseKey(LicenseKeyStore?.Load() ?? ExeConfig.ConfigLicenseKeyDefault); Task.Run(() => { var exchangeReport = InterfaceServerDispatcher?.Exchange(licenseClientConfig, null == AppInterface ? (int?)null : 1000); if (null != exchangeReport) { LogEntryWrite(new LogEntry { InterfaceServerDispatcherExchange = exchangeReport, }); } }); EnsureAppInterfaceLogged(); PresentUI(); var botStepLastAge = Bib3.Glob.StopwatchZaitMiliSictInt() - BotStepLastTime; if (!(botStepLastAge < BotStepDistance)) { BotStep(); } var browserProcessCreationLast = this.BrowserProcessCreationLast; Task.Run(() => { if (null != browserProcessCreationLast?.Value && BrowserConnectionMeasureLocationRateLimitState.AttemptPassStopwatchMilli(3000)) { browserProcessCreationLast.Value.DocumentLocationHrefMeasurementLast = FarmManager.Extension.InvokeTimespanFromStopwatchMilli(() => browserProcessCreationLast?.Value?.BrowserConnectionOrError?.Result?.Document?.Result?.locationHref); } }); if (BotPresentRateLimitState.AttemptPassStopwatchMilli(1000)) { BotControl.Present(Bot); } if (InputBrowserProcessStartAutomaticEnable && (browserProcessCreationLast?.Begin ?? 0) < BotStepLastTime) { var botRequestBrowserProcessStart = Bot?.StepLastReport?.Value?.RequestBrowserProcessStart; if (0 < botRequestBrowserProcessStart?.Length) { if (BrowserProcessStartAutomaticRateLimitState.AttemptPassStopwatchMilli(BrowserStartAutomaticDistanceMin)) { BrowserProcessCreate("Bot: " + botRequestBrowserProcessStart); } } } }
// Use this for initialization protected override void Awake() { base.Awake(); control = gameObject.GetComponent<BotControl>(); doorsState = new Dictionary<int, bool>(); commandBuffer = new Queue<string>(); // Initialize closed doors. List<int> doors = mapWorld.GetDoors(); foreach (int d in doors) { doorsState[d] = false; } }
private BotControl parentControl; /**< A reference to a BotControl instance. */ // Use this for initialization void Awake() { parentControl = gameObject.GetComponent <BotControl>(); actions = new Dictionary <string, Action <string[]> >(); }
protected void Awake() { // Extract the controller component from the parent object. parentControl = gameObject.transform.parent.gameObject.GetComponent <BotControl> (); objectInMesh = new List <GameObject> (); }
private void GameLobby_OnMessageReceived(object sender, object message) { if (message == null) { return; } if (message.GetType() != typeof(GameDTO)) { return; } var dto = message as GameDTO; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async() => { if (!HasConnectedToChat) { //Run once BaseMap map = BaseMap.GetMap(dto.MapId); MapLabel.Content = map.DisplayName; ModeLabel.Content = Client.TitleCaseString(dto.GameMode); GameTypeConfigDTO configType = Client.LoginPacket.GameTypeConfigs.Find(x => x.Id == dto.GameTypeConfigId); TypeLabel.Content = GetGameMode(configType.Id); SizeLabel.Content = dto.MaxNumPlayers / 2 + "v" + dto.MaxNumPlayers / 2; HasConnectedToChat = true; try { string obfuscatedName = Client.GetObfuscatedChatroomName(dto.Name.ToLower() + Convert.ToInt32(dto.Id), ChatPrefixes.Arranging_Practice); string jid = Client.GetChatroomJID(obfuscatedName, dto.RoomPassword, false); newRoom = Client.ConfManager.GetRoom(new JID(jid)); newRoom.Nickname = Client.LoginPacket.AllSummonerData.Summoner.Name; newRoom.OnRoomMessage += newRoom_OnRoomMessage; newRoom.OnParticipantJoin += newRoom_OnParticipantJoin; newRoom.Join(dto.RoomPassword); } catch { } } switch (dto.GameState) { case "TEAM_SELECT": { bool isSpectator = false; OptomisticLock = dto.OptimisticLock; LaunchedTeamSelect = false; BlueTeamListView.Items.Clear(); PurpleTeamListView.Items.Clear(); SpectatorListView.Items.Clear(); foreach (Participant playerTeam in dto.TeamOne) { if (playerTeam is PlayerParticipant) { var lobbyPlayer = new CustomLobbyPlayer(); var player = playerTeam as PlayerParticipant; lobbyPlayer = RenderPlayer(player, dto.OwnerSummary.SummonerId == player.SummonerId); Client.isOwnerOfGame = dto.OwnerSummary.SummonerId == Client.LoginPacket.AllSummonerData.Summoner.SumId; StartGameButton.IsEnabled = Client.isOwnerOfGame; AddBotBlueTeam.IsEnabled = Client.isOwnerOfGame; AddBotPurpleTeam.IsEnabled = Client.isOwnerOfGame; BlueTeamListView.Items.Add(lobbyPlayer); if (Client.Whitelist.Count <= 0) { continue; } if (!Client.Whitelist.Contains(player.SummonerName.ToLower())) { await Client.PVPNet.BanUserFromGame(Client.GameID, player.AccountId); } } else if (playerTeam is BotParticipant) { var botParticipant = playerTeam as BotParticipant; var botPlayer = new BotControl(); botPlayer = RenderBot(botParticipant); BlueTeamListView.Items.Add(botPlayer); } } foreach (Participant playerTeam in dto.TeamTwo) { if (playerTeam is PlayerParticipant) { var lobbyPlayer = new CustomLobbyPlayer(); var player = playerTeam as PlayerParticipant; lobbyPlayer = RenderPlayer(player, dto.OwnerSummary.SummonerId == player.SummonerId); Client.isOwnerOfGame = dto.OwnerSummary.SummonerId == Client.LoginPacket.AllSummonerData.Summoner.SumId; StartGameButton.IsEnabled = Client.isOwnerOfGame; AddBotBlueTeam.IsEnabled = Client.isOwnerOfGame; AddBotPurpleTeam.IsEnabled = Client.isOwnerOfGame; PurpleTeamListView.Items.Add(lobbyPlayer); if (Client.Whitelist.Count <= 0) { continue; } if (!Client.Whitelist.Contains(player.SummonerName.ToLower())) { await Client.PVPNet.BanUserFromGame(Client.GameID, player.AccountId); } } else if (playerTeam is BotParticipant) { var botParticipant = playerTeam as BotParticipant; var botPlayer = new BotControl(); botPlayer = RenderBot(botParticipant); PurpleTeamListView.Items.Add(botPlayer); } } foreach (GameObserver observer in dto.Observers) { if (observer.SummonerId == Client.LoginPacket.AllSummonerData.Summoner.SumId) { isSpectator = true; } var spectatorItem = new CustomLobbyObserver(); spectatorItem = RenderObserver(observer); SpectatorListView.Items.Add(spectatorItem); } if (isSpectator) { AddBotPurpleTeam.Visibility = Visibility.Hidden; AddBotBlueTeam.Visibility = Visibility.Hidden; JoinBlueTeamFromSpectator.Visibility = Visibility.Visible; JoinPurpleTeamFromSpectator.Visibility = Visibility.Visible; } else { AddBotPurpleTeam.Visibility = Visibility.Visible; AddBotBlueTeam.Visibility = Visibility.Visible; JoinBlueTeamFromSpectator.Visibility = Visibility.Hidden; JoinPurpleTeamFromSpectator.Visibility = Visibility.Hidden; } } break; case "PRE_CHAMP_SELECT": case "CHAMP_SELECT": if (!LaunchedTeamSelect) { Client.ChampSelectDTO = dto; Client.LastPageContent = Client.Container.Content; Client.SwitchPage(new ChampSelectPage(dto.RoomName, dto.RoomPassword).Load(this)); Client.GameStatus = "championSelect"; Client.SetChatHover(); LaunchedTeamSelect = true; } break; } })); }
private BotControl parentControl; /**< A reference to the IBotControl instance attache to the bot. */ #endregion Fields #region Methods // Use this for initialization protected override void Awake() { base.Awake(); parentControl = gameObject.transform.parent.gameObject.GetComponent<BotControl>(); }
private BotControl parentControl; /**< A reference to the IBotControl instance attache to the bot. */ // Use this for initialization protected override void Awake() { base.Awake(); parentControl = gameObject.transform.parent.gameObject.GetComponent <BotControl>(); }
private void GameLobby_OnMessageReceived(object sender, object message) { if (message.GetType() == typeof(GameDTO)) { GameDTO dto = message as GameDTO; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async() => { if (!HasConnectedToChat) { //Run once BaseMap map = BaseMap.GetMap(dto.MapId); MapLabel.Content = map.DisplayName; ModeLabel.Content = Client.TitleCaseString(dto.GameMode); GameTypeConfigDTO configType = Client.LoginPacket.GameTypeConfigs.Find(x => x.Id == dto.GameTypeConfigId); TypeLabel.Content = GetGameMode(configType.Id); SizeLabel.Content = dto.MaxNumPlayers / 2 + "v" + dto.MaxNumPlayers / 2; HasConnectedToChat = true; try { string ObfuscatedName = Client.GetObfuscatedChatroomName(dto.Name.ToLower() + Convert.ToInt32(dto.Id), ChatPrefixes.Arranging_Practice); string JID = Client.GetChatroomJID(ObfuscatedName, dto.RoomPassword, false); newRoom = Client.ConfManager.GetRoom(new jabber.JID(JID)); newRoom.Nickname = Client.LoginPacket.AllSummonerData.Summoner.Name; newRoom.OnRoomMessage += newRoom_OnRoomMessage; newRoom.OnParticipantJoin += newRoom_OnParticipantJoin; newRoom.Join(dto.RoomPassword); } catch { } } if (dto.GameState == "TEAM_SELECT") { OptomisticLock = dto.OptimisticLock; LaunchedTeamSelect = false; BlueTeamListView.Items.Clear(); PurpleTeamListView.Items.Clear(); List <Participant> AllParticipants = new List <Participant>(dto.TeamOne.ToArray()); AllParticipants.AddRange(dto.TeamTwo); int i = 0; bool PurpleSide = false; foreach (Participant playerTeam in AllParticipants) { i++; CustomLobbyPlayer lobbyPlayer = new CustomLobbyPlayer(); BotControl botPlayer = new BotControl(); if (playerTeam is PlayerParticipant) { PlayerParticipant player = playerTeam as PlayerParticipant; lobbyPlayer = RenderPlayer(player, dto.OwnerSummary.SummonerId == player.SummonerId); IsOwner = dto.OwnerSummary.SummonerId == Client.LoginPacket.AllSummonerData.Summoner.SumId; StartGameButton.IsEnabled = IsOwner; AddBotBlueTeam.IsEnabled = IsOwner; AddBotPurpleTeam.IsEnabled = IsOwner; if (Client.Whitelist.Count > 0) { if (!Client.Whitelist.Contains(player.SummonerName.ToLower())) { await Client.PVPNet.BanUserFromGame(Client.GameID, player.AccountId); } } } else if (playerTeam is BotParticipant) { BotParticipant botParticipant = playerTeam as BotParticipant; botPlayer = RenderBot(botParticipant); } if (i > dto.TeamOne.Count) { i = 0; PurpleSide = true; } if (!PurpleSide) { BlueTeamListView.Items.Add(lobbyPlayer); } else { PurpleTeamListView.Items.Add(lobbyPlayer); } } } else if (dto.GameState == "CHAMP_SELECT" || dto.GameState == "PRE_CHAMP_SELECT") { if (!LaunchedTeamSelect) { Client.ChampSelectDTO = dto; Client.LastPageContent = Client.Container.Content; Client.SwitchPage(new ChampSelectPage(this)); Client.GameStatus = "championSelect"; Client.SetChatHover(); LaunchedTeamSelect = true; } } })); } }
/** * Add an observer to the object. * * \param obs The observer controller. */ public void AddObserver(BotControl obs) { observers.Add(obs); }
/** * Remove an observer. * * \param obs The observer controller */ public void RemoveObserver(BotControl obs) { observers.Remove(obs); }
void Awake() { parentControl = gameObject.GetComponent<BotControl> (); actions = new Dictionary<string, Action<string[]>> (); }
protected void Awake() { // Extract the controller component from the parent object. parentControl = gameObject.transform.parent.gameObject.GetComponent<BotControl> (); objectInMesh = new List<GameObject> (); }