public void Update(ControllerInput input) { // bool prevValue = value; if (buttonMasks[0] != 0) { if (input.GetButton(buttonMasks[0])) { value = false; } else { value = input.GetButton(buttonMasks[1]); } } else { value = input.GetButton(buttonMasks[1]); } // if (value != prevValue) { if (target != null) { target.SetActive(true); } else { if (value) { onPressed.Invoke(); } else { onReleased.Invoke(); } } } }
void Update() { controllerInput.Update(); if (!m_Jump) { m_Jump = controllerInput.GetButton(ControllerButton.A); } bool button = controllerInput.GetButton(ControllerButton.RightShoulder); if (button) { SpatialMappingManager.Instance.DrawVisualMeshes = !SpatialMappingManager.Instance.DrawVisualMeshes; } //debug purpose only /*bool und = controllerInput.GetButton(ControllerButton.LeftShoulder); * if (und) * { * SpatialUnderstanding.Instance.GetComponent<SpatialUnderstandingCustomMesh>().DrawProcessedMesh = !SpatialUnderstanding.Instance.GetComponent<SpatialUnderstandingCustomMesh>().DrawProcessedMesh; * }*/ if (again) { if (controllerInput.GetButton(ControllerButton.X)) { again = false; chosen = true; } } if (controllerInput.GetButton(ControllerButton.X)) { endScan = true; } }
// Update is called once per frame void Update() { controllerInput.Update(); //transform.position = new Vector3(Camera.main.transform.position.x - (float)0.3 , Camera.main.transform.position.y + (float)0.2 , Camera.main.transform.position.z + 2); if (controllerInput.GetButton(ControllerButton.Menu) && tt == true) { on = !on; if (on) { System_info(); } else if (!on) { this.GetComponent <TextMesh>().text = ""; } } }
public void Update(ControllerInput input) { if (target != null) { switch (type) { case AxisType.Joystick: target.gameObject.SetActive(input.GetButton(ControllerButton.PrimaryThumbMove)); target.localPosition = m_CachedVector3 + new Vector3(input.GetAxis(axes[0]) * maxValue, input.GetAxis(axes[1]) * maxValue, 0.0f); break; case AxisType.Trigger: target.localRotation = Quaternion.AngleAxis(m_CachedVector3.x + input.GetAxis(axes[0]) * maxValue, Vector3.right); break; } } }
void changeTransform() { float moveHorizontal = 0.0f, moveVertical = 0.0f, moveDepth = 0.0f; if (controllerInput.GetButton(ControllerButton.RightShoulder)) { moveDepth = MoveSpeed * controllerInput.GetAxisLeftThumbstickY(); } else { moveHorizontal = MoveSpeed * controllerInput.GetAxisLeftThumbstickX(); moveVertical = MoveSpeed * controllerInput.GetAxisLeftThumbstickY(); } var rotateAroundY = RotateSpeed * controllerInput.GetAxisRightThumbstickX(); transform.Translate(moveHorizontal, moveVertical, moveDepth); transform.Rotate(0, -rotateAroundY, 0); }
private void Update() { #if UNITY_EDITOR m_jumpActive = Input.GetKey(KeyCode.Joystick1Button0); m_extrudePressed |= Input.GetKeyDown(KeyCode.Joystick1Button1); m_attackPressed |= Input.GetKeyDown(KeyCode.Joystick1Button3); m_platformGunPressed |= Input.GetKeyDown(KeyCode.Joystick1Button4); #else m_xboxController.Update(); m_jumpActive = m_xboxController.GetButton(ControllerButton.A); m_extrudePressed |= m_xboxController.GetButtonDown(ControllerButton.B); m_attackPressed |= m_xboxController.GetButtonDown(ControllerButton.X); m_platformGunPressed |= m_xboxController.GetButtonDown(ControllerButton.LeftShoulder); #endif m_motionInput = GetMotionInput(); if (m_motionInput != Vector3.zero) { m_moved = true; } }
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; } }
// Modify 4/14/2017 #if UNITY_UWP // Update is called once per frame void Update() { try { controllerInput.Update(); controllerConnection = true; } catch (ArgumentOutOfRangeException e) { controllerConnection = false; } if (controllerInput.GetButton(ControllerButton.A)) { GetControllerInfo(); } while (ExecuteOnMainThread.Count > 0) { ExecuteOnMainThread.Dequeue().Invoke(); } }
// Update is called once per frame void Update() { controllerInput.Update(); cloud_mesh mesh = cloud.GetComponent <cloud_mesh>(); navigator naviss = navi.GetComponent <navigator>(); height = mesh.points; res = mesh.showColNum; average = mesh.average; lat = naviss.get_lat; log = naviss.get_log; pix = naviss.get_Pix; file_name = mesh.filename_rr; if (Input.GetAxis("explore_h") == -1 || controllerInput.GetButton(ControllerButton.DPadRight)) { Vector3 current_position = this.transform.localPosition; current_position.z++; if (current_position.z < 100) { p_x = current_position.x; p_z = current_position.z; int x = (int)p_x + res / 2; int z = (int)p_z + res / 2; int index = (z) + (res - x) * res; // Debug.Log("Test:"); // Debug.Log(height[index]); this.transform.localPosition = new Vector3(p_x, height[index].y, p_z); Debug.Log(this.transform.localPosition); } } else if (Input.GetAxis("explore_h") == 1 || controllerInput.GetButton(ControllerButton.DPadLeft)) { Vector3 current_position = this.transform.localPosition; Debug.Log(current_position); current_position.z--; if (current_position.z > -100) { p_x = current_position.x; p_z = current_position.z; int x = (int)p_x + res / 2; int z = (int)p_z + res / 2; int index = (z) + (res - x) * res; // Debug.Log("Test:"); // Debug.Log(height[index]); this.transform.localPosition = new Vector3(p_x, height[index].y, p_z); // Debug.Log(this.transform.localPosition); } } else if (Input.GetAxis("explore_v") == 1 || controllerInput.GetButton(ControllerButton.DPadDown)) { Vector3 current_position = this.transform.localPosition; current_position.x++; if (current_position.x < 100) { p_x = current_position.x; p_z = current_position.z; int x = (int)p_x + res / 2; int z = (int)p_z + res / 2; int index = (z) + (res - x) * res; // Debug.Log("Test:"); // Debug.Log(height[index]); this.transform.localPosition = new Vector3(p_x, height[index].y, p_z); // Debug.Log(this.transform.localPosition); } } else if (Input.GetAxis("explore_v") == -1 || controllerInput.GetButton(ControllerButton.DPadUp)) { Vector3 current_position = this.transform.localPosition; current_position.x--; if (current_position.x > -100) { p_x = current_position.x; p_z = current_position.z; int x = (int)p_x + res / 2; int z = (int)p_z + res / 2; int index = (z) + (res - x) * res; Debug.Log("Test:"); Debug.Log(height[index]); this.transform.localPosition = new Vector3(p_x, height[index].y, p_z); Debug.Log(this.transform.localPosition); } } else if (height.Length != 0) { Vector3 current_position = this.transform.localPosition; p_x = current_position.x; p_z = current_position.z; int x = (int)p_x + res / 2; int z = (int)p_z + res / 2; int index = (z) + (res - x) * res; // Debug.Log(height[index]); this.transform.localPosition = new Vector3(p_x, height[index].y, p_z); // Debug.Log(this.transform.localPosition); } if (en_dis) { float dis_hei = this.transform.localPosition.y + average; float n_lat = lat + this.transform.localPosition.x * pix; float n_log = log + this.transform.localPosition.z * pix; Info_dis.GetComponent <TextMesh>().text = "Latitude: " + n_lat + "\n" + "Logtitude: " + n_log + "\n" + "Normalized Height(0 - 200 pixel unit): " + dis_hei + "\n" + "Current Result File: " + file_name; } }
private void setButtonInputText() { setLastButtonDown(); setLastButtonUp(); ButtonInputText.text = "Last Button Down: " + lastButtonDown + System.Environment.NewLine + "Last Button Up: " + lastButtonUp + System.Environment.NewLine + "A: " + ((controllerInput.GetButton(ControllerButton.A)) ? "YES" : "NO") + System.Environment.NewLine + "B: " + ((controllerInput.GetButton(ControllerButton.B)) ? "YES" : "NO") + System.Environment.NewLine + "X: " + ((controllerInput.GetButton(ControllerButton.X)) ? "YES" : "NO") + System.Environment.NewLine + "Y: " + ((controllerInput.GetButton(ControllerButton.Y)) ? "YES" : "NO") + System.Environment.NewLine + "LB: " + ((controllerInput.GetButton(ControllerButton.LeftShoulder)) ? "YES" : "NO") + System.Environment.NewLine + "RB: " + ((controllerInput.GetButton(ControllerButton.RightShoulder)) ? "YES" : "NO") + System.Environment.NewLine + "SHOW ADDRESS BAR: " + ((controllerInput.GetButton(ControllerButton.View)) ? "YES" : "NO") + System.Environment.NewLine + "SHOW MENU: " + ((controllerInput.GetButton(ControllerButton.Menu)) ? "YES" : "NO") + System.Environment.NewLine + "LEFT STICK CLICK: " + ((controllerInput.GetButton(ControllerButton.LeftThumbstick)) ? "YES" : "NO") + System.Environment.NewLine + "RIGHT STICK CLICK: " + ((controllerInput.GetButton(ControllerButton.RightThumbstick)) ? "YES" : "NO") + System.Environment.NewLine + "DPadDown: " + ((controllerInput.GetButton(ControllerButton.DPadDown)) ? "YES" : "NO") + System.Environment.NewLine + "DPadUp: " + ((controllerInput.GetButton(ControllerButton.DPadUp)) ? "YES" : "NO") + System.Environment.NewLine + "DPadLeft: " + ((controllerInput.GetButton(ControllerButton.DPadLeft)) ? "YES" : "NO") + System.Environment.NewLine + "DPadRight: " + ((controllerInput.GetButton(ControllerButton.DPadRight)) ? "YES" : "NO"); }
// Update is called once per frame void Update() { bool updateNeeded = false; float cutoff = 0.5f; float input; _controllerInput.Update(); if (_controllerInput.GetButton(ControllerButton.DPadUp)) { updateNeeded = _dataManager.SizeWindow(4); } else if (_controllerInput.GetButton(ControllerButton.DPadDown)) { updateNeeded = _dataManager.SizeWindow(-4); } else if (_controllerInput.GetButton(ControllerButton.DPadRight)) { updateNeeded = _dataManager.MoveWindow(4); } else if (_controllerInput.GetButton(ControllerButton.DPadLeft)) { updateNeeded = _dataManager.MoveWindow(-4); } if (updateNeeded) { foreach (SliceManagerScript slice in slices) { slice.RefreshSlices(); } } if (_controllerInput.GetButton(ControllerButton.View)) { foreach (SliceManagerScript slice in slices) { slice.CenterSlice(); } } input = _controllerInput.GetAxisLeftThumbstickY(); if (Mathf.Abs(input) > cutoff) { if (input > 0f) { slices[0].MoveSlice(1); } else { slices[0].MoveSlice(-1); } } input = _controllerInput.GetAxisRightThumbstickY(); if (Mathf.Abs(input) > cutoff) { if (input > 0f) { slices[1].MoveSlice(1); } else { slices[1].MoveSlice(-1); } } input = _controllerInput.GetAxisLeftThumbstickX(); if (Mathf.Abs(input) > cutoff) { if (input > 0f) { slices[2].MoveSlice(1); } else { slices[2].MoveSlice(-1); } } }
private void translateRotateScale() { float moveHorizontal = MoveHorizontalSpeed * controllerInput.GetAxisLeftThumbstickX(); float moveVertical = MoveVerticalSpeed * controllerInput.GetAxisLeftThumbstickY(); this.transform.Translate(moveHorizontal, moveVertical, 0.0f); float rotateAroundY = RotateAroundYSpeed * controllerInput.GetAxisRightThumbstickX(); float rotateAroundX = RotateAroundXSpeed * controllerInput.GetAxisRightThumbstickY(); float rotateAroundZ = RotateAroundZSpeed * (controllerInput.GetAxisRightTrigger() - controllerInput.GetAxisLeftTrigger()); this.transform.Rotate(rotateAroundX, -rotateAroundY, rotateAroundZ); if (controllerInput.GetButton(ControllerButton.DPadUp)) { this.transform.localScale = this.transform.localScale + (this.transform.localScale * ScaleSpeed * Time.deltaTime); } if (controllerInput.GetButton(ControllerButton.DPadDown)) { this.transform.localScale = this.transform.localScale - (this.transform.localScale * ScaleSpeed * Time.deltaTime); } }
private void UpdateControls(Vector3 aim) { // Determine angle between user gaze vector and helicopter forward, in xz // plane Vector3 view = new Vector3(Camera.main.transform.forward.x, 0, Camera.main.transform.forward.z); Vector3 forward = new Vector3(transform.forward.x, 0, transform.forward.z); float angle = Vector3.Angle(view, forward); // Get current joypad axis values #if UNITY_EDITOR float hor = Input.GetAxis("Horizontal"); float ver = Input.GetAxis("Vertical"); float hor2 = Input.GetAxis("Horizontal2"); float ver2 = -Input.GetAxis("Vertical2"); float lt = Input.GetAxis("Axis9"); float rt = Input.GetAxis("Axis10"); bool buttonA = Input.GetKey(KeyCode.Joystick1Button0); bool buttonB = Input.GetKey(KeyCode.Joystick1Button1); bool fire = rt > 0.5f || buttonA; #else m_xboxController.Update(); float hor = m_xboxController.GetAxisLeftThumbstickX(); float ver = m_xboxController.GetAxisLeftThumbstickY(); float hor2 = m_xboxController.GetAxisRightThumbstickX(); float ver2 = m_xboxController.GetAxisRightThumbstickY(); float lt = m_xboxController.GetAxisLeftTrigger(); float rt = m_xboxController.GetAxisRightTrigger(); bool fire = rt > 0.5f; bool buttonA = m_xboxController.GetButton(ControllerButton.A); bool buttonB = m_xboxController.GetButton(ControllerButton.B); /* * float hor = Input.GetAxis("Horizontal"); * float ver = Input.GetAxis("Vertical"); * float axis3 = Input.GetAxis("Axis3"); * float lt = Mathf.Max(axis3, 0); * float rt = -Mathf.Min(axis3, 0); */ #endif // Any of the main axes (which are relative to orientation) pressed? bool movingThisFrame = (hor != 0) || (ver != 0); if (movingThisFrame && !m_movingLastFrame) { // Joypad was not pressed last frame, reorient based on current view position m_joypadLateralAxis = Vector3.Normalize(Camera.main.transform.right); m_joypadLongitudinalAxis = Vector3.Normalize(Camera.main.transform.forward); } m_movingLastFrame = movingThisFrame; // Apply longitudinal and lateral controls. Compute projection of joypad // lateral/longitudinal axes onto helicopter's. float joypadLongitudinalToHeliLongitudinal = Vector3.Dot(m_joypadLongitudinalAxis, transform.forward); float joypadLongitudinalToHeliLateral = Vector3.Dot(m_joypadLongitudinalAxis, transform.right); float joypadLateralToHeliLongitudinal = Vector3.Dot(m_joypadLateralAxis, transform.forward); float joypadLateralToHeliLateral = Vector3.Dot(m_joypadLateralAxis, transform.right); m_playerControls.longitudinal = joypadLongitudinalToHeliLongitudinal * ver + joypadLateralToHeliLongitudinal * hor; m_playerControls.lateral = joypadLongitudinalToHeliLateral * ver + joypadLateralToHeliLateral * hor; // Helicopter rotation m_playerControls.rotational = hor2; // Altitude control (trigger axes each range from 0 to 1) m_playerControls.altitude = ver2; // Gun if (fire && (Time.time - m_gunLastFired >= GUN_FIRE_PERIOD)) { FireGun(aim); } }
// 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(); }
// Update is called once per frame void Update() { SmootIKWeight(); PlayerController mnPlayer; mnPlayer = player.GetPlayerNear(); //Estica maos para o jogaodr mais proximo HandleHandsTo(mnPlayer); if (jointPlayer) { if (!player.isOk || player.Locomotion.inStumble || player.Locomotion.inTrack || player.IsMyBall() || !jointPlayer.isOk || !player.GetSkill_BasicActionOne().IsReady ) { RemoveJoint(); } } else if (player.Locomotion.inHoldTug) { if (mnPlayer != null && !player.Locomotion.inAir && player.isOk && !mnPlayer.IsMyTeaM(player)) { float dist = mnPlayer.Distance(player); if (dist <= tugWarDistance && dist > 0.5f && mnPlayer.isOk && !mnPlayer.Locomotion.inAir) { //JOINT player.Locomotion.JointTo(mnPlayer); jointPlayer = mnPlayer; jointPlayer.GetAnimatorEvents().OnChangeDirStart += EnemyOnChangeDir; } } } //CONTROLE MANUAL if (!player.IsIA) { if (player.IsMyBall() || player.isOk == false) { if (player.Locomotion.inHoldTug) { player.Locomotion.ResetHoldTugAnimator(); } player.GetSkill_BasicActionOne().mode = SkillVarMode.autoSubtract; return; } if (ControllerInput.GetButton(player.GetInputType(), player.GetInputs().Input_Kick) && player.isOk) { SkillVar skilltug = player.GetSkill_BasicActionOne(); skilltug.SetToggle(); if (skilltug.IsMax) { skilltug.TriggerCooldown(); } if (skilltug.IsReady) { skilltug.mode = SkillVarMode.autoRegen; if (jointPlayer == null) { player.Locomotion.SetHoldTugAnimator(); } else { player.Locomotion.ResetHoldTugAnimator(); } } else { skilltug.SetCurrentValue(0); skilltug.mode = SkillVarMode.nothing; player.Locomotion.ResetHoldTugAnimator(); } } if (ControllerInput.GetButtonUp(player.GetInputType(), player.GetInputs().Input_Kick)) { SkillVar skilltug = player.GetSkill_BasicActionOne(); if (skilltug.isToggle == false) { return; } skilltug.mode = SkillVarMode.autoSubtract; player.Locomotion.ResetHoldTugAnimator(); skilltug.ResetTogle(); if (skilltug.IsReady) { RemoveJoint(); } } } }
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; } }
// Update is called once per frame void Update() { controllerInput.Update(); GameObject cloud = GameObject.Find("cloudMeshMap"); if (enable == false) { return; } if (Input.GetAxis("Vertical") > 0 || controllerInput.GetAxisLeftThumbstickY() > 0) { Vector3 current_position = this.transform.localPosition; current_position.y++; if (current_position.y + resolution / 2 <= row_num / 2) { this.transform.localPosition = current_position; cloud.GetComponent <cloud_mesh>().Update_position(current_position); send_coor(current_position); } } if (Input.GetAxis("Vertical") < 0 || controllerInput.GetAxisLeftThumbstickY() < 0) { Vector3 current_position = this.transform.localPosition; current_position.y--; if (current_position.y - resolution / 2 >= -row_num / 2) { this.transform.localPosition = current_position; cloud.GetComponent <cloud_mesh>().Update_position(current_position); send_coor(current_position); } } if (Input.GetAxis("Horizontal") < 0 || controllerInput.GetAxisLeftThumbstickX() < 0) { Vector3 current_position = this.transform.localPosition; current_position.x--; if (current_position.x - resolution / 2 >= -col_num / 2) { this.transform.localPosition = current_position; cloud.GetComponent <cloud_mesh>().Update_position(current_position); send_coor(current_position); } } if (Input.GetAxis("Horizontal") > 0 || controllerInput.GetAxisLeftThumbstickX() > 0) { Vector3 current_position = this.transform.localPosition; current_position.x++; if (current_position.x + resolution / 2 <= col_num / 2) { this.transform.localPosition = current_position; cloud.GetComponent <cloud_mesh>().Update_position(current_position); send_coor(current_position); } } if (Input.GetKeyDown(KeyCode.JoystickButton8) || (controllerInput.GetButton(ControllerButton.LeftThumbstick))) { Vector3 current_position = new Vector3(0, 0, 0); this.transform.localPosition = current_position; cloud.GetComponent <cloud_mesh>().Update_position(current_position); send_coor(current_position); } /* * if (Input.GetKeyDown(KeyCode.JoystickButton4)) * { * if (resolution > 49) * { * resolution = resolution / 2; * Vector3 current_position = this.transform.localPosition; * cloud.GetComponent<cloud_mesh>().resize_view(resolution, current_position); * send_coor(current_position); * } * * } * * if (Input.GetKeyDown(KeyCode.JoystickButton5)) * { * if (resolution < 101) * { * resolution = resolution * 2; * Vector3 current_position = this.transform.localPosition; * if (current_position.y + resolution / 2 > row_num / 2) * { * current_position.y = row_num / 2 - resolution / 2; * } * if (current_position.y - resolution / 2 < -row_num / 2) * { * current_position.y = -row_num / 2 + resolution / 2; * } * if (current_position.x + resolution / 2 > col_num / 2) * { * current_position.x = col_num / 2 - resolution / 2; * } * if (current_position.x - resolution / 2 < -col_num / 2) * { * current_position.x = -col_num / 2 + resolution / 2; * } * this.transform.localPosition = current_position; * cloud.GetComponent<cloud_mesh>().resize_view(resolution, current_position); * send_coor(current_position); * } * } */ }