示例#1
0
    public static void insertWaypointsTo(int id, List <Vector3> waypoints)
    {
        WaypointData wp;

        foreach (Vector3 waypoint in waypoints)
        {
            wp          = new WaypointData();
            wp.npc      = id;
            wp.position = waypoint;
            wp.create();
        }
    }
示例#2
0
    public override void OnInspectorGUI()
    {
        NPC npc = Selection.activeGameObject.GetComponent<NPC>();
        npc.Start(); // we load npcData

        if (m_editMode)
        {
            GUILayout.Label("To add a Waypoint: right-click in the desired position.\n To change the order, edit Waypoint's name.\n");
            if (GUILayout.Button("Stop Editing"))
            {
                WaypointData wp;
                m_editMode = false;

                // destroy old waypoints
                foreach (WaypointData waypoint in Service.db.Select<WaypointData>("FROM " + WaypointData.TABLE_NAME+" WHERE npc==?", npc.Id)) {
                    waypoint.delete();
                }

                // save new waypoints
                foreach (Transform child in m_container.transform)
                {
                    wp = new WaypointData();
                    wp.npc = npc.Id;
                    wp.position = child.transform.position;
                    wp.create();
                }
                DestroyImmediate(m_container);
                m_count = 0;
            }
        }
        else
        {
            if (GUILayout.Button("Start Editing"))
            {
                m_editMode = true;
                checkContainer();

                // show existing waypoints
                foreach (WaypointData waypoint in npc.waypoints) {
                    createWaypoint(waypoint.position);
                }
            }
        }

        if (GUILayout.Button("Reset"))
        {
            m_count = 0;
            DestroyImmediate(m_container);
        }
    }
示例#3
0
    public static void insertWaypointsTo(int id, List<Vector3> waypoints)
    {
        WaypointData wp;

        foreach (Vector3 waypoint in waypoints) {
            wp = new WaypointData();
            wp.npc = id;
            wp.position = waypoint;
            wp.create();
        }
    }
示例#4
0
    override public void OnInspectorGUI()
    {
        // Do not enable the editor ingame
        if (Application.isPlaying)
        {
            return;
        }

        NPC npc = Selection.activeGameObject.GetComponent <NPC>();

        npc.Start();         // we load npcData
        npcPos = npc.transform.position;

        if (m_editMode)
        {
            GUILayout.Label("To add a Waypoint: wheel/middle click in the desired position.\n To change the order, edit Waypoint's name.\n");
            if (GUILayout.Button("Stop Editing"))
            {
                WaypointData wp;
                m_editMode = false;
                checkContainer();

                // destroy old waypoints
                foreach (WaypointData waypoint in Service.db.Select <WaypointData>("FROM " + WaypointData.TABLE_NAME + " WHERE npc==?", npc.Id))
                {
                    waypoint.delete();
                }

                // save new waypoints
                foreach (Transform child in m_container.transform)
                {
                    wp          = new WaypointData();
                    wp.npc      = npc.Id;
                    wp.position = npcPos - child.transform.position;                     // save the relative pos
                    wp.create();
                }
                DestroyImmediate(m_container);
                m_count = 0;


                // copy waypoints to clipboard
                TextEditor te = new TextEditor();
                te.text = coords;
                te.SelectAll();
                te.Copy();
            }
        }
        else
        {
            if (GUILayout.Button("Start Editing"))
            {
                m_editMode = true;
                checkContainer();
                resetList();

                // show existing waypoints
                foreach (WaypointData waypoint in npc.waypoints)
                {
                    createWaypoint(npcPos + waypoint.position);
                }
            }
            if (coords.Length > 0)
            {
                GUILayout.Label("\nCurrent Waypoints:");
                nothing = GUILayout.TextArea(coords);
            }
        }

        if (GUILayout.Button("Reset"))
        {
            m_count = 0;
            nothing = "";
            coords  = "";
            checkContainer();
            DestroyImmediate(m_container);
        }
    }
示例#5
0
    public override void OnInspectorGUI()
    {
        NPC npc = Selection.activeGameObject.GetComponent<NPC>();
        npc.Start(); // we load npcData

        if (m_editMode)
        {
            GUILayout.Label("To add a Waypoint: wheel/middle click in the desired position.\n To change the order, edit Waypoint's name.\n");
            if (GUILayout.Button("Stop Editing"))
            {
                WaypointData wp;
                m_editMode = false;
                checkContainer();

                // destroy old waypoints
                foreach (WaypointData waypoint in Service.db.Select<WaypointData>("FROM " + WaypointData.TABLE_NAME+" WHERE npc==?", npc.Id)) {
                    waypoint.delete();
                }

                // save new waypoints
                foreach (Transform child in m_container.transform)
                {
                    wp = new WaypointData();
                    wp.npc = npc.Id;
                    wp.position = child.transform.position;
                    wp.create();
                }
                DestroyImmediate(m_container);
                m_count = 0;

                // copy waypoints to clipboard
                TextEditor te = new TextEditor();
                te.content = new GUIContent(coords);
                te.SelectAll();
                te.Copy();
            }
        }
        else
        {
            if (GUILayout.Button("Start Editing"))
            {
                m_editMode = true;
                checkContainer();
                resetList();

                // show existing waypoints
                foreach (WaypointData waypoint in npc.waypoints) {
                    createWaypoint(waypoint.position);
                }
            }
            if (coords.Length > 0) {
                GUILayout.Label("\nCurrent Waypoints:");
                nothing = GUILayout.TextArea(coords);
            }
        }

        if (GUILayout.Button("Reset"))
        {
            m_count = 0;
            nothing = "";
            coords = "";
            checkContainer();
            DestroyImmediate(m_container);
        }
    }