public void BetweenObstaclesTest_NarrowSpace()
        {
            obstacleMap = new ObstacleMap();
            Obstacle obstacleLeft  = new Obstacle(new Vector(-1000, 500), new Vector(-200, 500));
            Obstacle obstacleRight = new Obstacle(new Vector(200, 500), new Vector(1000, 500));

            obstacleMap.AddObstacle(obstacleLeft);
            obstacleMap.AddObstacle(obstacleRight);
            Vector result = obstacleMap.GetRouteSuggestion(new Vector(0, 1)).Item1;

            Assert.IsTrue(result.X <-0.998f && result.X> -1.005f);
        }
        public void BetweenObstaclesTest_WideSpace()
        {
            obstacleMap = new ObstacleMap();
            Obstacle obstacleLeft  = new Obstacle(new Vector(-800, 500), new Vector(-400, 500));
            Obstacle obstacleRight = new Obstacle(new Vector(400, 1000), new Vector(800, 1000));

            obstacleMap.AddObstacle(obstacleLeft);
            obstacleMap.AddObstacle(obstacleRight);
            Vector result = obstacleMap.GetRouteSuggestion(new Vector(0, 1)).Item1;

            Assert.IsTrue(result.Y > 0.995f && result.Y < 1.005f);
        }
 public void CreateObstacle(GameObject objectPrefab, List <Vector2> positions)
 {
     foreach (var pos in positions)
     {
         var obstacle = Instantiate(objectPrefab, obstacleRoot).GetComponent <Obstacle>();
         obstacle.transform.position = new Vector3(pos.x, pos.y, 0) * Globals.TILE_SIZE + new Vector3(0.5f, 0.5f, 0f);
         obstacle.GetPosition();
         ObstacleMap.AddObstacle(obstacle);
     }
 }
        public void InsideRangeObstacleTest()
        {
            obstacleMap = new ObstacleMap();
            Obstacle obstacle = new Obstacle(new Vector(-100, 100), new Vector(100, 100));

            obstacleMap.AddObstacle(obstacle);
            Vector result = obstacleMap.GetRouteSuggestion(new Vector(0, 1)).Item1;

            Assert.IsTrue(result.X <-0.998f && result.X> -1.005f);
        }
 public void CreateCannon(List <Vector2> positions, CannonType type)
 {
     foreach (var pos in positions)
     {
         var obstacle = Instantiate(cannon, obstacleRoot).GetComponent <Obstacle>();
         obstacle.transform.position = new Vector3(pos.x, pos.y, 0) * Globals.TILE_SIZE + new Vector3(0.5f, 0.5f, 0f);
         obstacle.GetPosition();
         obstacle.gameObject.GetComponent <Cannon>().SetType(type);
         ObstacleMap.AddObstacle(obstacle);
     }
 }
        public void AvoidDirectObstacleTest()
        {
            obstacleMap = new ObstacleMap();
            Obstacle obstacle = new Obstacle(new Vector(-500, 1000), new Vector(500, 1000));

            obstacleMap.AddObstacle(obstacle);
            Vector result = obstacleMap.GetRouteSuggestion(new Vector(0, 1)).Item1;

            Assert.IsTrue(result.Y > 0.79f && result.Y < 0.81f);
            Assert.IsTrue(result.X > -0.59f && result.X < -0.57f);
            Assert.IsTrue(result.Length > 0.999 && result.Length < 1.001);
        }