/// <summary> /// Constructor called that clears the field and also draws the board. /// </summary> /// <param name="g">The Graphics of the panel it draws on.</param> /// <param name="difficulty">The Difficulty of the Bot!</param> public Board(Graphics g, BotDifficulty difficulty) { _graphics = g; _botDifficulty = difficulty; ClearField(); DrawField(); }
private void DecreaseBot(object parameter) { BotDifficulty difficulty = (BotDifficulty)parameter; bots[difficulty] = bots[difficulty] - 1; NotifyNumberOfBotsChanged(); }
public override void Start() { difficulty = transform.root.GetComponent("BotDifficulty") as BotDifficulty; turret = GameObject.Find(gameObject.transform.root.name + "TurretControl").transform; myTarget = GameObject.Find(GameObject.FindGameObjectWithTag("Player").name + "Turret").transform; shootRange = difficulty.ShootDistance; player = GameObject.Find(GameObject.FindGameObjectWithTag("Player").name + "Turret"); }
public override void Start () { difficulty = transform.root.GetComponent("BotDifficulty") as BotDifficulty; turret = GameObject.Find(gameObject.transform.root.name + "TurretControl").transform; myTarget = GameObject.Find(GameObject.FindGameObjectWithTag("Player").name + "Turret").transform; shootRange = difficulty.ShootDistance; player = GameObject.Find(GameObject.FindGameObjectWithTag("Player").name + "Turret"); }
private bool IsDecreaseBotEnabled(object parameter) { BotDifficulty difficulty = (BotDifficulty)parameter; if (0 < bots[difficulty]) { return(true); } return(false); }
public override void Start () { turretControl = GameObject.Find (gameObject.transform.root.name + "TurretControl").transform; difficulty = transform.root.GetComponent("BotDifficulty") as BotDifficulty; turretTraverseSpeed = difficulty.TurretTraverseSpeed; shootRange = difficulty.ShootDistance; WithinRange = GameObject.FindGameObjectWithTag("Bot").GetComponent("SetPosition") as SetPosition; player = GameObject.Find(GameObject.FindGameObjectWithTag("Player").name + "Chassis"); enemy = player.transform; }
public override void Start() { turretControl = GameObject.Find(gameObject.transform.root.name + "TurretControl").transform; difficulty = transform.root.GetComponent("BotDifficulty") as BotDifficulty; turretTraverseSpeed = difficulty.TurretTraverseSpeed; shootRange = difficulty.ShootDistance; WithinRange = GameObject.FindGameObjectWithTag("Bot").GetComponent("SetPosition") as SetPosition; player = GameObject.Find(GameObject.FindGameObjectWithTag("Player").name + "Chassis"); enemy = player.transform; }
private static void RequestDifficulty(WildSpawnType role, BotDifficulty botDifficulty, Difficulty difficulty) { string json = new Request(Session, BackendUrl).GetJson("/client/game/bot/difficulty/" + role.ToString() + "/" + botDifficulty.ToString()); if (string.IsNullOrEmpty(json)) { Debug.LogError("EmuTarkov.SinglePlayer: Received bot " + role.ToString() + " " + botDifficulty.ToString() + " difficulty data is NULL, using fallback"); return; } Debug.LogError("EmuTarkov.SinglePlayer: Sucessfully received bot " + role.ToString() + " " + botDifficulty.ToString() + " difficulty data"); difficulty.Json = json; }
private void Start() { turret = GameObject.Find(gameObject.transform.root.name + "TurretControl").transform; raySpawnPoint = GameObject.Find(gameObject.transform.root.name + "ShellSpawnPoint").transform; difficulty = transform.root.GetComponent("BotDifficulty") as BotDifficulty; turretTraverseSpeed = difficulty.TurretTraverseSpeed; shootRange = difficulty.ShootDistance; WithingRange = GameObject.FindGameObjectWithTag("Bot").GetComponent("SetPosition") as SetPosition; player = GameObject.Find(GameObject.FindGameObjectWithTag("Player").name + "Turret"); myTarget = player.transform; }
private void Start() { turret = GameObject.Find (gameObject.transform.root.name + "TurretControl").transform; raySpawnPoint = GameObject.Find (gameObject.transform.root.name + "ShellSpawnPoint").transform; difficulty = transform.root.GetComponent("BotDifficulty") as BotDifficulty; turretTraverseSpeed = difficulty.TurretTraverseSpeed; shootRange = difficulty.ShootDistance; WithingRange = GameObject.FindGameObjectWithTag("Bot").GetComponent("SetPosition") as SetPosition; player = GameObject.Find(GameObject.FindGameObjectWithTag("Player").name + "Turret"); myTarget = player.transform; }
void Update () { if(difficultyLevel == null) { difficultyLevel = gameObject.GetComponent("BotDifficulty") as BotDifficulty; } timer += Time.deltaTime; if((int)timer % (int)difficultyLevel.ReactionTime == 0) { Vector3 lookDir = target.position - myTransform.position; lookDir.y = 0; // zero the height difference myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(lookDir), rotationSpeed * Time.deltaTime); myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime; } }
void Update() { if (difficultyLevel == null) { difficultyLevel = gameObject.GetComponent("BotDifficulty") as BotDifficulty; } timer += Time.deltaTime; if ((int)timer % (int)difficultyLevel.ReactionTime == 0) { Vector3 lookDir = target.position - myTransform.position; lookDir.y = 0; // zero the height difference myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(lookDir), rotationSpeed * Time.deltaTime); myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime; } }
public static bool Prefix(ref string __result, BotDifficulty botDifficulty, WildSpawnType role) { foreach (Difficulty difficulty in BotSettings.Difficulties) { if (difficulty.Role == role && difficulty.BotDifficulty == botDifficulty) { __result = difficulty.Json; } } if (string.IsNullOrEmpty(__result)) { return(true); } return(false); }
private void SetDestination() { if (gameObject.renderer.enabled && (int)timer % 2 == 0) { waypoints[1] = targetBotPoint.transform; BotDifficulty.Difficulty difficultyLevel = GameObject.Find("GameInformation").GetComponent <GameInformation>().difficultyLevel; BotDifficulty difficultySettings = gameObject.AddComponent("BotDifficulty") as BotDifficulty; difficultySettings.botDifficulty = difficultyLevel; Vector3 target = GameObject.FindGameObjectWithTag("Player").transform.position; target.x += Random.Range(-15 * difficultySettings.ReactionTime, 15 * difficultySettings.ReactionTime); target.y += Random.Range(-15 * difficultySettings.ReactionTime, 15 * difficultySettings.ReactionTime); target.z += Random.Range(-15 * difficultySettings.ReactionTime, 15 * difficultySettings.ReactionTime); targetBotPoint.transform.position = target; } }
public void MoveBots(BotDifficulty difficulty) // перемещение ботов { foreach (var bot in bots) { if (difficulty == BotDifficulty.Easy && bot is EasyBot || difficulty == BotDifficulty.Medium && bot is MediumBot || difficulty == BotDifficulty.Hard && bot is HardBot) { if (((Bot)bot).canMove && ((Bot)bot).countStep < maxStepsInOneDirection) { Move(bot, ((Bot)bot).direction); } else { int direction = random.Next(0, 4); Move(bot, directionForBot[direction]); } } } }
void Start() { difficultyLevel = gameObject.GetComponent("BotDifficulty") as BotDifficulty; myTransform = transform; target = GameObject.FindWithTag("Player").transform; }
private void button1_Click(object sender, EventArgs e) { switch (aiSettings.ShowDialog()) { case (DialogResult.OK): { switch (aiSettings.Difficulty.ToLower()) { case "easy": { this.difficulty = BotDifficulty.Easy; break; } case "normal": { this.difficulty = BotDifficulty.Normal; break; } case "hard": { this.difficulty = BotDifficulty.Hard; break; } case "random": { this.difficulty = BotDifficulty.Random; break; } default: { this.difficulty = BotDifficulty.Normal; break; } } switch (aiSettings.Speed.ToLower()) { case "slow": { this.AIthoughtSpeed = 1000; break; } case "fast": { this.AIthoughtSpeed = 100; break; } case "super fast": { this.AIthoughtSpeed = 20; break; } default: { this.AIthoughtSpeed = 100; break; } } break; } default: break; } }
private void OnAddClick(object sender, RoutedEventArgs e) { try { path = TextBox_Path.Text; port = TextBox_Port.Text; token = TextBox_Token.Text; team = (Team)ComboBox_Team.SelectedIndex; championId = int.Parse(ComboBox_ID.Text); botDifficulty = (BotDifficulty)ComboBox_Difficulty.SelectedIndex; if (isInputPath) { using (StreamReader reader = new StreamReader(new FileStream(path + "/lockfile", FileMode.Open, FileAccess.Read, FileShare.ReadWrite), System.Text.Encoding.Default)) { string line = reader.ReadLine(); var colonCount = 0; var colonIndex = 0; for (var i = 0; i < line.Length; i++) { if (line[i].ToString() == ":") { colonCount++; if (colonCount == 3) { port = line.Substring(colonIndex + 1, i - colonIndex - 1); } if (colonCount == 4) { token = line.Substring(colonIndex + 1, i - colonIndex - 1); } colonIndex = i; } } } } Console.WriteLine("https://127.0.0.1:" + port + "/lol-lobby/v1/lobby/custom/bots"); ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult); request = (HttpWebRequest)WebRequest.Create("https://127.0.0.1:" + port + "/lol-lobby/v1/lobby/custom/bots"); request.Method = "POST"; request.ContentType = "application/json"; request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(new ASCIIEncoding().GetBytes("riot:" + token))); var postData = new { championId, botDifficulty = s_BotDifficulty[(int)botDifficulty], teamId = ((int)team * 100 + 100).ToString() }; string postBody = JsonConvert.SerializeObject(postData); byte[] byteArray = Encoding.UTF8.GetBytes(postBody); using (Stream reqStream = request.GetRequestStream()) { reqStream.Write(byteArray, 0, byteArray.Length); } } catch (Exception ex) { if (ex.InnerException != null) { Console.WriteLine(ex.InnerException.Message); Textblock_Outupt.Text = ex.InnerException.Message; } else { Console.WriteLine(ex.Message); Textblock_Outupt.Text = ex.Message; } return; } string responseStr = ""; try { using (WebResponse response = request.GetResponse()){ using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8)){ responseStr = reader.ReadToEnd(); } } } catch (WebException ex) { using (WebResponse response = ex.Response) { HttpWebResponse httpResponse = (HttpWebResponse)response; if (response == null) { Console.WriteLine(ex.ToString()); Textblock_Outupt.Text = ex.ToString(); } using (Stream data = response.GetResponseStream()) using (var reader = new StreamReader(data)){ string text = reader.ReadToEnd(); Console.WriteLine(text); Textblock_Outupt.Text = text; } } return; } if (responseStr == "") { responseStr = "添加成功"; } Console.WriteLine(responseStr); Textblock_Outupt.Text = responseStr; }
/// <summary> /// Extension method to get the string associated to a BotDifficulty /// </summary> /// <param name="difficulty">The bot difficulty</param> /// <returns>The bot difficulty as a readable string</returns> public static string GetString(this BotDifficulty difficulty) { string[] difficulties = { "Easy", "Normal", "Hard", "Cruel", "Random" }; return(difficulties[(int)difficulty]); }
void Start() { difficultyLevel = gameObject.GetComponent("BotDifficulty") as BotDifficulty; myTransform = transform; target = GameObject.FindWithTag("Player").transform; }
protected void SetEnemyDifficulty(BotDifficulty difficulty) { // TODO }
protected void SetAllyDifficulty(BotDifficulty difficulty) { // TODO }
private void EditDifficulty(GameObject bot) { BotDifficulty tempDifficulty = bot.GetComponent("BotDifficulty") as BotDifficulty; tempDifficulty.botDifficulty = difficultyLevel; }
public Difficulty(WildSpawnType role, BotDifficulty botDifficulty, string json) { Role = role; BotDifficulty = botDifficulty; Json = json; }
private void CreateDifficulty(GameObject bot) { BotDifficulty tempDifficulty = bot.AddComponent("BotDifficulty") as BotDifficulty; tempDifficulty.botDifficulty = difficultyLevel; }