public override void Setup() { ctrler = ExperimentController.Instance(); //pinballDummy = Instantiate(ctrler.GetPrefab("PinballPrefabDummy")); //pinballDummy.transform.SetParent(ctrler.gameObject.transform); //pinballDummy.transform.localPosition = new Vector3(0, 0, 0); string per_block_ins = ctrler.Session.CurrentTrial.settings.GetString("per_block_instruction"); ins = ctrler.Session.CurrentTrial.settings.GetString(per_block_ins); // Temporarily disable VR Camera // TODO: This needs to be changed when we implement instruction task for VR //ctrler.CursorController.SetVRCamera(false); //Task GameObjects instructionPanel = Instantiate(ctrler.GetPrefab("InstructionPanel"), this.transform); instruction = GameObject.Find("Instruction"); timer = GameObject.Find("Timer"); done = GameObject.Find("Done"); vrInstructions = GameObject.Find("VRInstructions"); vrInstructions.transform.localPosition = new Vector3(vrInstructions.transform.localPosition.x, vrInstructionOffset, vrInstructions.transform.localPosition.z); instruction.GetComponent <Text>().text = ins; vrInstructions.GetComponent <TextMesh>().text = ins; //countdown Timer start timer.GetComponent <Text>().text = System.Math.Round(timeRemaining, 0).ToString(); //add event listener to done button done.GetComponent <Button>().onClick.AddListener(() => End()); }
public override void Setup() { ctrler = ExperimentController.Instance(); trial = ctrler.Session.CurrentTrial; Cursor.visible = false; reachPrefab = Instantiate(ctrler.GetPrefab("ReachPrefab")); reachPrefab.transform.SetParent(ctrler.transform); reachPrefab.transform.localPosition = Vector3.zero; reachCam = GameObject.Find("ReachCamera"); reachSurface = GameObject.Find("Surface"); waterBowl = GameObject.Find("Bowl"); water = GameObject.Find("Water"); timerIndicator = GameObject.Find("TimerIndicator").GetComponent <TimerIndicator>(); scoreboard = GameObject.Find("Scoreboard").GetComponent <Scoreboard>(); timerIndicator.Timer = ctrler.Session.CurrentBlock.settings.GetFloat("per_block_timerTime"); // Whether or not this is a practice trial // replaces scoreboard with 'Practice Round', doesn't record score trackScore = (ctrler.Session.CurrentBlock.settings.GetBool("per_block_track_score")); if (!trackScore) { // Scoreboard is now updated by the reach class scoreboard.AllowManualSet = true; scoreboard.ScorePrefix = false; scoreboard.ManualScoreText = "Practice Round"; } Enum.TryParse(ctrler.Session.CurrentTrial.settings.GetString("per_block_type"), out MovementType rType); reachType = new MovementType[3]; reachType[2] = rType; maxSteps = 3; // Set up hand and cursor ctrler.CursorController.SetHandVisibility(false); ctrler.CursorController.SetCursorVisibility(true); // Set up the dock position targets[0] = GameObject.Find("Dock"); targets[0].transform.position = ctrler.TargetContainer.transform.position; // Set up the home position targets[1] = GameObject.Find("Home"); targets[1].transform.position = ctrler.TargetContainer.transform.position + ctrler.transform.forward * 0.05f; targets[1].SetActive(false); Home = targets[1]; // Set up the target // Takes a target angle from the list and removes it float targetAngle = Convert.ToSingle(ctrler.PollPseudorandomList("per_block_targetListToUse")); targets[2] = GameObject.Find("Target"); targets[2].transform.rotation = Quaternion.Euler( 0f, -targetAngle + 90f, 0f); targets[2].transform.position = targets[1].transform.position + targets[2].transform.forward.normalized * (trial.settings.GetFloat("per_block_distance") / 100f); // Disable collision detection for nocursor task if (trial.settings.GetString("per_block_type") == "nocursor") { targets[2].GetComponent <BaseTarget>().enabled = false; } targets[2].SetActive(false); Target = targets[2]; // Use static camera for non-vr version if (ctrler.Session.settings.GetString("experiment_mode") == "target") { reachSurface.SetActive(false); reachCam.SetActive(false); ctrler.CursorController.UseVR = true; } else { ctrler.CursorController.SetVRCamera(false); } // sets up the water in the level if (ctrler.Session.CurrentBlock.settings.GetString("per_block_waterPresent") == "wp1") { float waterLevel = Convert.ToSingle(ctrler.PollPseudorandomList("per_block_waterPresent")); waterBowl.SetActive(true); water.SetActive(true); // If previous trial had a water level, animate water level rising/falling from that level try { if (ctrler.Session.PrevTrial.result.ContainsKey("per_block_waterPresent")) { water.transform.localPosition = new Vector3(water.transform.localPosition.x, Convert.ToSingle(ctrler.Session.PrevTrial.result["per_block_waterPresent"]) / 10, water.transform.localPosition.z); id = LeanTween.moveLocalY(water, waterLevel / 10, speed).id; d = LeanTween.descr(id); } else { water.transform.localPosition = new Vector3(0, -0.03f, 0); id = LeanTween.moveLocalY(water, waterLevel / 10, speed).id; d = LeanTween.descr(id); } } catch (NoSuchTrialException e) { water.transform.localPosition = new Vector3(0, -0.03f, 0); id = LeanTween.moveLocalY(water, waterLevel / 10, speed).id; d = LeanTween.descr(id); } } else { waterBowl.SetActive(false); water.SetActive(false); } }
/* * Step 0: * * spawn at startpoint gate * mouse move to car point * * Step 1: * let car move * * Step 2: * hit wall or hit finish line gate * log parameters * end trial * * Step 3: * finished * */ public override void Setup() { maxSteps = 3; ctrler = ExperimentController.Instance(); trailSpace = Instantiate(ctrler.GetPrefab("TrailPrefab")); trailGate1 = GameObject.Find("TrailGate1"); trailGate2 = GameObject.Find("TrailGate2"); startCollider = trailGate1.transform.GetChild(3).GetComponent <BoxCollider>(); midwayCollider = GameObject.Find("MidwayCollider").GetComponent <BoxCollider>(); gatePlacement = GameObject.Find("gatePlacement").GetComponent <GatePlacement>(); roadSegments = GameObject.Find("generated_by_SplineExtrusion"); scoreboard = GameObject.Find("Scoreboard").GetComponent <Scoreboard>(); for (int i = 0; i < roadSegments.transform.childCount; i++) { // add road segments to gatePlacement list of meshes gatePlacement.mesh.Add(roadSegments.transform.GetChild(i).GetComponent <MeshFilter>().mesh); } gatePlacement.Setup(); /* TrailGate children: * 0: pole1 * 2: pole2 * 3: checkered line (line renderer component) * 4: trigger (collider component) */ startPoint = ctrler.Session.CurrentBlock.settings.GetFloat("per_block_startPoint"); gatePlacement.SetGatePosition(trailGate1, trailGate1.transform.GetChild(0).gameObject, trailGate1.transform.GetChild(1).gameObject, trailGate1.transform.GetChild(2).GetComponent <LineRenderer>(), trailGate1.transform.GetChild(3).GetComponent <BoxCollider>(), startPoint); endPoint = ctrler.Session.CurrentBlock.settings.GetFloat("per_block_endPoint"); gatePlacement.SetGatePosition(trailGate2, trailGate2.transform.GetChild(0).gameObject, trailGate2.transform.GetChild(1).gameObject, trailGate2.transform.GetChild(2).GetComponent <LineRenderer>(), trailGate2.transform.GetChild(3).GetComponent <BoxCollider>(), endPoint); // Place midway triggers throughout the track for (int i = 0; i < NUM_MID_TRIGGERS; i++) { midwayTriggers.Add(Instantiate(midwayCollider.gameObject).GetComponent <BaseTarget>()); // Start Mid1 Mid2 End // |--------|--------|--------| if (endPoint < startPoint) { // If the end point comes before the start point float distance = 1 - startPoint + endPoint; midPoint = ((distance) / (NUM_MID_TRIGGERS + 1)) * (i + 1) + startPoint; if (midPoint > 1) { midPoint -= 1; } } else { float distance = endPoint - startPoint; midPoint = ((distance) / (NUM_MID_TRIGGERS + 1)) * (i + 1) + startPoint; } gatePlacement.SetColliderPosition(midwayTriggers[i].GetComponent <BoxCollider>(), midPoint); } railing1 = GameObject.Find("generated_by_SplineMeshTiling"); foreach (MeshCollider railing in railing1.transform.GetComponentsInChildren <MeshCollider>()) { railing.tag = "TrailRailing"; railing.convex = true; railing.isTrigger = true; railing.gameObject.SetActive(false); } railing2 = GameObject.Find("generated_by_SplineMeshTiling_1"); foreach (MeshCollider railing in railing1.transform.GetComponentsInChildren <MeshCollider>()) { railing.tag = "TrailRailing"; railing.convex = true; railing.isTrigger = true; railing.gameObject.SetActive(false); } for (int i = 0; i < railing1.transform.GetChild(0).transform.childCount; i++) { railing1.transform.GetChild(i).gameObject.AddComponent <BaseTarget>(); } for (int i = 0; i < railing2.transform.childCount; i++) { railing2.transform.GetChild(i).gameObject.AddComponent <BaseTarget>(); } car = GameObject.Find("Car"); car.transform.position = trailGate1.transform.position; raycastOrigins.AddRange(car.GetComponentsInChildren <Transform>()); innerTrackColliders.AddRange(GameObject.Find("innertrack").transform.GetComponentsInChildren <BaseTarget>()); if (ctrler.Session.currentTrialNum > 1) { trailGate1.GetComponentInChildren <ParticleSystem>().transform.position = trailGate1.transform.position; trailGate1.GetComponentInChildren <ParticleSystem>().transform.rotation = trailGate1.transform.rotation; trailGate1.GetComponentInChildren <ParticleSystem>().Play(); trailSpace.GetComponent <AudioSource>().clip = ctrler.AudioClips["correct"]; trailSpace.GetComponent <AudioSource>().Play(); } // Use static camera for non-vr version of pinball if (ctrler.Session.settings.GetString("experiment_mode") == "trail") { ctrler.CursorController.SetVRCamera(false); } else { } }
public override void Setup() { ExperimentController ctrler = ExperimentController.Instance(); maxSteps = 4; ctrler.CursorController.SetHandVisibility(false); Cursor.visible = false; ctrler.CursorController.SetCursorVisibility(true); localizationPrefab = Instantiate(ctrler.GetPrefab("LocalizationPrefab")); localizationPrefab.transform.SetParent(ctrler.transform); localizationPrefab.transform.localPosition = Vector3.zero; localizationCam = GameObject.Find("LocalizationCamera"); localizationSurface = GameObject.Find("Surface"); // Set up the dock position targets[0] = GameObject.Find("Dock"); targets[0].transform.position = ctrler.TargetContainer.transform.position; // Set up the home position targets[1] = GameObject.Find("Home"); targets[1].transform.position = ctrler.TargetContainer.transform.position + ctrler.transform.forward * 0.05f; targets[1].SetActive(false); Home = targets[1]; // Grab an angle from the list and then remove it float targetAngle = Convert.ToSingle(ctrler.PollPseudorandomList("per_block_targetListToUse")); // Set up the arc object targets[2] = GameObject.Find("ArcTarget"); targets[2].transform.rotation = Quaternion.Euler( 0f, -targetAngle + 90f, 0f); targets[2].transform.position = targets[1].transform.position; targets[2].GetComponent <ArcScript>().TargetDistance = ctrler.Session.CurrentTrial.settings.GetFloat("per_block_distance"); targets[2].GetComponent <ArcScript>().Angle = targets[2].transform.rotation.eulerAngles.y; //targets[2].transform.localScale = Vector3.one; Target = targets[2]; // Set up the GameObject that tracks the user's gaze localizer = GameObject.Find("Localizer"); localizer.GetComponent <SphereCollider>().enabled = false; localizer.GetComponent <BaseTarget>().enabled = false; localizer.SetActive(false); localizer.transform.SetParent(ctrler.TargetContainer.transform); localizer.name = "Localizer"; Target.SetActive(false); // Use static camera for non-vr version of pinball if (ctrler.Session.settings.GetString("experiment_mode") == "target") { localizationSurface.SetActive(false); localizationCam.SetActive(false); ctrler.CursorController.UseVR = true; } else { ctrler.CursorController.SetVRCamera(false); } }