void Update() { controllerInput.Update(); if (controllerInput.GetButtonDown(ControllerButton.Y)) { PreProcess(); } if (controllerInput.GetButtonDown(ControllerButton.X)) { StartStage(); } if (dangoTrigger) { StartDango(); dangoTrigger = false; } if (bottleTrigger) { StartBottle(); bottleTrigger = false; } if (sakuraTrigger) { StartSakura(); sakuraTrigger = false; } }
protected virtual void Update() { if (m_ControllerInput != null) { for (int i = 0, imax = m_Buttons.Length; i < imax; ++i) { if (m_Buttons[i].value != null) { if (m_ControllerInput.GetButtonDown(m_Buttons[i].key)) { m_Buttons[i].OnPointerEnter(m_EventData); } else if (m_ControllerInput.GetButtonUp(m_Buttons[i].key)) { m_Buttons[i].OnPointerExit(m_EventData); } // if (m_ControllerInput.GetButtonDown(((uint)m_Buttons[i].key >> 16))) { m_Buttons[i].OnPointerClick(m_EventData); } } } } }
private Vector3 GetMotionInput() { #if UNITY_EDITOR float hor = Input.GetAxis("Horizontal"); float ver = Input.GetAxis("Vertical"); //bool buttonA = Input.GetKeyDown(KeyCode.Joystick1Button0); bool jump = Input.GetKey(KeyCode.LeftControl); #else m_xboxController.Update(); float hor = m_xboxController.GetAxisLeftThumbstickX(); float ver = m_xboxController.GetAxisLeftThumbstickY(); bool buttonA = m_xboxController.GetButtonDown(ControllerButton.A); bool buttonB = m_xboxController.GetButtonDown(ControllerButton.B); bool jump = m_xboxController.GetButton(ControllerButton.A); #endif hor = Mathf.Abs(hor) > 0.25f ? hor : 0; ver = Mathf.Abs(ver) > 0.25f ? ver : 0; bool pressed = hor != 0 || ver != 0; if (!pressed) { m_horAxis = Vector3.zero; m_verAxis = Vector3.zero; return(Vector3.zero); } if (m_horAxis == Vector3.zero) { // Compute new motion axes m_verAxis = Vector3.Normalize(ProjectXZ(Camera.main.transform.forward)); m_horAxis = Vector3.Normalize(Quaternion.Euler(0, 90, 0) * m_verAxis); } return(hor * m_horAxis + ver * m_verAxis); }
// Update is called once per frame void Update() { // Needed ////////////////////////////////////////////////// controllerInput.Update(); /////////////////////////////////////////////////////////// if (isXboxController) { // RB: teleport to next camera if (controllerInput.GetButtonDown(ControllerButton.RightShoulder)) { NextCam(); } if (controllerInput.GetButtonDown(ControllerButton.LeftShoulder)) { PreviousCam(); } if (controllerInput.GetButtonDown(ControllerButton.X)) { isUsingSetCams = !isUsingSetCams; } } }
public virtual void ReadState(ControllerState outState) { // if (m_ControllerInput != null) { if (m_ControllerInput.connectionState != DeviceConnectionState.Connected) // If not connected. { m_ControllerInput = null; } } if (m_ControllerInput == null) { // Search available controller... for (int i = 0, imax = m_ControllerInputs.Length; i < imax; ++i) { if (m_ControllerInputs[i] != null || m_ControllerInputs[i].connectionState == DeviceConnectionState.Connected) { m_ControllerInput = m_ControllerInputs[i]; break; } } if (m_ControllerInput == null) { outState.connectionState = GvrConnectionState.Disconnected; return; } } // outState.connectionState = GvrConnectionState.Connected; //(GvrConnectionState)m_ControllerInput.connectionState; // Touchpad outState.touchPos = m_ControllerInput.GetTouchPos(); outState.isTouching = m_ControllerInput.GetButton(DaydreamButton.Touch); outState.touchDown = m_ControllerInput.GetButtonDown(DaydreamButton.Touch); outState.touchUp = m_ControllerInput.GetButtonUp(DaydreamButton.Touch); // Click Button outState.clickButtonState = m_ControllerInput.GetButton(DaydreamButton.Click); outState.clickButtonDown = m_ControllerInput.GetButtonDown(DaydreamButton.Click); outState.clickButtonUp = m_ControllerInput.GetButtonUp(DaydreamButton.Click); // App Button outState.appButtonState = m_ControllerInput.GetButton(DaydreamButton.App); outState.appButtonDown = m_ControllerInput.GetButtonDown(DaydreamButton.App); outState.appButtonUp = m_ControllerInput.GetButtonUp(DaydreamButton.App); // Home Button outState.recentering = m_ControllerInput.GetButton(DaydreamButton.Home); outState.recentered = m_ControllerInput.GetButtonUp(DaydreamButton.Home); // Fix recenter api. if (m_ControllerInput.GetButtonUp(DaydreamButton.Home)) { m_ControllerInput.Recenter(); } // Motions outState.orientation = m_ControllerInput.GetRotation(); outState.accel = m_ControllerInput.GetAccelerometer(); outState.gyro = m_ControllerInput.GetGyroscope(); }
void Update() { controllerInput.Update(); isSelected = checkIsSelected(); if (isSelected) { changeTransform(); } if (controllerInput.GetButtonDown(ControllerButton.B)) { gameObject.SetTransparent(!isTransparent); } }
void next_result() { GameObject mapview = GameObject.Find("map_view"); if (Input.GetKeyDown(KeyCode.JoystickButton4) || controllerInput.GetButtonDown(ControllerButton.RightShoulder)) { counter = counter + 1; if (counter >= result_name.Length) { counter = counter - 1; } img = (Texture2D)Resources.Load(result_name[counter]); filename_rr = result_name[counter]; Debug.Log(result_name[counter]); colArray = new Color[colNum * rowNum]; for (int i = 0; i < colNum; i++) { for (int j = 0; j < rowNum; j++) { colArray[j * colNum + i] = (img.GetPixel(i, rowNum - j)); } } Update_position(Current); mapview.GetComponent <load_map>().show_image(colNum, rowNum, result_name[counter]); } if (Input.GetKeyDown(KeyCode.JoystickButton5) || controllerInput.GetButtonDown(ControllerButton.LeftShoulder)) { counter = counter - 1; if (counter <= 0) { counter = 0; } img = (Texture2D)Resources.Load(result_name[counter]); filename_rr = result_name[counter]; Debug.Log(result_name[counter]); colArray = new Color[colNum * rowNum]; for (int i = 0; i < colNum; i++) { for (int j = 0; j < rowNum; j++) { colArray[j * colNum + i] = (img.GetPixel(i, rowNum - j)); } } Update_position(Current); mapview.GetComponent <load_map>().show_image(colNum, rowNum, result_name[counter]); } }
protected virtual void Update() { if (m_ControllerInput != null) { if (m_ControllerInput.GetButtonDown(ControllerButton.PrimaryTrigger)) { int i = 0, imax; #if UNITY_5 && !UNITY_5_0 && !UNITY_5_1 imax = Physics.OverlapSphereNonAlloc(m_Point.position, m_Radius, m_Colliders, layerMask); #else m_Colliders = Physics.OverlapSphere(m_Point.position, m_Radius, layerMask); imax = m_Colliders.Length; #endif if (imax > 0) { if (m_MaxObjects >= 0) { imax = Mathf.Min(imax, m_MaxObjects); } for (; i < imax; ++i) { AddPickObject(m_Colliders[i].transform); } } } else if (!m_ControllerInput.GetButton(ControllerButton.PrimaryTrigger)) { if (m_PickObjects.Count > 0) { ClearPickObjects(); } } } }
private void LateUpdate() { //Seleção manual de jogador mais proximo if (selectedPlayer.IsMyBall() == false && team.GetSelectionMode() == GameOptionMode.manual) { if (ControllerInput.GetButtonDown(team.GetInputType(), team.GetInputs().Input_Selection)) { PlayerController nearPlayer = null; if (selectedPlayer != null) { nearPlayer = selectedPlayer.GetTeamPlayerNear(); } else { nearPlayer = gameMananger.GetPlayerNearBall(team); } if (nearPlayer != null && nearPlayer != selectedPlayer) { SelectPlayer(nearPlayer); } } } SelectorUpdate(); }
void DebugDrawControllers() { for (uint controller = 1; controller < 2; ++controller) { GUILayout.Label("Controller " + (controller + 1)); foreach (ControllerInput.Range range in System.Enum.GetValues(typeof(ControllerInput.Range))) { Vector2 val = ControllerInput.GetRange(controller, range); GUILayout.Label(ControllerInput.GetRangeName(range) + ": " + val); } foreach (ControllerInput.Button button in System.Enum.GetValues(typeof(ControllerInput.Button))) { string state = ""; if (ControllerInput.GetButtonDown(controller, button)) { state += " Down"; } if (ControllerInput.GetButton(controller, button)) { state += " Pressed"; } if (ControllerInput.GetButtonUp(controller, button)) { state += " Up"; } Indent(1, () => (GUILayout.Label(ControllerInput.GetButtonName(button) + ":" + state))); } GUILayout.Space(10.0f); } }
public static bool GetButtonDown(this ControllerInput thiz, XimmerseButton buttonMask) { if (thiz == null) { return(false); } return(thiz.GetButtonDown((uint)buttonMask)); }
/// <summary> /// 获得指定按键是否在这一帧按下 /// </summary> /// <param name="controllerButton"></param> /// <returns></returns> public bool GetButtonDown(XBoxControllerButton controllerButton) { #if UNITY_METRO && !UNITY_EDITOR return(controllerInput.GetButtonDown((ControllerButton)controllerButton)); #else return(Input.GetButtonDown(TransformButtonId(controllerButton))); #endif }
public void Process() { // Save the previous Game Object GameObject gazeObjectPrevious = GetCurrentGameObject(); CastRayFromGaze(); UpdateCurrentObject(); UpdateReticle(gazeObjectPrevious); // Handle input //if(!Input.GetMouseButtonDown(0)&&Input.GetMouseButton(0)) { // HandleDrag(); //} else if(Time.unscaledTime-pointerData.clickTime<clickTime) { // // Delay new events until clickTime has passed. //} else if(!pointerData.eligibleForClick&& // (GvrViewer.Instance.Triggered||Input.GetMouseButtonDown(0)|| // GvrController.ClickButtonDown)) { // // New trigger action. // HandleTrigger(); //} else if(!GvrViewer.Instance.Triggered&&!Input.GetMouseButton(0)&& // !GvrController.ClickButton) { // // Check if there is a pending click to handle. // HandlePendingClick(); //} // Handle input if (!m_Controller.GetButtonDown(buttonClick) && m_Controller.GetButton(buttonClick)) { HandleDrag(); } else if (Time.unscaledTime - pointerData.clickTime < clickTime) { // Delay new events until clickTime has passed. } else if (!pointerData.eligibleForClick && (m_Controller.GetButtonDown(buttonClick))) { // New trigger action. HandleTrigger(); } else if (!m_Controller.GetButton(buttonClick)) { // Check if there is a pending click to handle. HandlePendingClick(); } }
void Update() { // Needed ////////////////////////////////////////////////// controllerInput.Update(); /////////////////////////////////////////////////////////// if (controllerInput.GetButtonDown(ControllerButton.DPadLeft)) { this.gameObject.GetComponent <ViconTracking>().adjustVec.x += .02f; } if (controllerInput.GetButtonDown(ControllerButton.DPadRight)) { this.gameObject.GetComponent <ViconTracking>().adjustVec.x -= .02f; } if (controllerInput.GetButtonDown(ControllerButton.DPadUp)) { this.gameObject.GetComponent <ViconTracking>().adjustVec.z += .02f; } if (controllerInput.GetButtonDown(ControllerButton.DPadDown)) { this.gameObject.GetComponent <ViconTracking>().adjustVec.z -= .02f; } if (controllerInput.GetButtonDown(ControllerButton.RightShoulder)) { this.gameObject.GetComponent <ViconTracking>().adjustVec.y += .02f; } if (controllerInput.GetButtonDown(ControllerButton.LeftShoulder)) { this.gameObject.GetComponent <ViconTracking>().adjustVec.y -= .02f; } }
public void Initialize(ButtonEvent buttonEvent) { switch (type) { case Type.Input_Button: Get = () => (Input.GetButton(stringArg)); GetDown = () => (Input.GetButtonDown(stringArg)); GetUp = () => (Input.GetButtonUp(stringArg)); break; case Type.Input_Key: Get = () => (Input.GetKey((KeyCode)intArg)); GetDown = () => (Input.GetKeyDown((KeyCode)intArg)); GetUp = () => (Input.GetKeyUp((KeyCode)intArg)); break; //case Type.CrossInput: // Get = ()=>(CrossInputManager.GetButton(stringArg)); // GetDown = ()=>(CrossInputManager.GetButtonDown(stringArg)); // GetUp = ()=>(CrossInputManager.GetButtonUp(stringArg)); //break; case Type.ControllerInput: ControllerInput input = ControllerInputManager.instance.GetControllerInput(stringArg); if (input == null) { goto default_label; } Get = () => (input.GetButton((ControllerButton)intArg)); GetDown = () => (input.GetButtonDown((ControllerButton)intArg)); GetUp = () => (input.GetButtonUp((ControllerButton)intArg)); break; default: default_label: Get = GetFalse; GetDown = GetFalse; GetUp = GetFalse; break; } }
private void Update() { if (!PlayspaceManager.Instance.IsScanningComplete()) { return; } // Get current joypad axis values #if UNITY_EDITOR float hor = Input.GetAxis("Horizontal"); float ver = Input.GetAxis("Vertical"); bool buttonA = Input.GetKeyDown(KeyCode.Joystick1Button0); bool buttonB = Input.GetKeyDown(KeyCode.Joystick1Button1); #else m_xboxController.Update(); float hor = m_xboxController.GetAxisLeftThumbstickX(); float ver = m_xboxController.GetAxisLeftThumbstickY(); bool buttonA = m_xboxController.GetButtonDown(ControllerButton.A); bool buttonB = m_xboxController.GetButtonDown(ControllerButton.B); #endif float delta = (Mathf.Abs(ver) > 0.25f ? ver : 0) * Time.deltaTime; if (m_state == State.Select) { m_selection.Raycast(Camera.main.transform.position, Camera.main.transform.forward); Vector3[] vertices; int[] triangles; Vector2[] uv; m_selection.GenerateMeshData(out vertices, out triangles, out uv); if (vertices.Length > 0) { m_mesh.Clear(); m_mesh.vertices = vertices; m_mesh.uv = uv; m_mesh.triangles = triangles; m_mesh.RecalculateBounds(); //TODO: make a GetTransform function m_gameObject.transform.rotation = m_selection.rotation; m_gameObject.transform.position = m_selection.position; m_gameObject.transform.localScale = m_selection.scale; if (buttonA) { m_state = State.ExtrudeSimple; m_meshExtruder = new MeshExtruder(m_selection); } else if (buttonB) { m_state = State.ExtrudeCapped; m_meshExtruder = new MeshExtruder(m_selection); } } } else if (m_state == State.ExtrudeSimple) { m_extrudeLength += delta; Vector3[] vertices; int[] triangles; Vector2[] uv; m_meshExtruder.ExtrudeSimple(out vertices, out triangles, out uv, m_extrudeLength, m_topUV, m_sideUV, m_extrudeLength * 100);// SelectionTile.SIDE_CM); m_mesh.Clear(); m_mesh.vertices = vertices; m_mesh.uv = uv; m_mesh.triangles = triangles; m_mesh.RecalculateBounds(); m_mesh.RecalculateNormals(); m_meshRenderer.material = extrudeMaterial; m_meshCollider.sharedMesh = null; m_meshCollider.sharedMesh = m_mesh; if (buttonA) { m_state = State.Finished; } } else if (m_state == State.ExtrudeCapped) { m_extrudeLength += delta; Vector3[] vertices; int[] triangles; Vector2[] uv; m_meshExtruder.ExtrudeCapped(out vertices, out triangles, out uv, m_extrudeLength, m_topUV, m_sideUV, m_sideUV); m_mesh.Clear(); m_mesh.vertices = vertices; m_mesh.uv = uv; m_mesh.triangles = triangles; m_mesh.RecalculateBounds(); m_mesh.RecalculateNormals(); m_meshRenderer.material = extrudeMaterial; m_meshCollider.sharedMesh = null; m_meshCollider.sharedMesh = m_mesh; if (buttonA) { m_state = State.Finished; } } }
private void setLastButtonDown() { if (controllerInput.GetButtonDown(ControllerButton.A)) { lastButtonDown = "A"; } if (controllerInput.GetButtonDown(ControllerButton.B)) { lastButtonDown = "B"; } if (controllerInput.GetButtonDown(ControllerButton.X)) { lastButtonDown = "X"; } if (controllerInput.GetButtonDown(ControllerButton.Y)) { lastButtonDown = "Y"; } if (controllerInput.GetButtonDown(ControllerButton.LeftShoulder)) { lastButtonDown = "LB"; } if (controllerInput.GetButtonDown(ControllerButton.RightShoulder)) { lastButtonDown = "RB"; } if (controllerInput.GetButtonDown(ControllerButton.View)) { lastButtonDown = "SHOW ADDRESS"; } if (controllerInput.GetButtonDown(ControllerButton.Menu)) { lastButtonDown = "SHOW MENU"; } if (controllerInput.GetButtonDown(ControllerButton.LeftThumbstick)) { lastButtonDown = "LEFT STICK CLICK"; } if (controllerInput.GetButtonDown(ControllerButton.RightThumbstick)) { lastButtonDown = "RIGHT STICK CLICK"; } if (controllerInput.GetButtonDown(ControllerButton.DPadDown)) { lastButtonDown = "DPadDown"; } if (controllerInput.GetButtonDown(ControllerButton.DPadUp)) { lastButtonDown = "DPadUp"; } if (controllerInput.GetButtonDown(ControllerButton.DPadLeft)) { lastButtonDown = "DPadLeft"; } if (controllerInput.GetButtonDown(ControllerButton.DPadRight)) { lastButtonDown = "DPadRight"; } }
private void translateRotateScale() { float moveHorizontal = MoveHorizontalSpeed * controllerInput.GetAxisLeftThumbstickX(); float moveVertical = MoveVerticalSpeed * controllerInput.GetAxisLeftThumbstickY(); transform.Translate(moveHorizontal, moveVertical, 0); RaycastHit hit; if (Physics.Raycast(transform.position, Vector3.forward, out hit, maxRayDistance)) { transform.Translate(0, 0, hit.distance - 0.01f); mKey = hit.transform.gameObject; if (mKey.tag == "Keys") { if (mKey != prev_mKey && prev_mKey.tag == "Keys") { prev_mKey.GetComponent <KeyboardItem>().r.material = mKey.GetComponent <KeyboardItem>().theme.GetThemeValue(KeyState.Default); } mKey.GetComponent <KeyboardItem>().r.material = mKey.GetComponent <KeyboardItem>().theme.GetThemeValue(KeyState.Focused); } if (controllerInput.GetButtonDown(ControllerButton.A)) { if (mKey == GameObject.Find("Start")) { Manager.GetComponent <Controller>().startClicked(); Manager.GetComponent <PhraseSet>().listStart(); } else if (mKey == GameObject.Find("Submit")) { Manager.GetComponent <Controller>().submitClicked(); Manager.GetComponent <PhraseSet>().listSubmit(); } else if (mKey.tag == "Keys") { mKey.GetComponent <KeyboardItem>().r.material = mKey.GetComponent <KeyboardItem>().theme.GetThemeValue(KeyState.Pressed); KeyboardMaster.GetComponent <KeyboardCreator>().HandleTap(mKey.GetComponent <KeyboardItem>()); } } prev_mKey = mKey; } else { transform.Translate(0, 0, 2.0f - transform.position.z); } }
// this is called every frame void IControllerProvider.ReadState(ControllerState outState) { lock (state) { if (ctrl != null) { XDevicePlugin.UpdateInputState(handle); XDevicePlugin.GetInputState(handle, ref m_leftControllerState); state.orientation = new Quaternion( -m_leftControllerState.rotation[0], -m_leftControllerState.rotation[1], m_leftControllerState.rotation[2], m_leftControllerState.rotation[3] ); state.gyro = new Vector3( -m_leftControllerState.gyroscope[0], -m_leftControllerState.gyroscope[1], m_leftControllerState.gyroscope[2] ); state.accel = new Vector3( m_leftControllerState.accelerometer[0], m_leftControllerState.accelerometer[1], -m_leftControllerState.accelerometer[2] ); state.touchPos = ctrl.touchPos; // GVR Hack Detection Controller if (ctrl.connectionState == DeviceConnectionState.Connected) { state.connectionState = GvrConnectionState.Connected; } else if (ctrl.connectionState == DeviceConnectionState.Connecting) { state.connectionState = GvrConnectionState.Connecting; } else { state.connectionState = GvrConnectionState.Disconnected; } // GVR Input Mapping state.apiStatus = GvrControllerApiStatus.Ok; state.appButtonState = ctrl.GetButton(XimmerseButton.App); state.appButtonDown = ctrl.GetButtonDown(XimmerseButton.App); state.appButtonUp = ctrl.GetButtonUp(XimmerseButton.App); state.homeButtonDown = ctrl.GetButtonDown(XimmerseButton.Home); state.homeButtonState = ctrl.GetButton(XimmerseButton.Home); state.clickButtonDown = ctrl.GetButtonDown(XimmerseButton.Click) || ctrl.GetButtonDown(XimmerseButton.Trigger); state.clickButtonState = ctrl.GetButton(XimmerseButton.Click) || ctrl.GetButton(XimmerseButton.Trigger); state.clickButtonUp = ctrl.GetButtonUp(XimmerseButton.Click) || ctrl.GetButtonUp(XimmerseButton.Trigger); // GVR Battery Indicator if (ctrl.batteryLevel > 80) { state.batteryLevel = GvrControllerBatteryLevel.Full; } if (ctrl.batteryLevel > 60 && ctrl.batteryLevel <= 80) { state.batteryLevel = GvrControllerBatteryLevel.AlmostFull; } if (ctrl.batteryLevel > 40 && ctrl.batteryLevel <= 60) { state.batteryLevel = GvrControllerBatteryLevel.Medium; } if (ctrl.batteryLevel > 20 && ctrl.batteryLevel <= 40) { state.batteryLevel = GvrControllerBatteryLevel.Low; } if (ctrl.batteryLevel >= 0 && ctrl.batteryLevel <= 20) { state.batteryLevel = GvrControllerBatteryLevel.CriticalLow; } // GVR Recenter Touchpad Detection if (ctrl.GetButtonDown(ControllerButton.PrimaryThumbMove) || ctrl.GetButtonDown(XimmerseButton.Click)) { state.touchDown = true; state.isTouching = true; } if (ctrl.GetButton(ControllerButton.PrimaryThumbMove) || ctrl.GetButton(XimmerseButton.Click)) { state.isTouching = true; } if (ctrl.GetButtonUp(ControllerButton.PrimaryThumbMove) || ctrl.GetButtonUp(XimmerseButton.Click)) { state.touchUp = true; state.isTouching = false; } // GVR Recenter Interactions state.gvrPtr = IntPtr.Zero; if (ctrl.GetButtonUp(XimmerseButton.Home)) { GvrCardboardHelpers.Recenter(); ctrl.Recenter(); state.recentered = true; } } else { if (EnableXdevice == false && FlipAppInstalled() == true) { EnableXdevice = true; XDevicePlugin.Init(); handle = XDevicePlugin.GetInputDeviceHandle("XCobra-0"); ctrl = new ControllerInput(handle); } state.connectionState = GvrConnectionState.Disconnected; state.clickButtonState = false; state.clickButtonDown = false; state.clickButtonUp = false; state.appButtonState = false; state.appButtonDown = false; state.appButtonUp = false; } outState.CopyFrom(state); } state.ClearTransientState(); }
private void DebugModePlacementUpdate() { #if UNITY_EDITOR float horAxis = Input.GetAxis("Horizontal"); bool pressedLeft = Input.GetKeyDown(KeyCode.LeftBracket); bool pressedRight = Input.GetKeyDown(KeyCode.RightBracket); bool pressedUp = Input.GetKeyDown(KeyCode.Semicolon); bool pressedDown = Input.GetKeyDown(KeyCode.Comma); bool pressedX = Input.GetKeyDown(KeyCode.LeftShift); bool pressedY = Input.GetKeyDown(KeyCode.Tab); #else m_xboxController.Update(); float horAxis = m_xboxController.GetAxisLeftThumbstickX(); bool pressedLeft = m_xboxController.GetButtonDown(ControllerButton.DPadLeft); bool pressedRight = m_xboxController.GetButtonDown(ControllerButton.DPadRight); bool pressedUp = m_xboxController.GetButtonDown(ControllerButton.DPadUp); bool pressedDown = m_xboxController.GetButtonDown(ControllerButton.DPadDown); bool pressedX = m_xboxController.GetButtonDown(ControllerButton.X); bool pressedY = m_xboxController.GetButtonDown(ControllerButton.Y); #endif // Y toggles placement mode if (pressedY) { m_player.gameObject.SetActive(!m_player.gameObject.activeSelf); } if (m_player.gameObject.activeSelf) { m_placeableObjects[m_objectIdx].SetActive(false); return; } // Up/down change the placement mode if (pressedUp) { uint mode = (uint)m_placementMode; mode = (mode + 1) % (int)PlacementMode.NumPlacementModes; m_placementMode = (PlacementMode)mode; } if (pressedDown) { uint mode = (uint)m_placementMode; mode = (mode - 1) % (uint)PlacementMode.NumPlacementModes; m_placementMode = (PlacementMode)mode; } // Digital left/right change the object m_placeableObjects[m_objectIdx].SetActive(false); int next = (pressedLeft ? -1 : 0) + (pressedRight ? 1 : 0); m_objectIdx += next; if (m_objectIdx >= m_placeableObjects.Length) { m_objectIdx = 0; } else if (m_objectIdx < 0) { m_objectIdx = m_placeableObjects.Length - 1; } // Analog left/right changes rotation about the Y axis float rotateBy = (horAxis > 0.25f ? 90 : 0) + (horAxis < -0.25f ? -90 : 0); m_eulerY += rotateBy * Time.deltaTime; // Update object position based on placement mode GameObject preview = m_placeableObjects[m_objectIdx]; preview.SetActive(true); switch (m_placementMode) { case PlacementMode.Free: preview.transform.position = Camera.main.transform.position + Camera.main.transform.forward; preview.transform.rotation = Quaternion.LookRotation(Camera.main.transform.forward, Camera.main.transform.up); break; case PlacementMode.Surface: preview.SetActive(false); // don't want raycast to hit self RaycastHit hit; if (FindGazeTarget(out hit)) { preview.transform.position = hit.point; preview.transform.rotation = Quaternion.FromToRotation(Vector3.up, hit.normal) * Quaternion.Euler(new Vector3(0, m_eulerY, 0)); } preview.SetActive(true); break; } // Place object if (pressedX) { GameObject newObj = Instantiate(placeablePrefabs[m_objectIdx], preview.transform.position, preview.transform.rotation); m_objects.Add(newObj); // Hack for passing player position to certain objects DroidController droid = newObj.GetComponent <DroidController>(); if (droid != null) { droid.SetPlayer(m_player.gameObject); } BayController bay = newObj.GetComponent <BayController>(); if (bay != null) { bay.SetPlayer(m_player.gameObject); } } }
void Update() { if (player == null) { return; } //Seleciona outro jogador manual mais proximo se eu estiver muito longe da bola if (player.GetCampTeam().GetSelectionMode() == GameOptionMode.automatric && player.GetCampTeam().HasPlayerOk() && !player.Locomotion.inHoldTug && !player.Locomotion.isJoint && playerToPass == null) { timeToSelect += Time.deltaTime; if (timeToSelect > 1.5f) { if (player.Distance(BallController.GetPosition()) > 3.5f || player.isOk == false) //Procurando jogador mais proximo { PlayerController nearBall = GameManager.instance.GetPlayerNearBall(player.GetCampTeam()); if (nearBall != player) { speed = 0; dir = 0; nearBall.SelectME(); timeToSelect = 0.0f; return; } } } } //Loockat na bola se estiver em strafe if (locomotion.inStrafe) { locomotion.ResetSpeedMultiples(); Vector3 ballposition = BallController.GetPosition(); ballposition.y = transform.position.y; transform.LookAt(ballposition); } //Gerenciamento de stamina if (locomotion.inSoccer) { SkillVar stamina = player.GetSkill_Stamina(); stamina.mode = SkillVarMode.autoSubtract; if (stamina.IsMin || player.isOk == false) { player.GetSkill_Stamina().mode = SkillVarMode.autoRegen; locomotion.ResetSpeedMultiples(); player.SetMotionNormal(); } } //Para ações manuais se estiver tropeçando if (player.Locomotion.inStumble)//Tropeçando { locomotion.ResetSpeedMultiples(); speed = 0; dir = 0; return; } //Solicita avoid dos aliados a frente if (player.IsMyBall()) { PlayerController allyBtw = null; if (player.IsHitForwad(5.5f, out allyBtw, player.GetCampTeam())) { if (allyBtw.IsLookAt(player)) { Vector3 origim = allyBtw.transform.position + (-allyBtw.transform.forward * 4.5f); Vector3 freePos = locomotion.GetRandomNavCircle(origim, 4.5f); allyBtw.GetComponent <AIController>().GoToPosition(freePos, BallController.instance.transform); } } } //Se houver um jogador selecionado para o passe de bola vou esperar ficar distante que o jogador efetue alguma ação difernte de se mover //para remover a seleção do jogador a passar a bola if (playerToPass != null) { if (playerToPass.Distance(player) > 11.5f) { playerToPass = null; GameManager.instance.ResetIndicator(); } } Vector2 move = locomotion.GetDirectionAxis1(); dir = move.x; speed = move.y; //Fill kick power amount if (ControllerInput.GetButtonDown(player.GetInputType(), player.GetInputs().Input_Kick)) { //Fill kick power or fill action2 power SkillVar skillKick = player.GetSkill_BasicKick(); if (player.IsMyBall()) { skillKick.SetToggle(); if (skillKick.IsReady) { skillKick.mode = SkillVarMode.autoRegen; } } playerToPass = null; GameManager.instance.ResetIndicator(); } //Kick ball if (ControllerInput.GetButtonUp(player.GetInputType(), player.GetInputs().Input_Kick)) { //Fill kick power if is myBall SkillVar skillKick = player.GetSkill_BasicKick(); locomotion.ResetHoldTugAnimator(); if (player.IsMyBall() && skillKick.isToggle) { if (skillKick.IsReady) { if (locomotion.TriggerKick()) { skillKick.TriggerCooldown(); } } } skillKick.mode = SkillVarMode.nothing; skillKick.SetCurrentValue(0); skillKick.ResetTogle(); playerToPass = null; GameManager.instance.ResetIndicator(); } //Soccer Motion if (ControllerInput.GetButton(player.GetInputType(), player.GetInputs().Input_Stamina)) { SkillVar Stamina = player.GetSkill_Stamina(); if (Stamina.IsCritical == false && player.isOk) { // playerToPass = null; // GameManager.instance.ResetIndicator(); player.SetMotionSoccer(); player.Locomotion.SetSpeedMultiplies(1.2f); } } if (ControllerInput.GetButtonUp(player.GetInputType(), player.GetInputs().Input_Stamina)) { // playerToPass = null; // GameManager.instance.ResetIndicator(); player.Locomotion.ResetSpeedMultiples(); player.SetMotionNormal(); player.GetSkill_Stamina().mode = SkillVarMode.autoRegen; } //Strafe Motion if (ControllerInput.GetButtonDown(player.GetInputType(), player.GetInputs().Input_Strafe)) { // playerToPass = null; // GameManager.instance.ResetIndicator(); player.SetMotionStrafe(); player.Locomotion.SetSpeedMultiplies(1.2f); } if (ControllerInput.GetButtonUp(player.GetInputType(), player.GetInputs().Input_Strafe)) { // playerToPass = null; // GameManager.instance.ResetIndicator(); player.Locomotion.ResetSpeedMultiples(); player.SetMotionNormal(); } //Seleção para passe de bola if (ControllerInput.GetButton(player.GetInputType(), player.GetInputs().Input_Pass)) { if (player.IsMyBall() == true && locomotion.inNormal) { Vector3 mdirection = transform.forward; List <PlayerController> players = player.GetPlayersNear(10.5f); if (players.Count > 0) { PlayerController target = players.MinAngle(player, mdirection); playerToPass = target; GameManager.instance.IndicatePlayer(playerToPass); } } } //Rasteira if (ControllerInput.GetButtonDown(player.GetInputType(), player.GetInputs().Input_Pass)) { if (player.IsMyBall() == false && locomotion.inNormal) { SkillVar skilltrack = player.GetSkill_BasicActionTwo(); if (skilltrack.IsReady) { if (locomotion.TriggerActionTwo()) { skilltrack.TriggerCooldown(); } } } } //Passe de bola if (ControllerInput.GetButtonUp(player.GetInputType(), player.GetInputs().Input_Pass)) { //playerToPass = null; //GameManager.instance.ResetIndicator(); SkillVar skillPass = player.GetSkill_BasicPass(); if (skillPass.IsReady && player.IsMyBall()) { if (locomotion.inNormal) { if (locomotion.TriggerPass()) { skillPass.TriggerCooldown(); } else { playerToPass = null; GameManager.instance.ResetIndicator(); } } } else { playerToPass = null; GameManager.instance.ResetIndicator(); } } //JUMP if (ControllerInput.GetButtonDown(player.GetInputType(), player.GetInputs().Input_Jump)) { locomotion.jump = true; } if (ControllerInput.GetButtonUp(player.GetInputType(), player.GetInputs().Input_Jump)) { locomotion.jump = false; } }