public void TestSearchPathIncorrectGoal()
 {
     AStarSearch.SetMesh(OneWall);
     Assert.AreEqual(AStarSearch.SearchPath(new Vector(5, 5), new Vector(1, 1)), new List <Vector>()
     {
         new Vector(0, 0)
     });
 }
예제 #2
0
        public void Update(
            Vector playerPosition, Vector playerVelocity, List <Bullet> sceneBullets,
            List <AbstractParticleUnit> particles, ShapesIterator shapes, List <List <Vector> > botPaths, List <Edge> walls)
        {
            currentWeapon.IncrementTick();
            AvoidCollision(shapes);
            if (IsInView(playerPosition, walls))
            {
                currentPath = null;
                Fire(playerPosition + playerVelocity, sceneBullets, particles);
                var v      = playerPosition - Position;
                var radius = CollisionShape.Diameter * 4;
                if (Vector.ScalarProduct(v, v) < radius * radius)
                {
                    MoveCirclesAround(playerPosition, 2);
                }
                else
                {
                    ChasePrey(playerPosition);
                }
            }
            else
            {
                if (currentPath == null || currentPathPointIndex == currentPath.Count || currentPath.Count == 0)
                {
                    currentPath           = AStarSearch.SearchPath(Position, playerPosition);
                    currentPathPointIndex = 0;
                }
                ChasePrey(currentPath[currentPathPointIndex]);
                var distVector = currentPath[currentPathPointIndex] - Position;
                if (Vector.ScalarProduct(distVector, distVector) < 32 * 32)
                {
                    currentPathPointIndex++;
                }
            }

            if (currentPath != null && currentPath.Count != 0)
            {
                botPaths.Add(currentPath);
            }
            Velocity = sight * speed;
        }
 public void TestSearchPathCorrect()
 {
     AStarSearch.SetMesh(NoWalls);
     Assert.Positive(AStarSearch.SearchPath(new Vector(1, 1), new Vector(5, 5)).Count);
 }