//check if left hand has changed state, and record data about collisions with face, and play sound effects private bool CheckLeft() { bool newSpriteNeeded = false; //check left bool prevLeftActive = leftActive; //Debug.Log("left force: " + _GlobalVariables.leftForce); //Debug.Log("Left force needed: " + leftBound); leftActive = _GlobalVariables.leftForce >= leftBound; if (leftActive != prevLeftActive) { //sprite changed newSpriteNeeded = true; if (leftActive) //started to grip left { leftValidAtAllTimes = true; HappyTimesSmartFeedback.TriggerEvent(HappyTimesSmartFeedback.LEFT, HappyTimesSmartFeedback.SQUEEZE, leftFaceColliding); } else { //on releasing HappyTimesSmartFeedback.TriggerEvent(HappyTimesSmartFeedback.LEFT, HappyTimesSmartFeedback.RELEASE, leftFaceColliding); if (leftValidAtAllTimes && !leftSmiley) //successful grip-release - make smiley once { hitAudio.Play(); leftSmiley = true; //TODO: other clauses can be removed if we don't want double failure sounds } else if (!leftSmiley && leftFaceColliding) //early grip { missAudio.Play(); //Debug.Log("not left smile and left face collide"); } else if (!leftFaceColliding) //late release { missAudio.Play(); //Debug.Log("not left face collide"); } gameCont.BoundaryTrigger(_GlobalVariables.LEFT_INDEX); //count number of grip-and-release leftValidAtAllTimes = false; //reset } } return(newSpriteNeeded); }
/// <summary> /// Postcondition: [side]FaceColliding = isSideColliding, side is left or right, based on isLeft /// </summary> /// <param name="isLeft">Whether to change status of left or right side</param> /// <param name="isSideColliding">Whether this side is currently colliding with a frowny face</param> public void SetIsSideColliding(bool isLeft, bool isSideColliding) { if (isLeft) { leftFaceColliding = isSideColliding; HappyTimesSmartFeedback.TriggerEvent(HappyTimesSmartFeedback.LEFT, HappyTimesSmartFeedback.NEITHER, leftFaceColliding); } else { rightFaceColliding = isSideColliding; HappyTimesSmartFeedback.TriggerEvent(HappyTimesSmartFeedback.RIGHT, HappyTimesSmartFeedback.NEITHER, rightFaceColliding); } }
//checks for state change and collisions in right hand, and play sound effects private bool CheckRight() { bool newSpriteNeeded = false; //check right bool prevRightActive = rightActive; //Debug.Log("Right force: " + _GlobalVariables.rightForce); //Debug.Log("Right force needed: " + rightBound); rightActive = _GlobalVariables.rightForce >= rightBound; if (rightActive != prevRightActive) { //sprite changed newSpriteNeeded = true; if (rightActive) //started to grip right { rightValidAtAllTimes = true; HappyTimesSmartFeedback.TriggerEvent(HappyTimesSmartFeedback.RIGHT, HappyTimesSmartFeedback.SQUEEZE, rightFaceColliding); } else { //releasing HappyTimesSmartFeedback.TriggerEvent(HappyTimesSmartFeedback.RIGHT, HappyTimesSmartFeedback.RELEASE, rightFaceColliding); if (rightValidAtAllTimes && !rightSmiley) //success for first time { hitAudio.Play(); rightSmiley = true; } else if (!rightSmiley && rightFaceColliding) //early grip { missAudio.Play(); } else if (!rightFaceColliding) //late release { missAudio.Play(); } gameCont.BoundaryTrigger(_GlobalVariables.RIGHT_INDEX); //count number of grip-and-release rightValidAtAllTimes = false; //reset } } return(newSpriteNeeded); }
protected new void EndGame() { base.EndGame(); string[] graphDisplays = { "leftAvgGripTime", "rightAvgGripTime" }; string[] graphTitles = { "Average Grip-Release Time For Left Hand Per Session", "Average Grip-Release Time For Right Hand Per Session" }; string[] tableCols1 = { "leftGrips", "leftHits", "leftFaces" }; string[] tableCols2 = { "rightGrips", "rightHits", "rightFaces" }; IGameSessionData[] dataArray = dataList.ToArray(); StringData[] tables = { new StringData(dataArray, tableCols1, format: "0"), new StringData(dataArray, tableCols2, format: "0"), new StringData(dataArray, graphDisplays, unit: "s") }; dataDisplay.AddTableView(tables); dataDisplay.AddTextView(HappyTimesSmartFeedback.LevelFinish()); dataDisplay.AddGraph(_GlobalVariables.dataRep.GetSessionData(TABLE_NAME, DATA_POINTS), graphDisplays, titles: graphTitles, difficulty: _GlobalVariables.difficulty); dataDisplay.InitializeDisplays(); }
private new void OnDestroy() { base.OnDestroy(); HappyTimesSmartFeedback.ResetVars(); }