示例#1
0
        public bool CheckForBlock(Vector3 pos)
        {
            float  gridSize   = BuildManager.GetGridSize();
            NodeTD targetNode = PathFinder.GetNearestNode(pos, nodeGraph);

            for (int i = 0; i < subPathList.Count; i++)
            {
                SubPath subPath = subPathList[i];
                if (Vector3.Distance(pos, subPath.startN.pos) < gridSize / 2)
                {
                    return(true);
                }
                if (Vector3.Distance(pos, subPath.endN.pos) < gridSize / 2)
                {
                    return(true);
                }

                if (subPath.IsNodeInPath(targetNode))
                {
                    subPath.altPath = PathFinder.ForceSearch(subPath.startN, subPath.endN, targetNode, nodeGraph);
                    if (subPath.altPath.Count == 0)
                    {
                        return(true);
                    }
                }
            }

            nextBuildNode = targetNode;

            return(false);
        }
示例#2
0
 void OnSubPathChanged(SubPath platformSubPath)
 {
     if (platformSubPath.parentPath == path && platformSubPath.wpIDPlatform == waypointID)
     {
         ResetSubPath(platformSubPath);
     }
 }
示例#3
0
 void OnSubPathChanged(SubPath platformSubPath)
 {
     if (platformSubPath.parentPath == path && platformSubPath.wpIDPlatform == waypointID)
     {
         subPath       = path.GetWPSectionPath(waypointID);
         subWaypointID = Mathf.Min(subWaypointID, subPath.Count - 1);
     }
 }
示例#4
0
        void CreatePathLine()
        {
            Transform parentT = new GameObject().transform;

            parentT.position        = transform.position;
            parentT.parent          = transform;
            parentT.gameObject.name = "PathLine";

            GameObject pathLine  = (GameObject)Resources.Load("ScenePrefab/PathLine");
            GameObject pathPoint = (GameObject)Resources.Load("ScenePrefab/PathPoint");

            Vector3 startPoint = Vector3.zero;
            Vector3 endPoint   = Vector3.zero;

            SubPath subP = null;

            for (int i = 0; i < wpSectionList.Count; i++)
            {
                WPSection wpSec = wpSectionList[i];
                if (!wpSec.isPlatform)
                {
                    GameObject pointObj = (GameObject)Instantiate(pathPoint, wpSec.waypointT.position, Quaternion.identity);
                    endPoint = wpSec.waypointT.position;
                    pointObj.transform.parent = parentT;
                }
                else
                {
                    subP = wpSec.platform.GetSubPath(wpSec.pathIDOnPlatform);
                    GameObject point1Obj = (GameObject)Instantiate(pathPoint, subP.startN.pos, Quaternion.identity);
                    GameObject point2Obj = (GameObject)Instantiate(pathPoint, subP.endN.pos, Quaternion.identity);
                    endPoint = subP.startN.pos;

                    point1Obj.transform.parent = parentT;
                    point2Obj.transform.parent = parentT;
                }

                if (i > 0)
                {
                    GameObject   lineObj = (GameObject)Instantiate(pathLine, startPoint, Quaternion.identity);
                    LineRenderer lineRen = lineObj.GetComponent <LineRenderer>();
                    lineRen.SetPosition(0, startPoint);
                    lineRen.SetPosition(1, endPoint);

                    lineObj.transform.parent = parentT;
                }

                if (wpSec.isPlatform)
                {
                    startPoint = subP.endN.pos;
                }
                else
                {
                    startPoint = wpSec.waypointT.position;
                }
            }
        }
示例#5
0
        public int AddSubPath(PathTD pathInstance, int wpID, Transform startP, Transform endP)
        {
            walkable=true;

            int ID=subPathList.Count;

            SubPath subPath=new SubPath();
            subPath.parentPath=pathInstance;
            subPath.wpIDPlatform=wpID;
            subPath.connectStart=startP;
            subPath.connectEnd=endP;

            subPathList.Add(subPath);

            return ID;
        }
示例#6
0
        public int AddSubPath(PathTD pathInstance, int wpID, Transform startP, Transform endP)
        {
            walkable = true;

            int ID = subPathList.Count;

            SubPath subPath = new SubPath();

            subPath.parentPath   = pathInstance;
            subPath.wpIDPlatform = wpID;
            subPath.connectStart = startP;
            subPath.connectEnd   = endP;

            subPathList.Add(subPath);

            return(ID);
        }
示例#7
0
        void ResetSubPath(SubPath platformSubPath)
        {
            if (dummyT == null)
            {
                dummyT = new GameObject().transform;
            }

            Quaternion rot = Quaternion.LookRotation(subPath[subWaypointID] - thisT.position);

            dummyT.rotation = rot;
            dummyT.position = thisT.position;

            Vector3 pos    = dummyT.TransformPoint(0, 0, BuildManager.GetGridSize() / 2);
            NodeTD  startN = PathFinder.GetNearestNode(pos, platformSubPath.parentPlatform.GetNodeGraph());

            PathFinder.GetPath(startN, platformSubPath.endN, platformSubPath.parentPlatform.GetNodeGraph(), this.SetSubPath);
        }
示例#8
0
        void ResetSubPath(SubPath platformSubPath)
        {
            if(dummyT==null) dummyT=new GameObject().transform;

            Quaternion rot=Quaternion.LookRotation(subPath[subWaypointID]-thisT.position);
            dummyT.rotation=rot;
            dummyT.position=thisT.position;

            Vector3 pos=dummyT.TransformPoint(0, 0, BuildManager.GetGridSize()/2);
            NodeTD startN=PathFinder.GetNearestNode(pos, platformSubPath.parentPlatform.GetNodeGraph());
            PathFinder.GetPath(startN, platformSubPath.endN, platformSubPath.parentPlatform.GetNodeGraph(), this.SetSubPath);
        }
示例#9
0
 void OnSubPathChanged(SubPath platformSubPath)
 {
     if(platformSubPath.parentPath==path && platformSubPath.wpIDPlatform==waypointID){
         ResetSubPath(platformSubPath);
     }
 }
示例#10
0
		void OnSubPathChanged(SubPath platformSubPath){
			if(platformSubPath.parentPath==path && platformSubPath.wpIDPlatform==waypointID){
				subPath=path.GetWPSectionPath(waypointID);
				subWaypointID=Mathf.Min(subWaypointID, subPath.Count-1);
			}
		}