Пример #1
0
    /// <summary>
    /// This function is to be used together with the "AddStep" adaptive function.
    /// It is used to save a step previously started
    /// </summary>
    /// <param name="canID">Can ID at which this step is associated</param>
    /// <param name="x_value">Detected x-value</param>
    /// <param name="y_value">Detected y-value</param>
    /// <param name="force">Detected force</param>
    /// <param name="force_accumulator">Force accumulated by the user by moving his foot up and down</param>
    /// <param name="movement_accumulator">Movement accumulate by the user by dragging his foot on the floor</param>
    /// <param name="end_time">Time at which the step has been detected</param>
    public void SaveStep(int canID, float x_value, float y_value, float force, double movement_accumulator, float force_accumulator, string end_time)
    {
        Utility.AdaptiveData a = new Utility.AdaptiveData();

        Utility.AdaptiveData data;
        lock (semaphore)
        {
            data = adaptiveSteps[canID];
        }

        // a = data;
        a.startTime  = data.startTime;;
        a.startPoint = new Vector2(data.startPoint.x, data.startPoint.y);
        a.preset     = data.preset;

        a.endTime           = end_time;
        a.endPoint          = new Vector2(x_value, y_value);
        a.distanceTravelled = movement_accumulator;
        a.force             = force;
        a.forceAccumulated  = force_accumulator;
        a.hasHit            = false;
        a.ducksHit          = new List <string>();

        lock (semaphore)
        {
            adaptiveSteps[canID] = a;
        }
    }
Пример #2
0
    /// <summary>
    /// This function is to be used in order to start recording data for an adaptive game session
    /// </summary>
    /// <param name="candID">Can ID to which we are referring</param>
    /// <param name="startTime">Time at wich the recording has started</param>
    public void AddStep(int canID, string start_time, float x_value_start, float y_value_start, string preset)
    {
        Utility.AdaptiveData a = new Utility.AdaptiveData();
        a.startTime         = start_time;
        a.startPoint        = new Vector2(x_value_start, y_value_start);
        a.preset            = preset;
        a.endTime           = "";
        a.endPoint          = Vector2.zero;
        a.distanceTravelled = 0;
        a.force             = 0;
        a.forceAccumulated  = 0;
        a.hasHit            = false;
        a.ducksHit          = new List <string>();

        lock (semaphore)
        {
            adaptiveSteps[canID] = a;
        }
    }
Пример #3
0
    public void SetDuckHit(int canId, string name)
    {
        // It is not possible to just update data contained in the list.
        // It is necessary to create a new element, and then add it
        Utility.AdaptiveData a = new Utility.AdaptiveData();

        // Get data regarding the desired canID.
        // It is essential to use a lock in order to avoid race condition
        Utility.AdaptiveData data;
        lock (semaphore)
        {
            data = adaptiveSteps[canId];
        }

        // Many values needn't to be changed
        // d = data;
        a.startTime         = data.startTime;;
        a.startPoint        = new Vector2(data.startPoint.x, data.startPoint.y);
        a.preset            = data.preset;
        a.endTime           = data.endTime;
        a.endPoint          = new Vector2(data.endPoint.x, data.endPoint.y);
        a.distanceTravelled = data.distanceTravelled;
        a.force             = data.force;
        a.forceAccumulated  = data.forceAccumulated;
        // A duck has been hit
        a.hasHit = true;
        // Keep track of the previously hit duck (if any)
        a.ducksHit = new List <string>(data.ducksHit);
        // Add the new one
        a.ducksHit.Add(name);

        // Update element in the list
        lock (semaphore)
        {
            adaptiveSteps[canId] = a;
        }
    }