public void Start() { selectedButton = null; selectedButtonMenuPos = inGameMenuRefrence.menuButtons.Length - 1; menuPress = false; //Get our limits form the camera set up limits = cam.limits; //start off with controler disabled disableTimer = timeToDisableWaitTime; //set player ID to player 1 playerID = 0; //creat then disable our cursor highlight cursorHighLight = Instantiate(cursorPrefab, new Vector3(0, 0, 0), Quaternion.identity); cursorHighLight.SetActive(false); }
public void Update() { //increase timers disableTimer += Time.deltaTime; waitTimer += Time.deltaTime; if (menuPress == true && Input.GetAxis("AButton") == 0) { selectedButton.onClick.Invoke(); UImanager.currUIState = UIManager.eUIState.BASE; UImanager.stateSwitch(); selectedButton.cursorClicked = false; selectedButton.cursorSelected = false; selectedButtonMenuPos = inGameMenuRefrence.menuButtons.Length - 1; selectedButton = null; inGameMenuRefrence.cursorActive = false; menuPress = false; } //check if we have swpaed player turns and set cursor to new players king position if (playerID != gameManagment.activePlayer.playerID) { gameManagment.activePlayer.CalculateKingPosition(); hoverOverTile = map.GetTileAtPos(gameManagment.activePlayer.kingPosition); cursorPos = hoverOverTile.pos; cursorHighLight.transform.position = hoverOverTile.pos; playerID = gameManagment.activePlayer.playerID; } //check if controller input has not been used and if so set it to ddefault position //disable it and go into a visual stand by if (disableTimer > timeToDisableWaitTime) { gameManagment.activePlayer.CalculateKingPosition(); hoverOverTile = map.GetTileAtPos(gameManagment.activePlayer.kingPosition); cursorPos = hoverOverTile.pos; cursorHighLight.transform.position = hoverOverTile.pos; cursorHighLight.SetActive(false); for (int i = 0; i < actionButtons.Length; i++) { actionButtons[i].SetActive(false); } } else { //make sure the cursor highlight is active if in use cursorHighLight.SetActive(true); for (int i = 0; i < actionButtons.Length; i++) { actionButtons[i].SetActive(true); } } //deteck if player has put in any controller inputs DetectButtonPress(); }
/* * InGameButtonChecks * public void function * * this goes and checks to see if we have pressed any buttons on our controller * if those button presses are currently valid to use and activates there functions * as is appropriate while we are playing the game * * @returns nothing */ public void InGameButtonChecks() { //left click function call if (Input.GetAxis("LeftTrigger") == 1 && waitTimer > 0.5f) { gameManagment.OnTileSelectedLeftClick(hoverOverTile); } //right click function call if (Input.GetAxis("RightTrigger") == 1 && waitTimer > 0.5f) { Vector3 vector3 = Camera.main.WorldToScreenPoint(hoverOverTile.pos); gameManagment.OnTileSelectedRightClick(hoverOverTile, vector3); } //if player is holding down both trigger for more then the endTurnWaitTimer end current players turn if (Input.GetAxis("LeftTrigger") == 1 && Input.GetAxis("RightTrigger") == 1) { endTurnTimer += Time.deltaTime; if (endTurnTimer >= endTurnWaitTimer) { gameManagment.OnNextTurn(); waitTimer = 0; } } else { endTurnTimer = 0; } //if any unit action UI is not at 10000 then it is valid to use if (UImanager.Buttons[0].GetComponent <RectTransform>().anchoredPosition.x != 10000) { //if we press the A button sends a move comand if (Input.GetAxis("AButton") == 1) { Debug.Log("AButton Pressed"); gameManagment.OnActionSelected(1); disableTimer = 0; return; } } if (UImanager.Buttons[1].GetComponent <RectTransform>().anchoredPosition.x != 10000) { //if we press the X button sends a Attack comand if (Input.GetAxis("XButton") == 1) { Debug.Log("XButton Pressed"); gameManagment.OnActionSelected(0); disableTimer = 0; return; } } if (UImanager.Buttons[2].GetComponent <RectTransform>().anchoredPosition.x != 10000) { //if we press the Y button sends a tile modife comand if (Input.GetAxis("YButton") == 1) { Debug.Log("YButton Pressed"); gameManagment.OnActionSelected(2); disableTimer = 0; return; } } if (UImanager.Buttons[3].GetComponent <RectTransform>().anchoredPosition.x != 10000) { //if we press the B button sends a Cancel action comand if (Input.GetAxis("BButton") == 1) { Debug.Log("BButton Pressed"); gameManagment.OnActionSelected(-1); disableTimer = 0; return; } } //pressing the otions button on the controler opens up the menu if (Input.GetAxis("MenuButton") == 1 && waitTimer > 0.5f) { UImanager.currUIState = UIManager.eUIState.PAUSEMENU; UImanager.stateSwitch(); disableTimer = 0; waitTimer = 0; selectedButton = inGameMenuRefrence.menuButtons[selectedButtonMenuPos]; selectedButton.cursorSelected = true; inGameMenuRefrence.cursorActive = true; } //left bumper toggles through the units in a "backwards" manner if (Input.GetAxis("LeftBumper") == 1 && waitTimer > 0.5f) { gameManagment.scroll = -1; gameManagment.ToggleBetweenActiveUnits(); disableTimer = 0; waitTimer = 0; hoverOverTile = map.GetTileAtPos(gameManagment.selectedUnit.transform.position); cursorPos = gameManagment.selectedUnit.transform.position; cursorHighLight.transform.position = hoverOverTile.pos; return; } //left bumper toggles through the units in a "forwards" manner if (Input.GetAxis("RightBumper") == 1 && waitTimer > 0.5f) { gameManagment.scroll = 1; gameManagment.ToggleBetweenActiveUnits(); disableTimer = 0; waitTimer = 0; hoverOverTile = map.GetTileAtPos(gameManagment.selectedUnit.transform.position); cursorPos = gameManagment.selectedUnit.transform.position; cursorHighLight.transform.position = hoverOverTile.pos; return; } }
public void InGameMenuButtonCheck() { //pressing the otions button on the controler opens up the menu if (Input.GetAxis("MenuButton") == 1 && waitTimer >= 0.5f) { UImanager.currUIState = UIManager.eUIState.BASE; UImanager.stateSwitch(); disableTimer = 0; waitTimer = 0; selectedButtonMenuPos = inGameMenuRefrence.menuButtons.Length - 1; selectedButton = null; inGameMenuRefrence.cursorActive = false; } //scrolls "UP" the menu if (Input.GetAxis("LeftJoyStickVertical") < -0.1f && waitTimer >= 0.25f) { selectedButtonMenuPos -= 1; disableTimer = 0; waitTimer = 0; if (selectedButtonMenuPos < 0) { selectedButtonMenuPos = inGameMenuRefrence.menuButtons.Length - 1; } if (selectedButtonMenuPos > 0 || selectedButtonMenuPos < inGameMenuRefrence.menuButtons.Length) { selectedButton.cursorSelected = false; selectedButton.cursorClicked = false; selectedButton = inGameMenuRefrence.menuButtons[selectedButtonMenuPos]; selectedButton.cursorSelected = true; } else { selectedButtonMenuPos = inGameMenuRefrence.menuButtons.Length - 1; } } //scrolls "down" the menu if (Input.GetAxis("LeftJoyStickVertical") > 0.1f && waitTimer >= 0.25f) { selectedButtonMenuPos += 1; disableTimer = 0; waitTimer = 0; if (selectedButtonMenuPos > inGameMenuRefrence.menuButtons.Length - 1) { selectedButtonMenuPos = 0; } if (selectedButtonMenuPos > 0 || selectedButtonMenuPos < inGameMenuRefrence.menuButtons.Length) { selectedButton.cursorSelected = false; selectedButton.cursorClicked = false; selectedButton = inGameMenuRefrence.menuButtons[selectedButtonMenuPos]; selectedButton.cursorSelected = true; } else { selectedButtonMenuPos = 0; } } if (Input.GetAxis("AButton") == 1) { selectedButton.cursorClicked = true; menuPress = true; } }