Exemplo n.º 1
0
        public void Init()
        {
            wpSectionList = new List <WPSection>();
            for (int i = 0; i < wpList.Count; i++)
            {
                Transform wp = wpList[i];

                //check if this is a platform, BuildManager would have add the component and have them layered
                if (wpList[i] != null)
                {
                    WPSection section = new WPSection();
                    section.waypointT = wp;

                    if (wp.gameObject.layer == LayerManager.LayerPlatform())
                    {
                        section.isPlatform       = true;
                        section.platform         = wp.gameObject.GetComponent <PlatformTD>();
                        section.pathIDOnPlatform = section.platform.AddSubPath(this, i, wpList[i - 1], wpList[i + 1]);
                    }

                    wpSectionList.Add(section);
                }
            }

            if (loop)
            {
                loopPoint = Mathf.Min(wpList.Count - 1, loopPoint);             //looping must start 1 waypoint before the destination
            }
        }
Exemplo n.º 2
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;
                }
            }
        }
Exemplo n.º 3
0
        public List <Vector3> GetWPSectionPath(int ID)
        {
            if (wpSectionList[ID].isPlatform)
            {
                WPSection section = wpSectionList[ID];
                return(section.platform.GetSubPathPath(section.pathIDOnPlatform));
            }

            return(new List <Vector3>(wpSectionList[ID].GetPosList()));
        }
Exemplo n.º 4
0
        public void Init()
        {
            wpSectionList = new List <WPSection>();

            for (int i = 0; i < wpList.Count; i++)
            {
                Transform wpT = wpList[i];

                //check if this is a platform, BuildManager would have add the component and have them layered
                if (wpT != null)
                {
                    WPSection section = new WPSection(wpT);

                    if (wpT.gameObject.layer == TDTK.GetLayerPlatform())
                    {
                        section.isPlatform       = true;
                        section.platform         = wpT.gameObject.GetComponent <PlatformTD>();
                        section.pathIDOnPlatform = section.platform.AddSubPath(this, i, wpList[i - 1], wpList[i + 1]);

                        if (isLinearPath)
                        {
                            isLinearPath = false;
                        }
                    }
                    else
                    {
                        WPSubPath wpSubPath = wpT.gameObject.GetComponent <WPSubPath>();
                        if (wpSubPath != null)
                        {
                            section.SetPosList(new List <Vector3>(wpSubPath.posList));
                        }
                        else
                        {
                            section.SetPosList(new List <Vector3> {
                                wpT.position
                            });
                        }
                    }

                    wpSectionList.Add(section);
                }
                else
                {
                    wpList.RemoveAt(i);
                    i -= 1;
                }
            }


            if (loop)
            {
                loopPoint = Mathf.Min(wpList.Count - 1, loopPoint);             //looping must be 1 waypoint before the destination
            }
        }
Exemplo n.º 5
0
        public List <Vector3> GetWPSectionPath(int ID)
        {
            if (wpSectionList[ID].isPlatform)
            {
                WPSection section = wpSectionList[ID];
                return(section.platform.GetSubPathPath(section.pathIDOnPlatform));
            }

            List <Vector3> list = new List <Vector3>();

            list.Add(wpSectionList[ID].waypointT.position);
            return(list);
        }
Exemplo n.º 6
0
		public void Init(){
			wpSectionList=new List<WPSection>();
			for(int i=0; i<wpList.Count; i++){
				Transform wp=wpList[i];
				
				//check if this is a platform, BuildManager would have add the component and have them layered
				if(wpList[i]!=null){
					WPSection section=new WPSection();
					section.waypointT=wp;
					
					if(wp.gameObject.layer==LayerManager.LayerPlatform()){
						section.isPlatform=true;
						section.platform=wp.gameObject.GetComponent<PlatformTD>();
						section.pathIDOnPlatform=section.platform.AddSubPath(this, i, wpList[i-1], wpList[i+1]);
					}
					
					wpSectionList.Add(section);
				}
			}
			
			if(loop){
				loopPoint=Mathf.Min(wpList.Count-1, loopPoint); //looping must start 1 waypoint before the destination
			}
		}