Example #1
0
    void Update()
    {
        bool successfulPlacement = false;

        if (hasActiveTile)
        {
            bool       keyPressed = false;
            TSGameTile targetTile = null;
            if (Input.GetKeyDown(leftKey))
            {
                keyPressed          = true;
                successfulPlacement = tryPlacePiece(leftKey, out targetTile);
                leftButton.BeginPress();
            }
            else if (Input.GetKeyDown(rightKey))
            {
                keyPressed          = true;
                successfulPlacement = tryPlacePiece(rightKey, out targetTile);
                rightButton.BeginPress();
            }
            if (keyPressed && targetTile != null)
            {
                targetTile.TimedShowIcon(successfulPlacement);
                if (hasCurrentTask)
                {
                    recordReponseTime();
                }
            }
        }
        bool buttonWasUp = false;

        if (Input.GetKeyUp(leftKey))
        {
            leftButton.EndPress();
            buttonWasUp = true;
        }
        else if (Input.GetKeyUp(rightKey))
        {
            rightButton.EndPress();
            buttonWasUp = true;
        }
        if (buttonWasUp)
        {
            rightButton.SetInactive();
            leftButton.SetInactive();
            if (hasCurrentTask)
            {
                recordTaskTime();
                sendTask(currentTask,
                         successfulPlacement ? TSResponseStatus.Correct : TSResponseStatus.Error,
                         responseTime,
                         taskTime);
            }
        }
    }
Example #2
0
    IEnumerator spawnCoroutine()
    {
        while (this.spawningActive)
        {
            yield return(new WaitForSeconds(spawnDelay));

            TSGameTile previousTile = activeTile;
            bool       tooSlow      = false;
            if (hasCurrentTask)
            {
                sendTask(currentTask, TSResponseStatus.TooSlow, 0, 0);
                tooSlow = true;
            }
            rightButton.SetActive();
            leftButton.SetActive();
            toggleAllTileIcons(visible: false);
            StimuliSet stimuli = data.GetSet();
            spawnPiece(stimuli);
            if (tooSlow && previousTile)
            {
                previousTile.TimedShowIcon(successfulPlacement: false);
            }
        }
    }