/* * A = 0, * B = 1, * X = 2, * Y = 3, * * DPad_UP = 4, * DPad_DOWN = 5, * DPad_LEFT = 6, * DPad_RIGHT = 7, * * Shldr_LEFT = 8, * Shldr_RIGHT = 9, * * ThumbStick_LEFT = 10, * ThumbStick_RIGHT = 11, * * Start = 12, * Back = 13 */ // Update is called once per frame void Update() { if (!isKeyboard) { if (manager.state.state == 0) { commands.jump = GamePadManager.GetControllerKeyPressed(manager.playerGamepad.gamepad, 0); commands.flip = GamePadManager.GetControllerKeyDown(manager.playerGamepad.gamepad, 8); commands.aim = GamePadManager.GetControllerAxes(manager.playerGamepad.gamepad).l_Trigger > 0.4f; commands.shoot = GamePadManager.GetControllerAxes(manager.playerGamepad.gamepad).r_Trigger > 0.4f; commands.sprint = GamePadManager.GetControllerKeyDown(manager.playerGamepad.gamepad, 10); commands.slam = GamePadManager.GetControllerKeyPressed(manager.playerGamepad.gamepad, 2); commands.dash = GamePadManager.GetControllerKeyPressed(manager.playerGamepad.gamepad, 11); commands.swap = GamePadManager.GetControllerKeyPressed(manager.playerGamepad.gamepad, 3); commands.crouch = GamePadManager.GetControllerKeyPressed(manager.playerGamepad.gamepad, 1); //commands.grenade = GamePadManager.GetControllerKeyPressed(manager.playerGamepad.gamepad, 9); } commands.pause = GamePadManager.GetControllerKeyPressed(manager.playerGamepad.gamepad, 12); commands.menuUp = GamePadManager.GetControllerKeyPressed(manager.playerGamepad.gamepad, 4); commands.menuDown = GamePadManager.GetControllerKeyPressed(manager.playerGamepad.gamepad, 5); commands.menuLeft = GamePadManager.GetControllerKeyPressed(manager.playerGamepad.gamepad, 6); commands.menuRight = GamePadManager.GetControllerKeyPressed(manager.playerGamepad.gamepad, 7); commands.back = GamePadManager.GetControllerKeyPressed(manager.playerGamepad.player, 1); commands.select = GamePadManager.GetControllerKeyPressed(manager.playerGamepad.player, 0); } else { if (manager.state.state == 0) { commands.jump = Input.GetKeyDown(KeyCode.Space); commands.flip = Input.GetKeyDown("q"); commands.aim = Input.GetMouseButton(1); commands.shoot = Input.GetMouseButton(0); commands.sprint = Input.GetKeyDown(KeyCode.LeftShift); commands.slam = Input.GetKeyDown(KeyCode.LeftControl); commands.dash = Input.GetKeyDown(KeyCode.E); } commands.pause = Input.GetKeyDown(KeyCode.Escape); commands.menuUp = Input.GetKeyDown(KeyCode.W); commands.menuDown = Input.GetKeyDown(KeyCode.S); commands.menuLeft = Input.GetKeyDown(KeyCode.A); commands.menuRight = Input.GetKeyDown(KeyCode.D); commands.back = Input.GetKeyDown(KeyCode.Escape); commands.select = Input.GetKeyDown(KeyCode.Return); } }
// Update is called once per frame void Update() { if (MenuStates.menuState == 0) { currentHeight = menuHeight; currentMax = menuButtons.Length; cursor.transform.position = menuButtons[slot].transform.position; cursor.GetComponent <CursorSizeing>().bottomDistance.x = menuButtons[slot].GetComponent <RectTransform>().sizeDelta.x * 0.5f; cursor.GetComponent <CursorSizeing>().bottomDistance.y = -menuButtons[slot].GetComponent <RectTransform>().sizeDelta.y * 0.5f; cursor.GetComponent <CursorSizeing>().topDistance.x = -menuButtons[slot].GetComponent <RectTransform>().sizeDelta.x * 0.5f; cursor.GetComponent <CursorSizeing>().topDistance.y = menuButtons[slot].GetComponent <RectTransform>().sizeDelta.y * 0.5f; } if (MenuStates.menuState == 1) { if (slot == 1) { temp = GameObject.Find("Map1").GetComponent <Image>().color; temp.a = 0.0f; GameObject.Find("Map1").GetComponent <Image>().color = temp; temp = GameObject.Find("Map2").GetComponent <Image>().color; temp.a = 1.0f; GameObject.Find("Map2").GetComponent <Image>().color = temp; temp = GameObject.Find("Map3").GetComponent <Image>().color; temp.a = 1.0f; GameObject.Find("Map3").GetComponent <Image>().color = temp; } else if (slot == 2) { temp = GameObject.Find("Map2").GetComponent <Image>().color; temp.a = 0.0f; GameObject.Find("Map2").GetComponent <Image>().color = temp; temp = GameObject.Find("Map1").GetComponent <Image>().color; temp.a = 1.0f; GameObject.Find("Map1").GetComponent <Image>().color = temp; temp = GameObject.Find("Map3").GetComponent <Image>().color; temp.a = 1.0f; GameObject.Find("Map3").GetComponent <Image>().color = temp; } else if (slot == 3) { temp = GameObject.Find("Map3").GetComponent <Image>().color; temp.a = 0.0f; GameObject.Find("Map3").GetComponent <Image>().color = temp; temp = GameObject.Find("Map2").GetComponent <Image>().color; temp.a = 1.0f; GameObject.Find("Map2").GetComponent <Image>().color = temp; temp = GameObject.Find("Map1").GetComponent <Image>().color; temp.a = 1.0f; GameObject.Find("Map1").GetComponent <Image>().color = temp; } else { temp = GameObject.Find("Map1").GetComponent <Image>().color; temp.a = 1.0f; GameObject.Find("Map1").GetComponent <Image>().color = temp; temp = GameObject.Find("Map2").GetComponent <Image>().color; temp.a = 1.0f; GameObject.Find("Map2").GetComponent <Image>().color = temp; temp = GameObject.Find("Map3").GetComponent <Image>().color; temp.a = 1.0f; GameObject.Find("Map3").GetComponent <Image>().color = temp; } currentHeight = localHeight; currentMax = localButtons.Length; cursor.transform.position = localButtons[slot].transform.position; cursor.GetComponent <CursorSizeing>().bottomDistance.x = localButtons[slot].GetComponent <RectTransform>().sizeDelta.x * 0.5f; cursor.GetComponent <CursorSizeing>().bottomDistance.y = -localButtons[slot].GetComponent <RectTransform>().sizeDelta.y * 0.5f; cursor.GetComponent <CursorSizeing>().topDistance.x = -localButtons[slot].GetComponent <RectTransform>().sizeDelta.x * 0.5f; cursor.GetComponent <CursorSizeing>().topDistance.y = localButtons[slot].GetComponent <RectTransform>().sizeDelta.y * 0.5f; } for (int i = 0; i <= 3; i++) { m_ctrlrTimer[i] -= Time.deltaTime; m_InputAxes[i] = GamePadManager.GetControllerAxes(i); if (GamePadManager.GetControllerKeyPressed(i, 5) || (m_InputAxes[i].l_ThumbStick_Y <= -0.3f && m_ctrlrTimer[i] <= 0f)) { Debug.Log("down"); m_ctrlrTimer[i] = 0.15f; if (slot < currentMax - 1 && (slot + 1) % currentHeight != 0) { slot++; } } else if (GamePadManager.GetControllerKeyPressed(i, 4) || (m_InputAxes[i].l_ThumbStick_Y >= 0.3f && m_ctrlrTimer[i] <= 0f)) { Debug.Log("up"); m_ctrlrTimer[i] = 0.15f; if (slot > 0 && (slot) % currentHeight != 0) { slot--; } } else if (GamePadManager.GetControllerKeyPressed(i, 6) || (m_InputAxes[i].l_ThumbStick_X <= -0.3f && m_ctrlrTimer[i] <= 0f)) { Debug.Log("left"); m_ctrlrTimer[i] = 0.15f; if (slot - (currentHeight - 1) > 0) { slot -= currentHeight; } } else if (GamePadManager.GetControllerKeyPressed(i, 7) || (m_InputAxes[i].l_ThumbStick_Y >= 0.3f && m_ctrlrTimer[i] <= 0f)) { Debug.Log("Right"); m_ctrlrTimer[i] = 0.15f; if (slot + currentHeight <= currentMax - 1) { slot += currentHeight; } } if (GamePadManager.GetControllerKeyPressed(i, 0)) { if (MenuStates.menuState == 0) { if (slot == 0) { MenuStates.menuState = 1; slot = 1; } else if (slot == 1) { MenuStates.menuState = 0; } else if (slot == 2) { //MenuStates.menuState = 2; } else if (slot == 3) { print("Close"); Application.Quit(); } } else if (MenuStates.menuState == 1) { if (slot == 0) { MenuStates.menuState = 0; } if (GamePadManager.playersActive > 0) { if (slot == 1) { localButtons[1].GetComponent <LoadLevel>().LoadMap1(); } else if (slot == 2) { localButtons[2].GetComponent <LoadLevel>().LoadMap2(); } else if (slot == 3) { localButtons[3].GetComponent <LoadLevel>().LoadMap4(); } } else { Instantiate <GameObject>(invalidSound); } if (slot == 4) { gameObject.GetComponent <MenuStates>().setGunGame(); } } } } }