Skip to content

Commit

Permalink
Refactors input management
Browse files Browse the repository at this point in the history
  • Loading branch information
thewithz committed Feb 20, 2020
1 parent 2333cab commit 7e7f135
Show file tree
Hide file tree
Showing 12 changed files with 1,311 additions and 3,507 deletions.
2 changes: 0 additions & 2 deletions OdysseyNow/.idea/.idea.OdysseyNow/.idea/contentModel.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 17 additions & 7 deletions OdysseyNow/.idea/.idea.OdysseyNow/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 29 additions & 51 deletions OdysseyNow/Assets/ModeDirector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,79 +23,57 @@ private void Start() {
//{
// Enable calibration

if (LocalInputManager.instance == null) {
switch (PlayerPrefs.GetString("game")) {
case "Cat and Mouse":
// load cat and mouse after calibration
calibration.GetComponent<CalibrationDirectorNew>().afterCalibration.AddListener(StartCatAndMouse);
break;
case "Super Cat and Mouse":
break;
case "Haunted House":
break;
case "Zoo Breakout":
break;
case "Football: Running":
break;
}
// fixme


calibration.GetComponent<CalibrationOdysseySettings>().useOverlay = false;

// if p1 is ai, don't read calibration
if (PlayerPrefs.GetInt("ai1") != -1)
calibration.GetComponent<CalibrationOdysseySettings>().p1_read = false;
// if p2 is ai, don't read calibration
if (PlayerPrefs.GetInt("ai2") != -1)
calibration.GetComponent<CalibrationOdysseySettings>().p2_read = false;
StartCalibration();

return;
}

switch (LocalInputManager.instance.p1Scheme) {
case LocalInputManager.ControlScheme.AI:
switch (PlayerPrefs.GetString("game")) {
case "Cat and Mouse":
// load cat and mouse after calibration
calibration.GetComponent<CalibrationDirectorNew>().afterCalibration.AddListener(StartCatAndMouse);
break;
case LocalInputManager.ControlScheme.OriginalConsole:
calibration.GetComponent<CalibrationOdysseySettings>().p1_read = true;
case "Super Cat and Mouse":
break;
case LocalInputManager.ControlScheme.Keyboard:
case "Haunted House":
break;
case LocalInputManager.ControlScheme.Traditional:
case "Zoo Breakout":
break;
case LocalInputManager.ControlScheme.OdysseyCon:
case "Football: Running":
break;
case LocalInputManager.ControlScheme.OdysseyConLegacy:
break;
default:
throw new ArgumentOutOfRangeException();
}

if (LocalInputManager.instance.p2Scheme == LocalInputManager.ControlScheme.OriginalConsole) {
calibration.GetComponent<CalibrationOdysseySettings>().p2_read = true;
}
// if both input schemes are keyboard, then no need for overlay
// calibration.GetComponent<CalibrationOdysseySettings>().useOverlay = false;

calibration.GetComponent<CalibrationOdysseySettings>().useOverlay = true;

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 p1 is ai, don't read calibration
if (p1Input == LocalInputManager.ControlScheme.AI)
calibration.GetComponent<CalibrationOdysseySettings>().p1_read = false;
// if p2 is ai, don't read calibration
if (p2Input == LocalInputManager.ControlScheme.AI)
calibration.GetComponent<CalibrationOdysseySettings>().p2_read = false;
StartCalibration();
}

private void StartCatAndMouse() {
calibration.SetActive(false);
var p1 = ElementSettings.FindFromNameAndTag("PlayerTarget", "Player1");
var p2 = ElementSettings.FindFromNameAndTag("PlayerTarget", "Player2");
var player1AI = PlayerPrefs.GetInt("ai1");
var player2AI = PlayerPrefs.GetInt("ai2");
if (player1AI != -1) {
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 (p1Input == LocalInputManager.ControlScheme.AI) {
p1.GetComponent<NavMeshAgent>().enabled = true;
p1.GetComponent<CatAI>().enabled = true;
p1.GetComponent<CatAI>().level = player1AI;
p1.GetComponent<CatAI>().level = PlayerPrefs.GetInt("ai1");
}

if (player2AI != -1) {
if (p2Input == LocalInputManager.ControlScheme.AI) {
p2.GetComponent<NavMeshAgent>().enabled = true;
p2.GetComponent<MouseAI>().enabled = true;
p2.GetComponent<MouseAI>().level = player2AI;
p2.GetComponent<MouseAI>().level = PlayerPrefs.GetInt("ai2");
}

AI.SetActive(true);
Expand Down
Loading

0 comments on commit 7e7f135

Please sign in to comment.