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)ObjectPoolManager.Spawn(pathPoint, wpSec.waypointT.position, Quaternion.identity);
                    endPoint = wpSec.waypointT.position;
                    pointObj.transform.parent = parentT;
                }
                else
                {
                    subP = wpSec.platform.GetSubPath(wpSec.pathIDOnPlatform);
                    GameObject point1Obj = (GameObject)ObjectPoolManager.Spawn(pathPoint, subP.startN.pos, Quaternion.identity);
                    GameObject point2Obj = (GameObject)ObjectPoolManager.Spawn(pathPoint, subP.endN.pos, Quaternion.identity);
                    endPoint = subP.startN.pos;

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

                if (i > 0)
                {
                    GameObject   lineObj = (GameObject)ObjectPoolManager.Spawn(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));
            }

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

            list.Add(wpSectionList[ID].waypointT.position);
            return(list);
        }