Skip to content
Snippets Groups Projects
Commit 348b28fa authored by 13035516's avatar 13035516
Browse files

Added the fail conditions monitoring feature for the two cases: 1) Not...

Added the fail conditions monitoring feature for the two cases: 1) Not finishing in time; 2) Leaving too early
parent 72785b84
No related merge requests found
File deleted
File deleted
File deleted
No preview for this file type
File deleted
No preview for this file type
......@@ -47,7 +47,7 @@ public class GameController : MonoBehaviour
private const int NumGoals = 2;
// If exceeds this time including hold time, then the player loses
private const int FailTime = 4000;
private const int FailTime = 3500;
// Player must keep their sprite in the goal for this long in order to complete the task
private const int HoldTime = 1000;
// Time the player must spend in the base to be considered end of trial
......@@ -139,8 +139,7 @@ public class GameController : MonoBehaviour
// If the player hasn't achieved the hold time in the allotted time
// they fail
if (Timer > FailTime)
{
if (FailConditions()) {
TrialResult = false;
TrialState = false;
}
......@@ -177,7 +176,6 @@ public class GameController : MonoBehaviour
// base position
if ( BaseTriggerBoundary.GetStayTime() >= (float)BaseHoldTime/1e3 ) {
EndTrialSequence();
Debug.Log("End complete");
}
}
}
......@@ -242,8 +240,6 @@ public class GameController : MonoBehaviour
{
GoalsChangeColour[GoalSet].GoalState = 0;
Timer = 0;
// THERE IS A BUG HERE, LOOK TO FIX, WHY CAN'T I CREATE ARRAYS OF
// CLASS OBJECTS?
mExperimentCtrl[ExperimentTrial].Index = ExperimentTrial;
mExperimentCtrl[ExperimentTrial].TrialResult = TrialResult;
ExperimentTrial++;
......@@ -252,7 +248,14 @@ public class GameController : MonoBehaviour
// Check for any fail conditions here
// Incl: Taking too long to finish, leaving early (disqualification)
private bool FailConditions() {
return true;
float goTime = mTimingSetting.TrialStart + mTimingSetting.TargetOnset +
OnsetDev;
bool base_exit = BaseTriggerBoundary.ExitColliderIsTriggered;
if (Timer > FailTime || (Timer < goTime && base_exit))
{
return true;
}
return false;
}
}
......@@ -139,8 +139,7 @@ public class GameController : MonoBehaviour
// If the player hasn't achieved the hold time in the allotted time
// they fail
if (Timer > FailTime)
{
if (FailConditions()) {
TrialResult = false;
TrialState = false;
}
......@@ -156,8 +155,8 @@ public class GameController : MonoBehaviour
+ DestTriggerBoundary.name + "\tDestStayTime: " +
DestTriggerBoundary.GetStayTime().ToString() +
"\nmExpCtrl-1: " +
mExperimentCtrl[ExperimentTrial].Index.ToString() + "\t" +
mExperimentCtrl[ExperimentTrial].TrialResult.ToString();
mExperimentCtrl[ExperimentTrial-1].Index.ToString() + "\t" +
mExperimentCtrl[ExperimentTrial-1].TrialResult.ToString();
}
else
{
......@@ -177,7 +176,6 @@ public class GameController : MonoBehaviour
// base position
if ( BaseTriggerBoundary.GetStayTime() >= (float)BaseHoldTime/1e3 ) {
EndTrialSequence();
Debug.Log("End complete");
}
}
}
......@@ -242,8 +240,6 @@ public class GameController : MonoBehaviour
{
GoalsChangeColour[GoalSet].GoalState = 0;
Timer = 0;
// THERE IS A BUG HERE, LOOK TO FIX, WHY CAN'T I CREATE ARRAYS OF
// CLASS OBJECTS?
mExperimentCtrl[ExperimentTrial].Index = ExperimentTrial;
mExperimentCtrl[ExperimentTrial].TrialResult = TrialResult;
ExperimentTrial++;
......@@ -252,7 +248,14 @@ public class GameController : MonoBehaviour
// Check for any fail conditions here
// Incl: Taking too long to finish, leaving early (disqualification)
private bool FailConditions() {
return true;
float goTime = mTimingSetting.TrialStart + mTimingSetting.TargetOnset +
OnsetDev;
bool base_exit = BaseTriggerBoundary.ExitColliderIsTriggered;
if (Timer > FailTime || (Timer < goTime && base_exit))
{
return true;
}
return false;
}
}
......@@ -5,6 +5,7 @@ using UnityEngine;
public class TriggerBoundary : MonoBehaviour
{
public bool ColliderIsTriggered { get; private set; }
public bool ExitColliderIsTriggered { get; private set; }
private float time;
......@@ -17,12 +18,14 @@ public class TriggerBoundary : MonoBehaviour
void OnTriggerStay2D(Collider2D collider)
{
ColliderIsTriggered = true;
ExitColliderIsTriggered = false;
time += Time.deltaTime;
}
void OnTriggerExit2D()
{
ColliderIsTriggered = false;
ExitColliderIsTriggered = true;
time = 0.0f;
}
......
......@@ -17,7 +17,7 @@ public class TriggerBoundary : MonoBehaviour
void OnTriggerStay2D(Collider2D collider)
{
ColliderIsTriggered = true;
time += Time.deltaTime/1e3;
time += Time.deltaTime;
}
void OnTriggerExit2D()
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment