Exemplo n.º 1
0
    /// <summary>
    /// Returns the player's response as an int score from 0 to 10.
    /// </summary>
    protected int GetScore(float xPos)
    {
        HighStrikerData data = sessionData.gameData as HighStrikerData;

        // As x position gets larger (in either direction), score becomes lower
        return((int)(Mathf.Round(MAX_X_POS - Mathf.Abs(xPos)) / data.HorizontalScale));
    }
Exemplo n.º 2
0
    /// <summary>
    /// Parses Game specific variables for this Trial from the given XmlElement.
    /// If no parsable attributes are found, or fail, then it will generate some from the given GameData.
    /// Used when parsing a Trial that IS defined in the Session file.
    /// </summary>
    public override void ParseGameSpecificVars(XmlNode n, SessionData session)
    {
        base.ParseGameSpecificVars(n, session);

        HighStrikerData data = (HighStrikerData)(session.gameData);
        //if (!XMLUtil.ParseAttribute(n, ReactData.ATTRIBUTE_DURATION, ref duration, true))
        //{
        //	duration = data.GeneratedDuration;
        //}
    }
Exemplo n.º 3
0
    /// <summary>
    /// Displays the marker and updates it's position on the score bar.
    /// The player wants to respond when the marker's position is close to 0.
    /// </summary>
    protected virtual IEnumerator MoveMarker(Trial t)
    {
        //GameObject mark = marker;
        //      mark.SetActive(false);
        //yield return new WaitForSeconds(t.delay);

        //StartInput();
        //      mark.SetActive(true);
        //      HighStrikerData data = sessionData.gameData as HighStrikerData;
        //      Vector3 destination = originalMarkerPosition + (new Vector3(MAX_X_POS, 0, 0) * markerDirection);
        //      float elapsed = 0.0f;
        //      float distance = 0.0f;

        //      while (listenForInput)
        //      {
        //          float frac = distance / MAX_X_POS;
        //          mark.transform.position = Vector3.Lerp(mark.transform.position, destination, frac);
        //          if (mark.transform.position == destination)
        //          {
        //              destination = -destination;
        //              markerDirection = -markerDirection;
        //          }
        //          elapsed += Time.deltaTime;
        //          distance = elapsed * 1;
        //          yield return null;
        //      }

        //      mark.SetActive(false);
        //yield break;
        GameObject mark = marker;

        mark.SetActive(false);
        yield return(new WaitForSeconds(t.delay));

        StartInput();
        mark.SetActive(true);

        HighStrikerData data        = sessionData.gameData as HighStrikerData;
        Vector3         destination = originalMarkerPosition + (new Vector3(MAX_X_POS, 0, 0) * markerDirection);
        Vector3         newPosition = mark.transform.position;

        while (listenForInput)
        {
            newPosition = new Vector3(newPosition.x + (data.MarkerSpeed * markerDirection), newPosition.y, newPosition.z);

            // If we have reached our destination
            if ((newPosition.x > destination.x && markerDirection == 1) || (newPosition.x < destination.x && markerDirection == -1))
            {
                destination     = -destination;
                markerDirection = -markerDirection;
            }
            else
            {
                mark.transform.position = newPosition;
            }
            yield return(null);
        }

        mark.SetActive(false);
        yield break;
    }