Exemplo n.º 1
1
 /// <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();
 }
Exemplo n.º 2
0
        private void DecreaseBot(object parameter)
        {
            BotDifficulty difficulty = (BotDifficulty)parameter;

            bots[difficulty] = bots[difficulty] - 1;

            NotifyNumberOfBotsChanged();
        }
Exemplo n.º 3
0
    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");
    }
Exemplo n.º 4
0
    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");
	}
Exemplo n.º 5
0
        private bool IsDecreaseBotEnabled(object parameter)
        {
            BotDifficulty difficulty = (BotDifficulty)parameter;

            if (0 < bots[difficulty])
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 6
0
	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;
	}
Exemplo n.º 7
0
    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;
    }
Exemplo n.º 8
0
        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;
        }
Exemplo n.º 9
0
    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;
    }
Exemplo n.º 10
0
	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;
	}
Exemplo n.º 11
0
	 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;
		}
	}
Exemplo n.º 12
0
    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;
        }
    }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
    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;
        }
    }
Exemplo n.º 15
0
        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]);
                    }
                }
            }
        }
Exemplo n.º 16
0
 void Start()
 {
     difficultyLevel = gameObject.GetComponent("BotDifficulty") as BotDifficulty;
     myTransform     = transform;
     target          = GameObject.FindWithTag("Player").transform;
 }
Exemplo n.º 17
0
        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;
            }
        }
Exemplo n.º 18
0
        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;
        }
Exemplo n.º 19
0
 /// <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]);
 }
Exemplo n.º 20
0
	 void Start()
	 {
		difficultyLevel = gameObject.GetComponent("BotDifficulty") as BotDifficulty;
		myTransform = transform; 
	 	target = GameObject.FindWithTag("Player").transform; 
	 }
Exemplo n.º 21
0
 protected void SetEnemyDifficulty(BotDifficulty difficulty)
 {
     // TODO
 }
Exemplo n.º 22
0
 protected void SetAllyDifficulty(BotDifficulty difficulty)
 {
     // TODO
 }
Exemplo n.º 23
0
    private void EditDifficulty(GameObject bot)
    {
        BotDifficulty tempDifficulty = bot.GetComponent("BotDifficulty") as BotDifficulty;

        tempDifficulty.botDifficulty = difficultyLevel;
    }
Exemplo n.º 24
0
 public Difficulty(WildSpawnType role, BotDifficulty botDifficulty, string json)
 {
     Role          = role;
     BotDifficulty = botDifficulty;
     Json          = json;
 }
Exemplo n.º 25
0
    private void CreateDifficulty(GameObject bot)
    {
        BotDifficulty tempDifficulty = bot.AddComponent("BotDifficulty") as BotDifficulty;

        tempDifficulty.botDifficulty = difficultyLevel;
    }