Skip to content

Commit

Permalink
Creates foundation for overlay specific calibration
Browse files Browse the repository at this point in the history
Changes the way CalibrationDirectorNew uses overlays and sprite masks so that different reference points can be used
  • Loading branch information
thewithz committed Nov 22, 2020
1 parent dac64c1 commit 888eb6d
Show file tree
Hide file tree
Showing 7 changed files with 1,262 additions and 714 deletions.
13 changes: 9 additions & 4 deletions OdysseyNow/Assets/CalibrationDirectorNew.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ private void Start() {
// if screen overlay is used
if (mCalibrationSettings.useOverlay) {
mStepPipe.Add(new S3_CalibRead(this, mCalibrationSettings.overlay_topLeft_extra_text,
mCalibrationSettings.overlay_topLeft, playerReadName, "top-left"));
mCalibrationSettings.overlays[PlayerPrefs.GetString("game")], playerReadName, "top-left"));
mStepPipe.Add(new S3_CalibRead(this, mCalibrationSettings.overlay_bottomRight_extra_text,
mCalibrationSettings.overlay_bottomRight, playerReadName,
mCalibrationSettings.overlays[PlayerPrefs.GetString("game")], playerReadName,
"bottom-right"));
}
else {
Expand All @@ -79,9 +79,9 @@ private void Start() {
// if screen overlay is used
if (mCalibrationSettings.useOverlay) {
mStepPipe.Add(new S4_CalibWrite(this, mCalibrationSettings.overlay_topLeft_extra_text,
mCalibrationSettings.overlay_topLeft, playerWriteName, "top-left"));
mCalibrationSettings.overlays[PlayerPrefs.GetString("game")], playerWriteName, "top-left"));
mStepPipe.Add(new S4_CalibWrite(this, mCalibrationSettings.overlay_bottomRight_extra_text,
mCalibrationSettings.overlay_bottomRight, playerWriteName,
mCalibrationSettings.overlays[PlayerPrefs.GetString("game")], playerWriteName,
"bottom-right"));
}
else {
Expand Down Expand Up @@ -364,6 +364,7 @@ void IStateStep.OnEnterStep() {
}

mOverlaySpot.SetActive(true);
mOverlaySpot.transform.Find(mMode).gameObject.SetActive(true);

// Append extra text
if (mOverlayExtraText.TrimStart().TrimEnd() != "") {
Expand Down Expand Up @@ -443,7 +444,9 @@ void IStateStep.OnExitStep() {
break;
}

mOverlaySpot.transform.Find(mMode).gameObject.SetActive(false);
mOverlaySpot.SetActive(false);

}

void IStateStep.Step() {
Expand Down Expand Up @@ -490,6 +493,7 @@ void IStateStep.OnEnterStep() {
}

mOverlaySpot.SetActive(true);
mOverlaySpot.transform.Find(mMode).gameObject.SetActive(true);

// Append extra text
if (mOverlayExtraText.TrimStart().TrimEnd() != "") {
Expand Down Expand Up @@ -561,6 +565,7 @@ void IStateStep.OnExitStep() {
break;
}

mOverlaySpot.transform.Find(mMode).gameObject.SetActive(false);
mOverlaySpot.SetActive(false);
}

Expand Down
29 changes: 14 additions & 15 deletions OdysseyNow/Assets/CalibrationOdysseySettings.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditorInternal;

public class CalibrationOdysseySettings : MonoBehaviour
{
Expand All @@ -11,21 +13,22 @@ public class CalibrationOdysseySettings : MonoBehaviour

[Header("Calibration Step 2:")]
public bool useOverlay;
public SpriteRenderer screenOverlay;
public string overlay_extra_text;

public GameObject overlay_topLeft;
public string overlay_topLeft_extra_text;
public List<string> games;
public List<GameObject> calibdefs;

public Dictionary<string, GameObject> overlays;

public GameObject overlay_bottomRight;
public string overlay_extra_text;
public string overlay_topLeft_extra_text;
public string overlay_bottomRight_extra_text;

[Header("Calibration Step 3:")]
public float _calib_p1_read_votage_x_left = 617;
public float _calib_p1_read_votage_y_top = 711;
public float _calib_p1_read_votage_x_right = 300;
public float _calib_p1_read_votage_y_bottom = 379;

public float _calib_p1_write_votage_x_left = 420;
public float _calib_p1_write_votage_y_top = 180;
public float _calib_p1_write_votage_x_right = 302;
Expand All @@ -51,15 +54,11 @@ public class CalibrationOdysseySettings : MonoBehaviour
public float _calib_unity_y_top = 4.4f;
public float _calib_unity_y_bottom = -4.4f;

// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
void Awake()
{

overlays = new Dictionary<string, GameObject>();
for(int i = 0; i < games.Count; i++) {
overlays.Add(games[i], calibdefs[i]);
}
}
}
7 changes: 4 additions & 3 deletions OdysseyNow/Assets/ModeDirector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,19 @@ private void Awake() {
case "Tennis":
calibration.GetComponent<CalibrationDirectorNew>().afterCalibration.AddListener(StartTennis);
break;
case "Table Tennis":
calibration.GetComponent<CalibrationOdysseySettings>().useOverlay = false;
break;
}

var p1Input = (LocalInputManager.ControlScheme) System.Enum.Parse(typeof(LocalInputManager.ControlScheme),
PlayerPrefs.GetString("P1Input"));
var p2Input = (LocalInputManager.ControlScheme) System.Enum.Parse(typeof(LocalInputManager.ControlScheme),
PlayerPrefs.GetString("P2Input"));
// if both input schemes are keyboard, then no need for overlay
// if both input schemes are keyboard or AI, then no need to calibrate overlay
if ((p1Input == LocalInputManager.ControlScheme.Keyboard || p1Input == LocalInputManager.ControlScheme.AI) &&
(p2Input == LocalInputManager.ControlScheme.Keyboard || p2Input == LocalInputManager.ControlScheme.AI))
calibration.GetComponent<CalibrationOdysseySettings>().useOverlay = false;
else
calibration.GetComponent<CalibrationOdysseySettings>().useOverlay = true;

// if p1 is ai or keyboard, don't read calibration
if (p1Input == LocalInputManager.ControlScheme.AI || p1Input == LocalInputManager.ControlScheme.Keyboard)
Expand Down
Loading

0 comments on commit 888eb6d

Please sign in to comment.