private static void SafeQ(AIBaseClient enemy) { var range = enemy.GetRealAutoAttackRange(); var path = Extension.CircleCircleIntersection(VectorConversions.To2D(GameObjects.Player.Position), VectorConversions.To2D(enemy.Position), 300, range); if (path.Length > 0) { var qpos = path.MinBy(x => x.Distance(Game.CursorPos)); if (VectorConversions.To3D2(qpos).IsUnderEnemyTurret() || VectorConversions.To3D2(qpos).IsWall()) { return; } if (VectorConversions.To3D2(qpos).CountEnemyHeroesInRange(200) > 0) { return; } Q.Cast(qpos); } if (path.Length == 0) { var qpos = GameObjects.Player.Position.Extend(enemy.Position, -300f); if (qpos.IsUnderEnemyTurret() || qpos.IsWall()) { return; } Q.Cast(GameObjects.Player.Position.Extend(enemy.Position, -300)); } }
public void ConvertToAndFromVector3() { var vector = new Vector(5.7, 6.6); var vector3 = VectorConversions.ToOgreVector(vector); var returnedVector = VectorConversions.FromOgreVector(vector3); Assert.AreEqual(vector, returnedVector); }
public IEnumerator Spy_Local_Position_Observation_OffSet() { var trainingInstanceController = GetDebugSetup(TrainingScenario.GuardAlert); trainingInstanceController.transform.position = new Vector3(100, 100, 100); SetBasicDebug(trainingInstanceController); yield return(new WaitUntil(() => trainingInstanceController.TestSetUpComplete)); var max = StaticFunctions.GetMaxLocalDistance(1); var frontRow = StaticFunctions.NormalisedFloat(-max, max, VectorConversions.GetLocalPosition(trainingInstanceController.TileDict[TileType.SpyTile][0].Position, trainingInstanceController).z); Assert.AreEqual(frontRow, trainingInstanceController.Guards[0].GetComponent <AlertGuardAgent>().GetSpyLocalPositions().Item2); }
public IEnumerator Spy_Nearest_Guards_All_Guards_OffSet() { var trainingInstanceController = GetDebugSetup(TrainingScenario.GuardAlert); SetDebugParameters(trainingInstanceController, 4, 0, 4, 3, false); trainingInstanceController.transform.position = new Vector3(100, 100, 100); yield return(new WaitUntil(() => trainingInstanceController.TestSetUpComplete)); var freeTiles = trainingInstanceController.TileDict[TileType.FreeTiles] .Concat(trainingInstanceController.TileDict[TileType.SpyTile]) .Concat(trainingInstanceController.TileDict[TileType.GuardTiles]).ToList(); var agentPosition1 = freeTiles.First(t => t.Coords == (7, 7)).Position; var agentPosition2 = freeTiles.First(t => t.Coords == (7, 8)).Position; var agentPosition3 = freeTiles.First(t => t.Coords == (7, 9)).Position; trainingInstanceController.Guards[0].transform.position = agentPosition1; trainingInstanceController.Guards[1].transform.position = agentPosition2; trainingInstanceController.Guards[2].transform.position = agentPosition3; var max = StaticFunctions.GetMaxLocalDistance(4); agentPosition1 = VectorConversions.GetLocalPosition(agentPosition1, trainingInstanceController); agentPosition2 = VectorConversions.GetLocalPosition(agentPosition2, trainingInstanceController); agentPosition3 = VectorConversions.GetLocalPosition(agentPosition3, trainingInstanceController); List <float> nearestPosToAgent1 = new List <float>() { StaticFunctions.NormalisedFloat(-max, max, agentPosition1.x), StaticFunctions.NormalisedFloat(-max, max, agentPosition1.z), StaticFunctions.NormalisedFloat(-max, max, agentPosition2.x), StaticFunctions.NormalisedFloat(-max, max, agentPosition2.z), StaticFunctions.NormalisedFloat(-max, max, agentPosition3.x), StaticFunctions.NormalisedFloat(-max, max, agentPosition3.z) }; Assert.AreEqual(nearestPosToAgent1, trainingInstanceController .Spy .GetComponent <SpyAgent>() .GetGuardPositions(3)); }