Esempio n. 1
0
        public static List <Vector3> GetFourPointsInEachDirection(Vector3 center, int radius)
        {
            var result      = new List <Vector3>();
            var nearestNode = ExplorationGrid.Instance.GetNearestNode(center);

            if (nearestNode == null)
            {
                return(result);
            }
            return
                (ExplorationGrid.GetExplorationNodesInRadius(nearestNode, radius)
                 .Where(n => n.HasEnoughNavigableCells & n.NavigableCenter.Distance(AdvDia.MyPosition) > 10)
                 .Select(n => n.NavigableCenter)
                 .ToList());
        }
Esempio n. 2
0
        public static List <Vector3> GetFourPointsInEachDirection(Vector3 center, int radius)
        {
            var result      = new List <Vector3>();
            var nearestNode = ExplorationGrid.Instance.GetNearestNode(center) as ExplorationNode;

            if (nearestNode == null)
            {
                return(result);
            }
            return(ExplorationGrid.GetExplorationNodesInRadius(nearestNode, radius).Where(n => n.HasEnoughNavigableCells & n.NavigableCenter.Distance(AdvDia.MyPosition) > 10).Select(n => n.NavigableCenter).ToList());

            try
            {
                var node1 = ExplorationGrid.Instance.GetNearestWalkableNodeToPosition(new Vector3(center.X - radius, center.Y + radius, 0));
                if (node1 != null)
                {
                    result.Add(node1.NavigableCenter);
                }
                var node2 = ExplorationGrid.Instance.GetNearestWalkableNodeToPosition(new Vector3(center.X + radius, center.Y + radius, 0));
                if (node2 != null)
                {
                    result.Add(node2.NavigableCenter);
                }

                var node3 = ExplorationGrid.Instance.GetNearestWalkableNodeToPosition(new Vector3(center.X + radius, center.Y - radius, 0));
                if (node3 != null)
                {
                    result.Add(node3.NavigableCenter);
                }

                var node4 = ExplorationGrid.Instance.GetNearestWalkableNodeToPosition(new Vector3(center.X - radius, center.Y - radius, 0));
                if (node4 != null)
                {
                    result.Add(node4.NavigableCenter);
                }
            }
            catch (Exception)
            {
            }

            return(result);
        }