Пример #1
0
 //Go through all the trakers and check if the transform still exsists
 void CheckIfTrackerIsNull(MovmentData tracker)
 {
     if (tracker.transformToTrack == null)
     {
         activeTrackers.Remove(tracker); //Remove the null tracker from the list. Do this here rather than using the EndTracker method as there is no transform to check againts.
         Debug.LogError("Tracker [" + tracker.id + "] was missing, it has been removed from the tracker list and has stopped sending movment data to the server.", gameObject);
     }
 }
Пример #2
0
        void CheckTrackerForUpdate(MovmentData tracker)
        {
            distance = Vector3.Distance(tracker.transformToTrack.position, tracker.lastRecordedPosition); //Get the distance between the last recorded point and the active point

            if (distance >= settings.distanceToRecord)                                                    //Check if the distance between the last recorded point and the current point is large enough to record a new point
            {
                tracker.lastRecordedPosition = tracker.transformToTrack.position;
                tracker.movementString      += JsonPosition(tracker);
                sql.UpdateData(tracker.id, tracker.movementString); //Update the row in the sql
            }
        }
Пример #3
0
        public void StartTracker(Transform tracker, string tag = "")
        {
            MovmentData newTracker = new MovmentData(); //Create empty movement data to fill with new information

            newTracker.transformToTrack     = tracker;  //Set the transform we want to track
            newTracker.lastRecordedPosition = tracker.position;
            newTracker.movementString       = JsonPosition(newTracker);

            //Create the new row in the sql for this data. Also pass the movment data so it can set the id the sql created for it.
            sql.CreateNewData(newTracker.movementString, newTracker, tag);

            activeTrackers.Add(newTracker);
        }
Пример #4
0
        IEnumerator SendData(string startingMovmentData, MovmentData newData, DateTime date, string sessionTag)
        {
            WWWForm form = new WWWForm();                                      //Create an empty form to post to the php script

            form.AddField("movementData", startingMovmentData);                //Add the starting movement data to the form
            string dateString = date.Year + "-" + date.Month + "-" + date.Day; //Put the date into the format that an SQL reads e.g. YYYY/MM/DD

            form.AddField("date", dateString);
            form.AddField("sessionTag", sessionTag);

            WWW postRequest = new WWW(LineUpSqlSettings.startNewDataPhp, form); //Post the form to the php script

            yield return(postRequest);                                          //Wait for the script to finish downloading

            //print(postRequest.text); //Print the result of the page which is the auto increment value given to this row in the table
            float resultID = 0;

            float.TryParse(postRequest.text, out resultID); //Convert the string we got from the php page to an int so we can store it as an id
            newData.id = resultID;                          //Store the id in the copy of the movment data we sent over
        }
Пример #5
0
 string JsonPosition(MovmentData tracker)
 {
     return(JsonUtility.ToJson(tracker.lastRecordedPosition) + "|"); //Add the vertical bar after we create the JSON so we can seperate it later on
 }
Пример #6
0
 public void CreateNewData(string startingMovmentData, MovmentData newData, string sessionTag)
 {
     StartCoroutine(SendData(startingMovmentData, newData, DateTime.Now, sessionTag));
 }