protected const float TARGET_DISTANCE = 0.85f; // Target distance from home public override void Setup() { Surface = GameObject.Find("Surface"); timerIndicator = GameObject.Find("TimerIndicator").GetComponent <TimerIndicator>(); scoreboard = GameObject.Find("Scoreboard").GetComponent <Scoreboard>(); // Scoreboard is now updated by the billiards class scoreboard.AllowManualSet = true; cameraTilt = Convert.ToSingle(ctrler.PollPseudorandomList("per_block_list_camera_tilt")); surfaceTilt = Convert.ToSingle(ctrler.PollPseudorandomList("per_block_list_surface_tilt")); cameraTilt -= surfaceTilt; // As surfaceTilt rotates the entire prefab, this line makes creating the json more intuitive // 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.ScorePrefix = false; scoreboard.ManualScoreText = "Practice Round"; } }
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); } }