Beispiel #1
0
        private void TakeRandomStep()
        {
            var gridPoint = GetTileGridPoints();

            var newX = gridPoint.X + _random.Next(-MaxWanderX, MaxWanderX + 1);
            var newY = gridPoint.Y + _random.Next(-MaxWnaderY, MaxWnaderY + 1);

            var searcher = new AStarSearcher(Character.Zone.TileMap, new Point(newX, newY),
                new Point(gridPoint.X, gridPoint.Y));
            var results = searcher.GeneratePath(true);

            var destList = new List<Vector2>();

            // If it's even possible
            if (results.Count > 0)
            {

                foreach (var result in results)
                {
                    var point = new Point(result.X * 32 - Character.Body.OffsetX, result.Y * 32 - Character.Body.OffsetY);
                    destList.Add(new Vector2(point.X, point.Y));
                }

                BeginPath(destList);
            }
        }
Beispiel #2
0
        private void ToRandomSpot()
        {
            // Get our position in the actual tilemap
            var gridPoint = GetTileGridPoints();
            var gridX = gridPoint.X;
            var gridY = gridPoint.Y;

            var destX = 3;
            var destY = 3;

            var searcher = new AStarSearcher(this.Character.Zone.TileMap, new Point(destX, destY), new Point(gridX, gridY));
            var results = searcher.GeneratePath(true);

            var destList = new List<Vector2>();

            foreach (var result in results)
            {
                var point = new Point(result.X * 32 - Character.Body.OffsetX, result.Y * 32 - Character.Body.OffsetY);
                destList.Add(new Vector2(point.X, point.Y));
            }

            BeginPath(destList);
        }
Beispiel #3
0
        private List<Vector2> RegeneratePath()
        {
            var victim = GetVictim();
            var start = GetTileGridPoints();

            var gridPoint = GetTileGridPoints(victim);

            var newX = gridPoint.X;
            var newY = gridPoint.Y;

            var searcher = new AStarSearcher(Character.Zone.TileMap, new Point(newX, newY),
                new Point(start.X, start.Y));
            var results = searcher.GeneratePath(true);

            var destList = new List<Vector2>();

            // If it's even possible
            if (results.Count > 0)
            {
                results.RemoveAt(0);
                results.RemoveAt(results.Count - 1);

                foreach (var result in results)
                {
                    var point = new Point(result.X * 32 - Character.Body.OffsetX, result.Y * 32 - Character.Body.OffsetY);
                    destList.Add(new Vector2(point.X, point.Y));
                }

            }
            else
            {
                AgressionTracker.RemoveAgression(victim.Id);
                EndPath();
            }

            // ResetPath();

            return destList;
        }