void Update() { AnimatorStateInfo state = Animator.GetCurrentAnimatorStateInfo(0); if (!state.IsName("P1Config") && !state.IsName("P2Config") && !state.IsName("P3Config") && !state.IsName("P4Config")) { return; } if (Input.GetKeyDown(KeyCode.F12) && Input.GetKey(KeyCode.LeftShift)) { Debug.Log("flusing save data"); PlayerPrefs.DeleteAll(); return; } if (Input.GetKeyDown(KeyCode.Escape)) { if (CurrentPhase == ConfigurationPhase.SlideUp) { if (CurrentPlayer == 1) { QuitWithoutSaving(); } else { CurrentPlayer--; PlayerConfigurators[CurrentPlayer - 1].Unready(); GetComponent<GameJoinControl>().PlayersReady[CurrentPlayer - 1] = false; } } else { CurrentPhase = ConfigurationPhase.SlideUp; } PlaySound(CancelClip, Players[CurrentPlayer-1]); return; } if (WaitingForAxisReset) { if (GamePad.GetAxis(GamePad.Axis.Dpad, GamePadIndex).magnitude > 0.1f || GamePad.GetAxis(GamePad.Axis.LeftStick, GamePadIndex).magnitude > 0.1f || GamePad.GetAxis(GamePad.Axis.RightStick, GamePadIndex).magnitude > 0.1f) { return; } WaitingForAxisReset = false; } if (CurrentPhase == ConfigurationPhase.WaitingToReadInput) { if (CurrentControllerType != ControllerType.Gamepad || AnyPad() == GamePad.Index.Any) { CurrentPhase++; } } else if (CurrentPhase == ConfigurationPhase.SlideUp) { if (PressedKeyOrButton() != KeyCode.None) { CurrentControllerType = ControllerType.Keyboard; FetchAxisMapping(ref KeyboardSlideUp, ref GamePadVerticalAxis, ref GamePadVerticalAxisDirection); } else { GamePad.Index index = AnyPad(); if (index != GamePad.Index.Any) { CurrentControllerType = ControllerType.Gamepad; GamePadIndex = index; FetchAxisMapping(ref KeyboardSlideUp, ref GamePadVerticalAxis, ref GamePadVerticalAxisDirection); } } } else if (CurrentPhase == ConfigurationPhase.SlideDown) { FetchAxisMapping(ref KeyboardSlideDown, ref GamePadHorizontalAxis, ref GamePadHorizontalAxisDirection, true); } else if (CurrentPhase == ConfigurationPhase.SlideLeft) { FetchAxisMapping(ref KeyboardSlideLeft, ref GamePadHorizontalAxis, ref GamePadHorizontalAxisDirection); } else if (CurrentPhase == ConfigurationPhase.SlideRight) { FetchAxisMapping(ref KeyboardSlideRight, ref GamePadHorizontalAxis, ref GamePadHorizontalAxisDirection, true); } else if (CurrentPhase == ConfigurationPhase.RocketUp) { FetchButtonMapping(ref KeyboardRocketUp, ref GamePadRocketUp); } else if (CurrentPhase == ConfigurationPhase.RocketDown) { FetchButtonMapping(ref KeyboardRocketDown, ref GamePadRocketDown); } else if (CurrentPhase == ConfigurationPhase.RocketLeft) { FetchButtonMapping(ref KeyboardRocketLeft, ref GamePadRocketLeft); } else if (CurrentPhase == ConfigurationPhase.RocketRight) { FetchButtonMapping(ref KeyboardRocketRight, ref GamePadRocketRight); } else if (CurrentPhase == ConfigurationPhase.Finished) { StoreForSaving(); PlayerConfigurators[CurrentPlayer - 1].Ready(); GetComponent<GameJoinControl>().PlayersReady[CurrentPlayer - 1] = true; if (CurrentPlayer < PlayersToConfigure) { CurrentPlayer++; CurrentPhase = ConfigurationPhase.WaitingToReadInput; } else { SaveAndQuit(); } } UpdateGUI(); }
void Start() { CurrentPlayer = 1; CurrentPhase = ConfigurationPhase.SlideUp; SoundBoard = FindObjectOfType<SoundBoard>(); Cursor.visible = false; }