Ejemplo n.º 1
0
        //updates LineRenderer positions
        void Render()
        {
            //avoid freeze in while loop with spacing set to zero
            spacing = Mathf.Clamp01(spacing);
            if (spacing == 0)
            {
                spacing = 0.05f;
            }

            //get path points of the path component
            List <Vector3> list = new List <Vector3>();

            list.AddRange(path.GetPathPoints());

            //differ between linear and curved paths
            if (path.drawCurved)
            {
                //on curved paths, the first and last waypoint
                //has to exist twice due to tween library calculations
                list.Insert(0, list[0]);
                list.Add(list[list.Count - 1]);
                points = list.ToArray();
                DrawCurved();
            }
            else
            {
                points = list.ToArray();
                DrawLinear();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Starts movement. Can be called from other scripts to allow start delay.
        /// <summary>
        public void StartMove()
        {
            //don't continue without path container
            if (pathContainer == null)
            {
                Debug.LogWarning(gameObject.name + " has no path! Please set Path Container.");
                return;
            }

            //get array with waypoint positions
            waypoints = pathContainer.GetPathPoints(local);
            //cache original speed for future speed changes
            originSpeed = speed;
            //cache original rotation if waypoint rotation is enabled
            originRot = transform.rotation;

            //initialize waypoint positions
            startPoint = Mathf.Clamp(startPoint, 0, waypoints.Length - 1);
            int index = startPoint;

            if (reverse)
            {
                Array.Reverse(waypoints);
                index = waypoints.Length - 1 - index;
            }
            Initialize(index);

            Stop();
            CreateTween();
        }
    static int GetPathPoints(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1)
            {
                SWS.PathManager       obj = (SWS.PathManager)ToLua.CheckObject <SWS.PathManager>(L, 1);
                UnityEngine.Vector3[] o   = obj.GetPathPoints();
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 2)
            {
                SWS.PathManager       obj  = (SWS.PathManager)ToLua.CheckObject <SWS.PathManager>(L, 1);
                bool                  arg0 = LuaDLL.luaL_checkboolean(L, 2);
                UnityEngine.Vector3[] o    = obj.GetPathPoints(arg0);
                ToLua.Push(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: SWS.PathManager.GetPathPoints"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
        /// <summary>
        /// Starts movement. Can be called from other scripts to allow start delay.
        /// <summary>
        public void StartMove()
        {
            //don't continue without path container
            if (pathContainer == null)
            {
                Debug.LogWarning(gameObject.name + " has no path! Please set Path Container.");
                return;
            }

            //get array with waypoint positions
            waypoints = pathContainer.GetPathPoints();

            //cache original speed for future speed changes
            originSpeed = speed;

            Stop();
            //start movement
            StartCoroutine(Move());
        }
Ejemplo n.º 5
0
    private void Start()
    {
        PinkToPinkSmoothedPath   = PinkToPinkPathPoints2.GetPathPoints();
        PinkToPurpleSmoothedPath = PinkToPurplePathPoints2.GetPathPoints();
        PinkToBlueSmoothedPath   = PinkToBluePathPoints2.GetPathPoints();

        RedtoRedSmoothedPath    = RedToRedPathPoints2.GetPathPoints();
        RedtoBlueSmoothedPath   = RedToBluePathPoints2.GetPathPoints();
        RedtoPurpleSmoothedPath = RedToPurplePathPoints2.GetPathPoints();

        PurpleToPurpleSmoothedPath = PurpleToPurplePathPoints2.GetPathPoints();
        PurpleToRedSmoothedPath    = PurpleToRedPathPoints2.GetPathPoints();
        PurpleToPinkSmoothedPath   = PurpleToPinkPathPoints2.GetPathPoints();

        BlueToBlueSmoothedPath = BlueToBluePathPoints2.GetPathPoints();
        BlueToPinkSmoothedPath = BlueToPinkPathPoints2.GetPathPoints();
        BlueToRedSmoothedPath  = BlueToRedPathPoints2.GetPathPoints();
    }