void Start() { controller = GetComponent <Controller2D> (); anim = GetComponent <Animator> (); if (!didQueryNumOfCtrlrs) { didQueryNumOfCtrlrs = true; int queriedNumberOfCtrlrs = XCI.GetNumPluggedCtrlrs(); if (queriedNumberOfCtrlrs == 1) { Debug.Log("Only " + queriedNumberOfCtrlrs + " Xbox controller plugged in."); } else if (queriedNumberOfCtrlrs == 0) { Debug.Log("No Xbox controllers plugged in!"); } else { Debug.Log(queriedNumberOfCtrlrs + " Xbox controllers plugged in."); } XCI.DEBUG_LogControllerNames(); } gravity = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2); maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex; minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight); }
public void onClick() { p1Control = playerOneDropdown.value; p2Control = playerTwoDropdown.value; numberOfPlayers = playerSelector.value; bool status = true; // True means Ok. string err_msg = ""; errorText.text = err_msg; int numberOfControllersNeeded = p1Control + p2Control; // This is total number of controllers. int totalNumberPluggedIn = XCI.GetNumPluggedCtrlrs(); if (numberOfControllersNeeded > totalNumberPluggedIn) { status = false; err_msg += "Check Controllers."; } if (status) { PlayerPrefs.SetInt("P1_Controller_Scheme", p1Control); PlayerPrefs.SetInt("P2_Controller_Scheme", p2Control); PlayerPrefs.SetInt("NumberOfPlayers", numberOfPlayers); LevelManager levelManger = GameObject.Find("LevelManager").GetComponent <LevelManager> (); levelManger.LoadLevel("StartMenu"); } else { errorText.text = err_msg; } }
private void Start() { camTransform = transform; cam = Camera.main; if (!didQueryNumOfCtrlrs) { didQueryNumOfCtrlrs = true; int queriedNumberOfCtrlrs = XCI.GetNumPluggedCtrlrs(); if (queriedNumberOfCtrlrs == 1) { Debug.Log("Only " + queriedNumberOfCtrlrs + " Xbox controller plugged in."); } else if (queriedNumberOfCtrlrs == 0) { Debug.Log("No Xbox controllers plugged in!"); } else { Debug.Log(queriedNumberOfCtrlrs + " Xbox controllers plugged in."); } XCI.DEBUG_LogControllerNames(); } }
private void SetControllerRadioButtons() { var controllerCount = XCI.GetNumPluggedCtrlrs(); string[] controllerNames = new string[] { "1st", "2nd", "3rd", "4th" }; controllerChoice = new RadioButtonSet(0, controllerNames.Take(controllerCount).ToArray()); }
// Use this for initialization void Start() { wardAnim = GameObject.Find("Ward Logo").GetComponent <Animator>(); peakAnim = GameObject.Find("Peak Logo").GetComponent <Animator>(); Time.timeScale = 1f; ctrlNum = XCI.GetNumPluggedCtrlrs(); // Transparency.SetTransparent(leftStickGroup); // Transparency.SetTransparent(rightStickGroup); // Transparency.SetTransparent(pauseGroup); // Transparency.SetTransparent(startGroup); // Transparency.SetTransparent(escGroup); // Transparency.SetTransparent(spaceGroup); // Transparency.SetTransparent(asGroup); // Transparency.SetTransparent(klGroup); Transparency.SetTransparent(pauseButtonGroup); Transparency.SetTransparent(pauseKeyboardGroup); StartCoroutine("StartScreen"); Cursor.visible = false; // Screen.SetResolution(1920, 1080, true); // StartCoroutine("SwitchButtons"); }
public void QueryControllers() { int queriedNumberOfCtrlrs = XCI.GetNumPluggedCtrlrs(); if (queriedNumberOfCtrlrs == 1) { Debug.Log("Only " + queriedNumberOfCtrlrs + " Xbox controller plugged in."); } else if (queriedNumberOfCtrlrs == 0) { Debug.Log("No Xbox controllers plugged in!"); } else { Debug.Log(queriedNumberOfCtrlrs + " Xbox controllers plugged in."); } XCI.DEBUG_LogControllerNames(); // This code only works on Windows if (Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsEditor) { Debug.Log("Windows Only:: Any Controller Plugged in: " + XCI.IsPluggedIn(XboxController.Any).ToString()); Debug.Log("Windows Only:: Controller 1 Plugged in: " + XCI.IsPluggedIn(XboxController.First).ToString()); Debug.Log("Windows Only:: Controller 2 Plugged in: " + XCI.IsPluggedIn(XboxController.Second).ToString()); Debug.Log("Windows Only:: Controller 3 Plugged in: " + XCI.IsPluggedIn(XboxController.Third).ToString()); Debug.Log("Windows Only:: Controller 4 Plugged in: " + XCI.IsPluggedIn(XboxController.Fourth).ToString()); } }
private static float GetHorzScrollAxis(int player) { if (XCI.GetNumPluggedCtrlrs() > player) { bool left = XCI.GetButton(XboxButton.LeftBumper, player + 1); bool right = XCI.GetButton(XboxButton.RightBumper, player + 1); if (left && !right) { return(-1); } else if (!left && right) { return(1); } else { return(XCI.GetAxis(XboxAxis.LeftStickX, player + 1)); } } else if (player == 0) { bool left = Input.GetKey("a"); bool right = Input.GetKey("d"); if (left && !right) { return(-1); } else if (!left && right) { return(1); } else { return(0); } } else if (player == 1) { bool left = Input.GetKey("left"); bool right = Input.GetKey("right"); if (left && !right) { return(-1); } else if (!left && right) { return(1); } else { return(0); } } else { return(0); } }
void Start() { camera = mainCamera.GetComponent <Camera>(); if (XCI.GetNumPluggedCtrlrs() > 0) { Cursor.visible = false; } }
public override bool Calculate() { float epsilon = 0.000001f; if (binding) { var controllerCount = XCI.GetNumPluggedCtrlrs(); XboxController[] controllers = { XboxController.First, XboxController.Second, XboxController.Third, XboxController.Fourth }; for (int i = 0; i < controllerCount; i++) { var controller = controllers[i]; var leftStickX = XCI.GetAxis(XboxAxis.LeftStickX, controller); var leftStickY = XCI.GetAxis(XboxAxis.LeftStickY, controller); Vector2 leftStick = new Vector2(leftStickX, leftStickY); if (leftStick.magnitude > epsilon) { boundController = controller; boundStick = XboxStickId.left; binding = false; bound = true; } var rightStickX = XCI.GetAxis(XboxAxis.RightStickX, controller); var rightStickY = XCI.GetAxis(XboxAxis.RightStickY, controller); Vector2 rightStick = new Vector2(rightStickX, rightStickY); if (rightStick.magnitude > epsilon) { boundController = controller; boundStick = XboxStickId.right; binding = false; bound = true; } } } else if (bound) { float stickX = 0, stickY = 0; switch (boundStick) { case XboxStickId.left: stickX = XCI.GetAxis(XboxAxis.LeftStickX, boundController); stickY = XCI.GetAxis(XboxAxis.LeftStickY, boundController); break; case XboxStickId.right: stickX = XCI.GetAxis(XboxAxis.RightStickX, boundController); stickY = XCI.GetAxis(XboxAxis.RightStickY, boundController); break; } axis2D = new Vector2(stickX, stickY); axis2DKnob.SetValue(axis2D); axisXKnob.SetValue(axis2D.x); axisYKnob.SetValue(axis2D.y); } return(true); }
public void BonusLevel() { int random = 0; int range = 5; bool bonusSceneCanOccur = false; switch (XCI.GetNumPluggedCtrlrs()) { case 1: break; case 2: if (GameStats.Player1Score > 9 && GameStats.Player2Score > 9) { bonusSceneCanOccur = true; } break; case 3: if (GameStats.Player1Score > 9 && GameStats.Player2Score > 9 && GameStats.Player3Score > 9) { bonusSceneCanOccur = true; } break; case 4: if (GameStats.Player1Score > 9 && GameStats.Player2Score > 9 && GameStats.Player3Score > 9 && GameStats.Player4Score > 9) { bonusSceneCanOccur = true; } break; default: break; } if (bonusSceneCanOccur) { range = (GameStats.LevelsWithoutBonusScene * 10) + 10; range -= GameStats.BonusScenesPlayed * 20; random = Random.Range(0, 100); if (random <= range) { sceneFader.FadeTo(2); } else { GameStats.LevelsWithoutBonusScene++; } } }
public void UpdateCtrl() { if (XCI.GetNumPluggedCtrlrs() < 2) { this.UpdateCtrl_KeyBoard(); } else { this.UpdateCtrl_XCI(); } }
// Update is called once per frame void Update() { if (!selectingCharacters) { for (int i = 1; i <= XCI.GetNumPluggedCtrlrs(); i++) { if (XCI.GetAxis(XboxAxis.LeftStickX, i) > 0.1 && !isMainMenuOn) { RaiseVolume(); } //if (XCI.GetAxis(XboxAxis.LeftStickX) < 0 && XCI.GetAxis(XboxAxis.LeftStickX) > -1) if (XCI.GetAxis(XboxAxis.LeftStickX, i) < -0.1 && !isMainMenuOn) { LowerVolume(); } if (XCI.GetButtonDown(XboxButton.A, i)) { Debug.Log("A pressed"); audioSource.PlayOneShot(aSound); Application.LoadLevelAdditive(nextScene); mainMenu.SetActive(false); selectingCharacters = true; } if (XCI.GetButtonDown(XboxButton.B, i)) { Debug.Log("B pressed"); audioSource.PlayOneShot(bSound); if (isMainMenuOn == true) { turnSettingsMenuOn(); } else if (isMainMenuOn == false) { turnMainMenuOn(); } } if (XCI.GetButtonDown(XboxButton.X, i)) { Debug.Log("X pressed"); audioSource.PlayOneShot(bSound); Application.LoadLevel(creditsScene); } if (XCI.GetButtonDown(XboxButton.Y, i)) { Debug.Log("Y pressed"); Application.Quit(); } } //if (XCI.GetAxis(XboxAxis.LeftStickX) < 1 && XCI.GetAxis(XboxAxis.LeftStickX) > 0) } }
public override bool Calculate() { if (controllerChoice.Selected != lastSelected) { ChooseController(); } if (XCI.GetNumPluggedCtrlrs() > 0 && XCI.IsPluggedIn(boundController)) { var lX = XCI.GetAxis(XboxAxis.LeftStickX, boundController); var lY = XCI.GetAxis(XboxAxis.LeftStickY, boundController); var rX = XCI.GetAxis(XboxAxis.RightStickX, boundController); var rY = XCI.GetAxis(XboxAxis.RightStickY, boundController); leftStick = new Vector2(lX, lY); rightStick = new Vector2(rX, rY); leftTrigger = XCI.GetAxis(XboxAxis.LeftTrigger, boundController); rightTrigger = XCI.GetAxis(XboxAxis.RightTrigger, boundController); dpadUp = XCI.GetButton(XboxButton.DPadUp, boundController); dpadDown = XCI.GetButton(XboxButton.DPadDown, boundController); dpadLeft = XCI.GetButton(XboxButton.DPadLeft, boundController); dpadRight = XCI.GetButton(XboxButton.DPadRight, boundController); a = XCI.GetButton(XboxButton.A, boundController); b = XCI.GetButton(XboxButton.B, boundController); x = XCI.GetButton(XboxButton.X, boundController); y = XCI.GetButton(XboxButton.Y, boundController); leftBumper = XCI.GetButton(XboxButton.LeftBumper, boundController); rightBumper = XCI.GetButton(XboxButton.LeftBumper, boundController); start = XCI.GetButton(XboxButton.Start, boundController); back = XCI.GetButton(XboxButton.Back, boundController); LeftStickKnob.SetValue(leftStick); RightStickKnob.SetValue(rightStick); LeftTriggerKnob.SetValue(leftTrigger); RightTriggerKnob.SetValue(rightTrigger); dpadUpKnob.SetValue(dpadUp); dpadDownKnob.SetValue(dpadDown); dpadLeftKnob.SetValue(dpadLeft); dpadRightKnob.SetValue(dpadRight); aKnob.SetValue(a); bKnob.SetValue(b); xKnob.SetValue(x); yKnob.SetValue(y); leftBumperKnob.SetValue(leftBumper); rightBumperKnob.SetValue(rightBumper); startKnob.SetValue(start); backKnob.SetValue(back); } return(true); }
// Use this for initialization void Start() { if (XCI.GetNumPluggedCtrlrs() > 0 && isKeyboardUI) { gameObject.SetActive(false); } else if (XCI.GetNumPluggedCtrlrs() == 0 && isGamepadUI) { gameObject.SetActive(false); } }
// Start is called before the first frame update void Start() { // Search for controllers: if (!hasSearchedForControllers && !toggleDebugMode.startInDebugMode) { hasSearchedForControllers = true; connectedControllers = XCI.GetNumPluggedCtrlrs(); if (connectedControllers == 1) { Debug.Log("Only " + connectedControllers + " Xbox controller plugged in."); controllerFound = true; } else if (connectedControllers == 0) { Debug.Log("No Xbox controllers plugged in!"); } else { Debug.Log(connectedControllers + " Xbox controllers plugged in."); controllerFound = true; } XCI.DEBUG_LogControllerNames(); } // Adding the player containers to a list. for (int i = 0; i < playerContainersGroup.transform.childCount; ++i) { playerContainers.Add(playerContainersGroup.transform.GetChild(i).transform.gameObject.GetComponent <PlayerContainer>()); } // Adding to the yet to bed added list for (int c = 1; c < connectedControllers + 1; ++c) { XboxController xboxController = ((XboxController)c); if (xboxController == XboxController.All) { continue; } connectedControllerList.Add(xboxController); } // Getting the fade panel. panel = fadePanel.GetComponent <FadePanel>(); // Setting up the timer. gameStartTimer = maxGameStartTimer; gameStartText.text = startingGameInText + gameStartTimer.ToString("0.00"); }
// Start void Start() { switch (controller) { case XboxCtrlrInput.XboxController.First: GetComponent <Renderer>().material = matRed; break; case XboxCtrlrInput.XboxController.Second: GetComponent <Renderer>().material = matGreen; break; case XboxCtrlrInput.XboxController.Third: GetComponent <Renderer>().material = matBlue; break; case XboxCtrlrInput.XboxController.Fourth: GetComponent <Renderer>().material = matYellow; break; } newPosition = transform.position; // Call for the number of connected controllers once if (!didQueryNumOfCtrlrs) { didQueryNumOfCtrlrs = true; int queriedNumberOfCtrlrs = XCI.GetNumPluggedCtrlrs(); if (queriedNumberOfCtrlrs == 1) { Debug.Log("Only " + queriedNumberOfCtrlrs + " Xbox controller plugged in."); } else if (queriedNumberOfCtrlrs == 0) { Debug.Log("No Xbox controllers plugged in!"); } else { Debug.Log(queriedNumberOfCtrlrs + " Xbox controllers plugged in."); } XCI.DEBUG_LogControllerNames(); // This code only works on Windows if (Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsEditor) { Debug.Log("Windows Only:: Any Controller Plugged in: " + XCI.IsPluggedIn(XboxCtrlrInput.XboxController.Any).ToString()); Debug.Log("Windows Only:: Controller 1 Plugged in: " + XCI.IsPluggedIn(XboxCtrlrInput.XboxController.First).ToString()); Debug.Log("Windows Only:: Controller 2 Plugged in: " + XCI.IsPluggedIn(XboxCtrlrInput.XboxController.Second).ToString()); Debug.Log("Windows Only:: Controller 3 Plugged in: " + XCI.IsPluggedIn(XboxCtrlrInput.XboxController.Third).ToString()); Debug.Log("Windows Only:: Controller 4 Plugged in: " + XCI.IsPluggedIn(XboxCtrlrInput.XboxController.Fourth).ToString()); } } }
void Start() { playerController = GetComponent <PlayerController> (); if (playerNum > GameRoundManager.instance.numPlayers) { Destroy(gameObject); } else if (playerNum > XCI.GetNumPluggedCtrlrs()) { GetComponent <AIPlayer> ().enabled = true; GetComponent <Player> ().enabled = false; } //Debug.Log(XCI.GetNumPluggedCtrlrs() + " Xbox controllers plugged in."); }
public static bool GetAnyCancelButtonDown() { if (XCI.GetNumPluggedCtrlrs() > 0) { for (int i = 0; i < XCI.GetNumPluggedCtrlrs(); ++i) { if (XCI.GetButtonDown(XboxButton.Back, i + 1)) { return(true); } } } return(Input.GetKeyDown("escape")); }
public static bool GetAnyStartButtonDown() { if (XCI.GetNumPluggedCtrlrs() > 0) { for (int i = 0; i < XCI.GetNumPluggedCtrlrs(); ++i) { if (XCI.GetButtonDown(XboxButton.Start, i + 1)) { return(true); } } } return(Input.GetKeyDown("space") || Input.GetKeyDown("enter")); }
/* ========= Public Helper Methods ========= */ public int GetNumPlayers() { int numCtrls = XCI.GetNumPluggedCtrlrs(); if (numCtrls == 0) { // due to keyboard input return(1); } if (numCtrls > MAX_NUM_PLAYERS) { return(MAX_NUM_PLAYERS); } return(numCtrls); }
// Use this for initialization void Awake() { if (XCI.GetNumPluggedCtrlrs() >= 1) { TriggerTxt.text = "Press A to continue"; } else { TriggerTxt.text = "Press SPACE to continue"; } for (int i = 0; i < 4; i++) { PlayerPrefs.SetInt("RoundWinner " + (i + 1).ToString(), 0); } }
// Update is called once per frame void Update() { if (ReadyPlayers != XCI.GetNumPluggedCtrlrs() || XCI.GetNumPluggedCtrlrs() == 0) { timer = 5.0f; CountDownText.gameObject.SetActive(false); } else { CountDownText.gameObject.SetActive(true); timer -= Time.deltaTime * 1.0f; } Player[3].SetActive(XCI.GetNumPluggedCtrlrs() > 3); PlayerNameText[3].text = (XCI.GetNumPluggedCtrlrs() > 3 ? (!PBehaviour[3].PlayerReady ? "Player Four" : "Ready") : "Connect Controller"); ColourPicker[3].SetActive(XCI.GetNumPluggedCtrlrs() > 3 && !PBehaviour[3].PlayerReady); Player[2].SetActive(XCI.GetNumPluggedCtrlrs() > 2); PlayerNameText[2].text = (XCI.GetNumPluggedCtrlrs() > 2 ? (!PBehaviour[2].PlayerReady ? "Player Three" : "Ready") : "Connect Controller"); ColourPicker[2].SetActive(XCI.GetNumPluggedCtrlrs() > 2 && !PBehaviour[2].PlayerReady); Player[1].SetActive(XCI.GetNumPluggedCtrlrs() > 1); PlayerNameText[1].text = (XCI.GetNumPluggedCtrlrs() > 1 ? (!PBehaviour[1].PlayerReady ? "Player Two" : "Ready") : "Connect Controller"); ColourPicker[1].SetActive(XCI.GetNumPluggedCtrlrs() > 1 && !PBehaviour[1].PlayerReady); Player[0].SetActive(XCI.GetNumPluggedCtrlrs() > 0); PlayerNameText[0].text = (XCI.GetNumPluggedCtrlrs() > 0 ? (!PBehaviour[0].PlayerReady ? "Player One" : "Ready") : "Connect Controller"); ColourPicker[0].SetActive(XCI.GetNumPluggedCtrlrs() > 0 && !PBehaviour[0].PlayerReady); ReadyPlayers = 0; for (int i = 0; i < 4; i++) { ReadyPlayers += (PBehaviour[i].PlayerReady ? 1 : 0); } if (ReadyPlayers == XCI.GetNumPluggedCtrlrs() && XCI.GetNumPluggedCtrlrs() > 0) { CountDownTimer = System.Convert.ToInt32(timer); CountDownText.text = System.Convert.ToString(CountDownTimer); if (CountDownTimer < 0) { SceneManager.LoadScene(2); } } }
public static bool GetButtonDown(XboxButton button, XboxController controller) { #if UNITY_EDITOR int controllerNum = Ctrl2Num(controller); if (XCI.GetNumPluggedCtrlrs() >= controllerNum) { return(XCI.GetButtonDown(button, controller)); } else { return(Input.GetButtonDown("P" + controllerNum + button)); } #else return(XCI.GetButtonDown(button, controller)); #endif }
public static float GetAxis(XboxAxis axis, XboxController controller) { #if UNITY_EDITOR int controllerNum = Ctrl2Num(controller); if (XCI.GetNumPluggedCtrlrs() >= controllerNum) { return(XCI.GetAxis(axis, controller)); } else { return(Input.GetAxis("P" + controllerNum + axis)); } #else return(XCI.GetAxis(axis, controller)); #endif }
#pragma warning restore IDE0044 // Add readonly modifier // Start is called before the first frame update void Start() { playerHeight = GetComponent <CapsuleCollider>().bounds.size.y; tongueHitPoints = new List <Vector3> { Vector3.zero }; // Only draws tongue if there is a line renderer on the game object line = GetComponent <LineRenderer>(); line.positionCount = 0;; rb = gameObject.GetComponent <Rigidbody>(); if (!didQueryNumOfCtrlrs) { didQueryNumOfCtrlrs = true; int queriedNumberOfCtrlrs = XCI.GetNumPluggedCtrlrs(); if (queriedNumberOfCtrlrs == 1) { Debug.Log("Only " + queriedNumberOfCtrlrs + " Xbox controller plugged in."); } else if (queriedNumberOfCtrlrs == 0) { Debug.Log("No Xbox controllers plugged in!"); } else { Debug.Log(queriedNumberOfCtrlrs + " Xbox controllers plugged in."); } XCI.DEBUG_LogControllerNames(); } // getting component for animation and sound anim = GetComponent <Animator>(); audiosource = GetComponent <AudioSource>(); TongueCoolDownSoundPlayed = true; // Set variables on spawn point SpawnPos = transform.position; SpawnRot = transform.rotation; playernumber = (XInputDotNetPure.PlayerIndex)controller - 1; }
private static float GetVertScrollAxis(int player) { if (XCI.GetNumPluggedCtrlrs() > player) { return(-XCI.GetAxis(XboxAxis.LeftStickY, player + 1)); } else if (player == 0) { bool up = Input.GetKey("w"); bool down = Input.GetKey("s"); if (up && !down) { return(-1); } else if (!up && down) { return(1); } else { return(0); } } else if (player == 1) { bool up = Input.GetKey("up"); bool down = Input.GetKey("down"); if (up && !down) { return(-1); } else if (!up && down) { return(1); } else { return(0); } } else { return(0); } }
void Start() { timeToShoot = 0; rb = GetComponent <Rigidbody>(); timeToBomb = 0; if (!didQueryNumOfCtrlrs) { didQueryNumOfCtrlrs = true; int queriedNumberOfCtrlrs = XCI.GetNumPluggedCtrlrs(); if (queriedNumberOfCtrlrs == 1) { Debug.Log("Só um controle Xbox conectado."); } else if (queriedNumberOfCtrlrs == 0) { Debug.Log("Não há controles Xbox conectados"); } else { Debug.Log(queriedNumberOfCtrlrs + " controles Xbox conectados."); } XCI.DEBUG_LogControllerNames(); // This code only works on Windows if (Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsEditor) { Debug.Log("Apenas em Windows:: Algum controle conectado: " + XCI.IsPluggedIn(XboxController.Any).ToString()); Debug.Log("Apenas em Windows:: Controle 1 conectado: " + XCI.IsPluggedIn(XboxController.First).ToString()); Debug.Log("Apenas em Windows:: Controle 2 conectado: " + XCI.IsPluggedIn(XboxController.Second).ToString()); Debug.Log("Apenas em Windows:: Controle 3 conectado: " + XCI.IsPluggedIn(XboxController.Third).ToString()); Debug.Log("Apenas em Windows:: Controle 4 conectado: " + XCI.IsPluggedIn(XboxController.Fourth).ToString()); } } sangle = Mathf.Sin(angle * Mathf.PI / 180); cangle = Mathf.Cos(angle * Mathf.PI / 180); anim = GetComponentInChildren <Animator>(); stat = GetComponent <PlayerStatus>(); }
// Use this for initialization void Start() { // print("canvas width: " + GameObject.Find("Canvas").GetComponent<RectTransform>().rect.width); // print(levelClearBox.GetComponent<RectTransform>().rect.center - GameObject.Find("Canvas").GetComponent<RectTransform>().rect.center); boxCollider = GetComponent <BoxCollider2D>(); float differenceCanvasAndLevelComplete = levelClearBox.transform.position.x - GameObject.Find("Canvas").transform.position.x; levelClearText = levelClearBox.transform.GetChild(0).gameObject; print("difference = " + differenceCanvasAndLevelComplete); levelCompleteScreenDist = (2f / 3f) * differenceCanvasAndLevelComplete; //************ COMMENTED OUT DUE TO CTRLR ERROR ctrlNum = XCI.GetNumPluggedCtrlrs(); //*************************** lvlControl = GameObject.Find("Game Controller").GetComponent <LevelControl>(); target = lvlControl.GetPlayer(); }
void InitializePlayers() { // Resets max ritual maxRitual = 0; // Gets the number of connected controllers int playersConnected = XCI.GetNumPluggedCtrlrs(); Debug.Log("Players Connected: " + playersConnected); // Loops through the connected controllers and adds the player to the game for (int i = 0; i < playersConnected; i++) { // Instantiates player object GameObject playerObj = Instantiate(playerPrefabs[i], new Vector3(1, 0, 5), Quaternion.identity); // Creates reference to the PlayerController component on the object PlayerController playerCont = playerObj.GetComponent <PlayerController>(); // Finds player number int playerNumber = i + 1; string hudTag = ("P" + playerNumber + "HUD"); Debug.Log(hudTag); // Finds the HUD for the corresponding player number GameObject hud = GameObject.FindGameObjectWithTag(hudTag); // Assigns player number and HUD to player playerCont.InitializePlayer(hud, (XboxController)playerNumber); // Adds player to list of players players.Add(playerObj); // Adds 50 to the maximum ritual requisite. maxRitual += 50; } if (playersConnected < 4) { for (int i = 4; i > playersConnected; i--) { Debug.Log("P" + i + "HUD" + " disabled"); GameObject.FindGameObjectWithTag(("P" + i + "HUD")).SetActive(false); } } }
public static bool GetTribeButtonUp(int tribe, int player) { if (XCI.GetNumPluggedCtrlrs() > player) { return(XCI.GetButtonUp(TribeButton(tribe), player + 1)); } else if (player == 0) { return(Input.GetKeyUp(TribePlayerOneKey(tribe))); } else if (player == 1) { return(Input.GetKeyUp(TribePlayerTwoKey(tribe))); } else { return(false); } }