Beispiel #1
0
        private bool CanShoot(Scene scene)
        {
            var myPoint     = MapPoint.FromVector2(Position);
            var playerPoint = MapPoint.FromVector2(scene.Player.Position);

            return(myPoint.GetManhattanDistanceTo(playerPoint) >= ShootingDistance);
        }
Beispiel #2
0
        private bool TryRunFromPlayer(Scene scene, float elapsedMilliseconds)
        {
            var myPoint     = MapPoint.FromVector2(Position);
            var playerPoint = MapPoint.FromVector2(scene.Player.Position);
            var pointsToRun = playerPoint
                              .GetPointsAtRadius(scene.Map, ShootingDistance + 5)
                              .Where(p => p.GetManhattanDistanceTo(playerPoint) >= ShootingDistance)
                              .OrderBy(p => p.GetManhattanDistanceTo(myPoint))
                              .ToArray();

            if (pointsToRun.Length < 1)
            {
                Console.WriteLine("There is no points to Run1");
                return(false);
            }

            var pathToPoint = PathFinder.FindPath(scene.Map, pointsToRun[0], myPoint);

            if (pathToPoint == null)
            {
                return(false);
            }

            DirectionAngle = GetAngleToPoint(pathToPoint[1]);

            MoveOnDirection(scene, elapsedMilliseconds);

            return(true);
        }
Beispiel #3
0
        private bool TryGetDirectionToTarget(Scene scene, out float angle)
        {
            angle = 0.0f;

            var myPoint = MapPoint.FromVector2(Position);

            Console.WriteLine($"{myPoint}");
            var targetPoint = MapPoint.FromVector2(Target.Position);

            Console.WriteLine($"{targetPoint}");
            var path = PathFinder.FindPath(scene.Map, targetPoint, myPoint);

            if (path == null)
            {
                return(false);
            }

            Console.WriteLine("before");
            angle = GetAngleToPoint(path[1]);
            Console.WriteLine("after");

            return(true);
        }