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));
        }
    }
 static int SetPath(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         SWS.splineMove  obj  = (SWS.splineMove)ToLua.CheckObject <SWS.splineMove>(L, 1);
         SWS.PathManager arg0 = (SWS.PathManager)ToLua.CheckObject <SWS.PathManager>(L, 2);
         obj.SetPath(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int GetWaypointCount(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         SWS.PathManager obj = (SWS.PathManager)ToLua.CheckObject <SWS.PathManager>(L, 1);
         int             o   = obj.GetWaypointCount();
         LuaDLL.lua_pushinteger(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int GetWaypoint(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         SWS.PathManager       obj  = (SWS.PathManager)ToLua.CheckObject <SWS.PathManager>(L, 1);
         int                   arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
         UnityEngine.Transform o    = obj.GetWaypoint(arg0);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int GetHandleSize(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         SWS.PathManager     obj  = (SWS.PathManager)ToLua.CheckObject <SWS.PathManager>(L, 1);
         UnityEngine.Vector3 arg0 = ToLua.ToVector3(L, 2);
         float o = obj.GetHandleSize(arg0);
         LuaDLL.lua_pushnumber(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
    static int set_replaceObject(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            SWS.PathManager        obj  = (SWS.PathManager)o;
            UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckObject(L, 2, typeof(UnityEngine.GameObject));
            obj.replaceObject = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index replaceObject on a nil value"));
        }
    }
    static int set_skipCustomNames(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            SWS.PathManager obj  = (SWS.PathManager)o;
            bool            arg0 = LuaDLL.luaL_checkboolean(L, 2);
            obj.skipCustomNames = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index skipCustomNames on a nil value"));
        }
    }
    static int set_radius(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            SWS.PathManager obj  = (SWS.PathManager)o;
            float           arg0 = (float)LuaDLL.luaL_checknumber(L, 2);
            obj.radius = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index radius on a nil value"));
        }
    }
    static int set_waypoints(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            SWS.PathManager         obj  = (SWS.PathManager)o;
            UnityEngine.Transform[] arg0 = ToLua.CheckObjectArray <UnityEngine.Transform>(L, 2);
            obj.waypoints = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index waypoints on a nil value"));
        }
    }
Exemplo n.º 10
0
    static int get_replaceObject(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            SWS.PathManager        obj = (SWS.PathManager)o;
            UnityEngine.GameObject ret = obj.replaceObject;
            ToLua.PushSealed(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index replaceObject on a nil value"));
        }
    }
Exemplo n.º 11
0
    static int get_skipCustomNames(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            SWS.PathManager obj = (SWS.PathManager)o;
            bool            ret = obj.skipCustomNames;
            LuaDLL.lua_pushboolean(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index skipCustomNames on a nil value"));
        }
    }
Exemplo n.º 12
0
    static int get_radius(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            SWS.PathManager obj = (SWS.PathManager)o;
            float           ret = obj.radius;
            LuaDLL.lua_pushnumber(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index radius on a nil value"));
        }
    }
Exemplo n.º 13
0
    static int get_size(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            SWS.PathManager     obj = (SWS.PathManager)o;
            UnityEngine.Vector3 ret = obj.size;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index size on a nil value"));
        }
    }
Exemplo n.º 14
0
    static int get_waypoints(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            SWS.PathManager         obj = (SWS.PathManager)o;
            UnityEngine.Transform[] ret = obj.waypoints;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index waypoints on a nil value"));
        }
    }
Exemplo n.º 15
0
    static int set_color2(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            SWS.PathManager   obj  = (SWS.PathManager)o;
            UnityEngine.Color arg0 = ToLua.ToColor(L, 2);
            obj.color2 = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index color2 on a nil value"));
        }
    }
Exemplo n.º 16
0
    static int set_size(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            SWS.PathManager     obj  = (SWS.PathManager)o;
            UnityEngine.Vector3 arg0 = ToLua.ToVector3(L, 2);
            obj.size = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index size on a nil value"));
        }
    }
Exemplo n.º 17
0
    static int set_pathContainer(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            SWS.splineMove  obj  = (SWS.splineMove)o;
            SWS.PathManager arg0 = (SWS.PathManager)ToLua.CheckObject <SWS.PathManager>(L, 2);
            obj.pathContainer = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index pathContainer on a nil value"));
        }
    }
Exemplo n.º 18
0
    static int get_pathContainer(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            SWS.splineMove  obj = (SWS.splineMove)o;
            SWS.PathManager ret = obj.pathContainer;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index pathContainer on a nil value"));
        }
    }
Exemplo n.º 19
0
    static int Create(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1)
            {
                SWS.PathManager obj = (SWS.PathManager)ToLua.CheckObject <SWS.PathManager>(L, 1);
                obj.Create();
                return(0);
            }
            else if (count == 2 && TypeChecker.CheckTypes <UnityEngine.Transform[]>(L, 2))
            {
                SWS.PathManager         obj  = (SWS.PathManager)ToLua.CheckObject <SWS.PathManager>(L, 1);
                UnityEngine.Transform[] arg0 = ToLua.ToObjectArray <UnityEngine.Transform>(L, 2);
                obj.Create(arg0);
                return(0);
            }
            else if (count == 2 && TypeChecker.CheckTypes <UnityEngine.Transform>(L, 2))
            {
                SWS.PathManager       obj  = (SWS.PathManager)ToLua.CheckObject <SWS.PathManager>(L, 1);
                UnityEngine.Transform arg0 = (UnityEngine.Transform)ToLua.ToObject(L, 2);
                obj.Create(arg0);
                return(0);
            }
            else if (count == 3)
            {
                SWS.PathManager         obj  = (SWS.PathManager)ToLua.CheckObject <SWS.PathManager>(L, 1);
                UnityEngine.Transform[] arg0 = ToLua.CheckObjectArray <UnityEngine.Transform>(L, 2);
                bool arg1 = LuaDLL.luaL_checkboolean(L, 3);
                obj.Create(arg0, arg1);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: SWS.PathManager.Create"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Exemplo n.º 20
0
        public override void OnInspectorGUI()
        {
            //show default variables of manager
            DrawDefaultInspector();
            //get manager reference
            script = (WaypointManager)target;

            //get sceneview to auto-detect 2D mode
            SceneView view = SceneView.currentDrawingSceneView;

            if (view == null)
            {
                view = EditorWindow.GetWindow <SceneView>("Scene", false);
            }
            mode2D = view.in2DMode;

            EditorGUIUtility.LookLikeControls();
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();

            //draw path text label
            GUILayout.Label("Enter Path Name: ", GUILayout.Height(15));
            //display text field for creating a path with that name
            pathName = EditorGUILayout.TextField(pathName, GUILayout.Height(15));

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();

            //draw path type selection enum
            GUILayout.Label("Select Path Type: ", GUILayout.Height(15));
            pathType = (PathType)EditorGUILayout.EnumPopup(pathType);

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            //display label of current mode
            if (mode2D)
            {
                GUILayout.Label("2D Mode Detected.", GUILayout.Height(15));
            }
            else
            {
                GUILayout.Label("3D Mode Detected.", GUILayout.Height(15));
            }
            EditorGUILayout.Space();

            //draw path creation button
            if (!placing && GUILayout.Button("Start Path", GUILayout.Height(40)))
            {
                if (pathName == "")
                {
                    Debug.LogWarning("No path name defined. Cancelling.");
                    return;
                }

                if (script.transform.Find(pathName) != null)
                {
                    Debug.LogWarning("Path name already given. Cancelling.");
                    return;
                }

                //create a new container transform which will hold all new waypoints
                path = new GameObject(pathName);
                //reset position and parent container gameobject to this manager gameobject
                path.transform.position = script.gameObject.transform.position;
                path.transform.parent   = script.gameObject.transform;
                StartPath();

                //we passed all prior checks, toggle waypoint placement
                placing = true;
                //focus sceneview for placement
                if (view != null)
                {
                    view.Focus();
                }
                //   SceneView.currentDrawingSceneView.Focus();
            }

            if (!placing && GUILayout.Button("Export Path", GUILayout.Height(40)))
            {
                string filepath = EditorUtility.SaveFilePanelInProject("Save Path", "PathInfo", "csv", "OKOK");
                LogManager.Log(filepath);
                string fileName = filepath;                //文件名字

                StringBuilder sb = new StringBuilder();
                //offset
                sb.Append("patrolId").Append(',');
                sb.Append("patrolPlan").Append(',');
                sb.Append("patrolX").Append(',');
                sb.Append("patrolY").Append("\r\n");
                int           totalCount = 0;
                PathManager[] pathes     = script.GetComponentsInChildren <PathManager>();
                for (int i = 0; i < pathes.Length; ++i)
                {
                    sb.Append('#').Append(pathes[i].name).Append(',').Append(pathes[i].transform.position.y).Append("\r\n");
                    Vector3[] points = pathes[i].GetPathPoints();
                    for (int j = 0; j < points.Length; ++j)
                    {
                        totalCount++;
                        sb.Append(totalCount).Append(',');
                        sb.Append(i).Append(',');
                        sb.Append(points[j].x).Append(',');
                        sb.Append(points[j].z).Append("\r\n");
                    }
                }

                //要写的数据源
                SaveTextFile(filepath, sb.ToString());
            }

            if (!placing && GUILayout.Button("Import", GUILayout.Height(40)))
            {
                string filepath = EditorUtility.OpenFilePanel("Load pathes", Application.dataPath, "csv");
                if (filepath != null)
                {
                    StreamReader reader = new StreamReader(filepath, new UTF8Encoding(false));
                    if (reader != null)
                    {
                        string content = reader.ReadToEnd();
                        int    readPos = 0;
                        //skip the first line
                        string        skipLine   = EditorUtils.readLine(content, ref readPos);
                        List <string> kv         = null;
                        PathManager   manager    = null;
                        int           pointCount = 0;
                        float         currentY   = 0f;
                        while (readPos < content.Length)
                        {
                            string lineNew = EditorUtils.readLine(content, ref readPos);
                            //new path
                            if (lineNew[0] == '#')
                            {
                                int noUse = 0;
                                kv = GameAssist.readCsvLine(lineNew, ref noUse);
                                string readpathName = kv[0].Substring(1);
                                float.TryParse(kv[1], out currentY);
                                path = new GameObject(readpathName);
                                //reset position and parent container gameobject to this manager gameobject
                                path.transform.position = script.gameObject.transform.position;
                                path.transform.parent   = script.gameObject.transform;
                                StartPath();
                                wpList.Clear();
                            }
                            else
                            {
                                int a = 0;
                                kv = GameAssist.readCsvLine(lineNew, ref a);
                                float x = 0f;
                                float.TryParse(kv[2], out x);
                                float z = 0f;
                                float.TryParse(kv[3], out z);
                                PlaceWaypoint(new Vector3(x, currentY, z));
                            }
                        }
                    }
                }
            }

            if (!placing && GUILayout.Button("CreateColliders", GUILayout.Height(40)))
            {
                UnityEngine.Object prefab = AssetDatabase.LoadAssetAtPath("Assets/PathEditor/Cube.prefab", typeof(UnityEngine.Object));
                GameObject         parent = GameObject.Find("WalkColliders");
                Texture2D          tex    = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/CameraPath3/Icons/options.png", typeof(Texture2D));
                if (parent == null)
                {
                    parent = new GameObject("WalkColliders");
                }
                PathManager[] pathes = script.GetComponentsInChildren <PathManager>();
                for (int i = 0; i < pathes.Length; ++i)
                {
                    Vector3[] points    = pathes[i].GetPathPoints();
                    int       pointC    = points.Length;
                    int       loopcount = pointC;
                    //不是关闭类型的,不生成最后一个点到初始点的连线
                    if (pathes[i].closure == false)
                    {
                        loopcount = pointC - 1;
                    }
                    for (int j = 0; j < loopcount; ++j)
                    {
                        Vector3    nextPos   = points[(j + 1) % pointC];
                        Vector3    middlePos = (points[j] + nextPos) * 0.5f;
                        GameObject collider  = GameObject.Instantiate(prefab, middlePos, Quaternion.identity) as GameObject;
                        Vector3    lookPos   = nextPos;
                        lookPos.y = middlePos.y;
                        collider.transform.LookAt(lookPos);
                        collider.transform.parent = parent.transform;
                        Vector3 setScale = collider.transform.localScale;
                        setScale.z = (nextPos - points[j]).magnitude;
                        collider.transform.localScale = setScale;
                    }
                }
            }
            GUI.backgroundColor = Color.yellow;

            //finish path button
            if (placing && GUILayout.Button("Finish Editing", GUILayout.Height(40)))
            {
                if (wpList.Count < 2)
                {
                    Debug.LogWarning("Not enough waypoints placed. Cancelling.");
                    //if we have created a path already, destroy it again
                    if (path)
                    {
                        DestroyImmediate(path);
                    }
                }

                //toggle placement off
                placing = false;
                //clear list with temporary waypoint references,
                //we only needed this for getting the waypoint count
                wpList.Clear();
                //reset path name input field
                pathName = "";
                //make the new path the active selection
                Selection.activeGameObject = path;
            }

            GUI.backgroundColor = Color.white;
            EditorGUILayout.Space();
            //draw instructions
            GUILayout.TextArea("Hint:\nPress 'Start Path' to begin a new path, then press 'p' "
                               + "on your keyboard to place waypoints in the SceneView. In 3D Mode "
                               + "you have to place waypoints onto objects with colliders."
                               + "\n\nPress 'Finish Editing' to end your path.");
        }
Exemplo n.º 21
0
 /// <summary>
 /// Changes the current path of this object and starts movement.
 /// <summary>
 public void SetPath(PathManager newPath)
 {
     //disable any running movement methods
     Stop();
     //set new path container
     pathContainer = newPath;
     //restart movement
     StartMove();
 }
Exemplo n.º 22
0
 //get references and start rendering
 void Start()
 {
     line = GetComponent<LineRenderer>();
     path = GetComponent<PathManager>();
     if (path) StartCoroutine("StartRenderer");
 }
Exemplo n.º 23
0
 // Token: 0x06000752 RID: 1874 RVA: 0x00030D84 File Offset: 0x0002F184
 public void SetPath(PathManager newPath)
 {
     this.Stop();
     this.pathContainer = newPath;
     this.StartMove();
 }