void playerInput(int playNum) { #if WindowsBuild _Controller = Gen_ControllerManager.Instance.GetController(playNum); if (_Controller.IsConnected) { //_Fire = _Controller.GetButton("RB") ? 1 : 0; _FireDown = _Controller.GetButtonDown("RB") ? 1 : 0; _FireUp = _Controller.GetButtonUp("RB") ? 1 : 0; } else if (playNum == 3) { //_Fire = Input.GetButton("Fire3") ? 1 : 0; _FireDown = Input.GetButtonDown("Fire3") ? 1 : 0; } else if (playNum == 4) { //_Fire = Input.GetButton("Fire4") ? 1 : 0; _FireDown = Input.GetButtonDown("Fire4") ? 1 : 0; } #else //_Fire = Input.GetButton("Fire" + playNum.ToString()) ? 1 : 0; _FireDown = Input.GetButtonDown("Fire" + playNum.ToString()) ? 1 : 0; _FireUp = Input.GetButtonUp("Fire" + playNum.ToString()) ? 1 : 0; #endif }
/* * // Handles dying * ///Controller rumble only works on windows builds (xinput) */ public void Dying() { //VisScript.MakeVisDeath(); _LifeState = LifeState.Dying; #if WindowsBuild switch (_PlayerColor) { case PlayerColor.BLUE: _Controller = Gen_ControllerManager.Instance.GetController(1); break; case PlayerColor.YELLOW: _Controller = Gen_ControllerManager.Instance.GetController(2); break; case PlayerColor.RED: _Controller = Gen_ControllerManager.Instance.GetController(3); break; case PlayerColor.GREEN: _Controller = Gen_ControllerManager.Instance.GetController(4); break; } if (_Controller.IsConnected) { //Debug.Log("rumble"); _Controller.AddRumble(1.5f, new Vector2(0.75f, 0.75f), 0.5f); } #endif //Displays the Particles transform.FindChild("Blood").GetComponent <ParticleSystem>().Play(); }
/* * / Returns input of specefiek player */ void playerInput(int playNum) { #if WindowsBuild _Controller = Gen_ControllerManager.Instance.GetController(playNum); _Activate = _Controller.GetButtonDown("LB"); #else _Activate = Input.GetButton("Activate" + playNum.ToString()); #endif }
void Start() { #if WindowsBuild _Controller = Gen_ControllerManager.Instance.GetController(1); #endif // LevelSelect = 0; //_Controls.enabled = false; ButtonArray[0] = _ButtonRestart; ButtonArray[1] = _ButtonMainMenu; ButtonArray[2] = _ButtonQuit; }
void Start() { #if WindowsBuild _Controller = Gen_ControllerManager.Instance.GetController(1); #endif // LevelSelect = 0; //_Controls.enabled = false; _ButtonArray[0] = ButtonPlay; _ButtonArray[1] = ButtonControls; _ButtonArray[2] = ButtonQuit; _ButtonArray[3] = ButtonBack; if (_ButtonArray[_Counter] != null) { _ButtonArray[_Counter].GetComponent <Button>().Select(); } }
/* * / Returns input of specific player */ void playerInput(int playNum) { #if WindowsBuild _Controller = Gen_ControllerManager.Instance.GetController(playNum); if (_Controller.IsConnected) { _LeftStickX = _Controller.GetStick_L().X; _LeftStickY = _Controller.GetStick_L().Y; _RightStickX = _Controller.GetStick_R().X; _RightStickY = _Controller.GetStick_R().Y; } #else _LeftStickX = Input.GetAxis("LeftStickX" + playNum.ToString()); _LeftStickY = Input.GetAxis("LeftStickY" + playNum.ToString()); _RightStickX = Input.GetAxis("RightStickX" + playNum.ToString()); _RightStickY = Input.GetAxis("RightStickY" + playNum.ToString()); #endif }
void Update() { #if WindowsBuild _Controller = Gen_ControllerManager.Instance.GetController(1); if (_Controller.IsConnected) { if (_Controller.GetButtonDown("A")) { ReDirect(); } } #else if (Input.GetButton("Ready1") || Input.GetButtonDown("Submit")) { ReDirect(); } #endif }
void CheckGame() { ContinueText.GetComponent <Text>().text = "Press A when ready"; //check if enabled players are ready (not enabled players not ready) if (_playerCount > 1) { bool everyoneReady = false; for (int i = 0; i < 4; ++i) { if (PlayerEnabled[i] == _PlayerReady[i]) { everyoneReady = true; } else { //Not enough players ready everyoneReady = false; break; } } if (everyoneReady) { ContinueText.GetComponent <Text>().text = "Player 1 press A to start"; #if WindowsBuild //WINDOWS _Controller = Gen_ControllerManager.Instance.GetController(1); if (_Controller.IsConnected) { if (_Controller.GetButtonDown("A")) { LevelSelectMenu.SetActive(true); } } #else //WEB if (Input.GetButtonDown("Ready1")) { LevelSelectMenu.SetActive(true); } #endif } } }
void playerInput(int playNum) { #if WindowsBuild _Controller = Gen_ControllerManager.Instance.GetController(playNum); #else //if (Time.timeScale == 1.0f) //{ _Pause = Input.GetButtonDown("Start" + playNum.ToString()); if (_Pause) { _PausedPlayer = playNum; } // } // else // { // _Pause = Input.GetButtonDown("Start" + pausedPlayer.ToString()); // } // #endif //Debug.Log(Input.GetButtonDown("Start" + playNum.ToString())); }
// Update is called once per frame void Update() { #if WindowsBuild _Controller = Gen_ControllerManager.Instance.GetController(1); if (_Controller.IsConnected) { _LeftStickX = _Controller.GetStick_L().X; } #else _LeftStickX = Input.GetAxis("LeftStickX1"); #endif if (_LeftStickX == 0.0f && _Moved) { _Moved = false; } if ((_LeftStickX > 0.5f || _LeftStickX < -0.5f) && !_Moved) { _Moved = true; ChangeSelected(); } #if WindowsBuild if (_Controller.IsConnected) { if (_Controller.GetButtonDown("A")) { ClickSelected(); } } #else if (Input.GetButtonDown("Ready1")) { ClickSelected(); } #endif }
void Update() { pausedPlayer = _PauseScript._PausedPlayer; //Debug.Log(pausedPlayer); #if WindowsBuild if (pausedPlayer == 0) { _Controller = Gen_ControllerManager.Instance.GetController(1); } else { _Controller = Gen_ControllerManager.Instance.GetController(pausedPlayer); } // Debug.Log(_Controller.Index); if (_Controller.IsConnected) { _LeftStickY = _Controller.GetStick_L().Y; } #else if (Time.timeScale == 0) { _LeftStickY = Input.GetAxis("LeftStickY" + pausedPlayer.ToString()); } #endif if ((_LeftStickY == 0.0f)) { flag = true; } if (_LeftStickY >= .75f && flag) { flag = false; Cycle(false); } if (_LeftStickY <= -.75f && flag) { flag = false; Cycle(true); } //Debug.Log(_LeftStickY); //Debug.Log(_Counter); #if WindowsBuild if (Time.timeScale == 0) { if (_Controller.IsConnected) { ButtonArray[_Counter].GetComponent <Button>().Select(); if (_Controller.GetButtonDown("A")) { switch (_Counter) { case 0: Restart(); break; case 1: MainMenu(); break; case 2: Quit(); break; } } } } else if (Time.timeScale == 1.0f) { _Counter = 0; } #else if (Time.timeScale == 0) { //if (ButtonArray[_Counter].GetComponent<Button>().IsActive()) //Debug.Log(_Counter); //Debug.Log(ButtonArray[_Counter].GetComponent<Button>().IsActive()); ButtonArray[_Counter].GetComponent <Button>().Select(); //Debug.Log(_Counter); if (Input.GetButtonDown("Ready" + pausedPlayer.ToString())) { switch (_Counter) { case 0: Restart(); break; case 1: MainMenu(); break; case 2: Quit(); break; } } } else if (Time.timeScale == 1.0f) { _Counter = 0; } #endif //if (_PauseScript._Pause) //_Counter = 0; }
void chooseName(int index) { int playNum = index + 1; _Counter -= Time.deltaTime; #if WindowsBuild _Controller = Gen_ControllerManager.Instance.GetController(playNum); if (_Controller.IsConnected) { if (_Controller.GetButtonDown("DPad_Left")) { if (NameIndexes[index] <= 0) { NameIndexes[index] = Names.Count - 1; } else { --NameIndexes[index]; } } if (_Controller.GetButtonDown("DPad_Right")) { if (NameIndexes[index] >= Names.Count - 1) { NameIndexes[index] = 0; } else { ++NameIndexes[index]; } } //Random name if (_Controller.GetButtonDown("Y")) { NameIndexes[index] = Random.Range(0, Names.Count); } } #else float dpadX = getDpadX(playNum); if (dpadX < 0.0f && _Counter < 0.0f) { if (NameIndexes[index] <= 0) { NameIndexes[index] = Names.Count - 1; } else { --NameIndexes[index]; } _Counter = 0.7f; } if (dpadX > 0.0f && _Counter < 0.0f) { if (NameIndexes[index] >= Names.Count - 1) { NameIndexes[index] = 0; } else { ++NameIndexes[index]; } _Counter = 0.7f; } //Random name if (Input.GetButtonDown("YButton" + playNum.ToString())) { NameIndexes[index] = Random.Range(0, Names.Count); } #endif }
void dropInPlayer() { #if WindowsBuild for (int i = 0; i < 4; ++i) { int playNum = i + 1; //WINDOWS _Controller = Gen_ControllerManager.Instance.GetController(playNum); if (_Controller.IsConnected) { if ((_Controller.GetButtonDown("A") || _Controller.GetButtonDown("RB")) && !PlayerEnabled[i]) { EnablePlayer(i, false, playNum); } } } if (/*_IntroLevel&&*/ _KeyboardUser == 0) { if (Input.GetKeyDown(KeyCode.Space)) { for (int i = 0; i < 4; ++i) { int playNum = i + 1; if (!PlayerEnabled[i]) { EnablePlayer(i, true, playNum); _KeyboardUserId = i + 1; Debug.Log(playNum); break; } } } } #else for (int i = 0; i < 4; ++i) { int playNum = i + 1 - _KeyboardUser; if (playNum <= 4) { if (playNum != 0) { if (((Input.GetButtonDown("Ready" + playNum.ToString()) || Input.GetAxis("Fire" + playNum.ToString()) > 0)) && !PlayerEnabled[i]) { Debug.Log(playNum); EnablePlayer(i, false, playNum); } } } } if (/*_IntroLevel&&*/ _KeyboardUser == 0) { if (Input.GetKeyDown(KeyCode.Space)) { for (int i = 0; i < 4; ++i) { int playNum = i + 1; if (!PlayerEnabled[i]) { EnablePlayer(i, true, playNum); _KeyboardUserId = i + 1; Debug.Log(playNum); break; } } } } #endif }
void ReadyPlayers() { if (_playerCount > 1) { ContinueText.SetActive(true); for (int i = 0; i < 4; ++i) { int playNum = i + 1; //WINDOWS #if WindowsBuild _Controller = Gen_ControllerManager.Instance.GetController(playNum); if (playNum == _KeyboardUserId) { if (Input.GetKeyDown(KeyCode.Space) && PlayerEnabled[i]) { //PLAYER READY _PlayerReady[i] = true; PlayerReady[i].SetActive(true); } } else if (_Controller.IsConnected) { //PLAYER READY if (_Controller.GetButtonDown("A") && PlayerEnabled[i]) { _PlayerReady[i] = true; PlayerReady[i].SetActive(true); } //PLAYER CANCEL if (_Controller.GetButtonDown("B") && PlayerEnabled[i]) { _PlayerReady[i] = false; PlayerReady[i].SetActive(false); } } //WEB #else if (playNum == _KeyboardUserId) { if (Input.GetKeyDown(KeyCode.Space) && PlayerEnabled[i]) { //PLAYER READY _PlayerReady[i] = true; PlayerReady[i].SetActive(true); } } else { if (playNum > _KeyboardUserId) { playNum -= 1; } if (Input.GetButtonDown("Ready" + playNum.ToString()) && PlayerEnabled[i]) { //PLAYER READY _PlayerReady[i] = true; PlayerReady[i].SetActive(true); } if (Input.GetButtonDown("Cancel" + playNum.ToString()) && PlayerEnabled[i]) { //PLAYER CANCEL READY _PlayerReady[i] = false; PlayerReady[i].SetActive(false); } } #endif } } else { ContinueText.SetActive(false); } }