// Update is called once per frame void Update() { shoot_button = CnInputManager.GetButton("Jump"); moving.x = moving.y = 0; Vector2 movement = new Vector2(CnInputManager.GetAxis("Horizontal"), CnInputManager.GetAxis("Vertical")); if (movement.x > 0) { moving.x = 1; transform.localScale = new Vector3(1, 1, 1); } else if (movement.x < 0) { moving.x = -1; transform.localScale = new Vector3(-1, 1, 1); } // for jump if (movement.y > 0) { moving.y = 1; } else if (movement.y < 0) { moving.y = -1; } }
void Update() { if (UnitZ.playerManager.PlayingCharacter != null) { SetVisible(true); FPSController fpsControl = UnitZ.playerManager.PlayingCharacter.GetComponent <FPSController>(); if (fpsControl) { MouseLock.IsMobileControl = true; fpsControl.MoveCommand(new Vector3(CnInputManager.GetAxis("Horizontal"), 0, CnInputManager.GetAxis("Vertical")), CnInputManager.GetButton("Jump")); fpsControl.Aim(new Vector2(CnInputManager.GetAxis("Touch X") * AimSensitivity, CnInputManager.GetAxis("Touch Y") * AimSensitivity)); fpsControl.Trigger1(CnInputManager.GetButton("Touch Fire1")); /*fpsControl.Trigger2(CnInputManager.GetButtonDown("Fire2")); * * if (CnInputManager.GetButtonDown("Fire3")) * { * fpsControl.OutVehicle(); * fpsControl.Interactive(); * } * * if (CnInputManager.GetButtonDown("Submit")) * { * fpsControl.Reload(); * }*/ fpsControl.Checking(); } } else { SetVisible(false); } }
void ControlSprint() { if (points <= 300) { speedMultiplier = 1; return; } // IF IS PLAYER if (isPlayer) { if (CnInputManager.GetButton("Jump")) { speedMultiplier = originalSpeedMultiplier; } else { speedMultiplier = 1; } } // IF IS BOT if (!isPlayer) { if (aiModule.sprint) { speedMultiplier = originalSpeedMultiplier; } else { speedMultiplier = 1; } } }
public override bool IsActionHeld(string action) { foreach (var i in inputsMap) { if (i.action == action) { #if UP_USE_CN_INPUT_MANAGER if (SystemInfo.deviceType == DeviceType.Handheld) { return(CnInputManager.GetButton(i.handheld)); } #endif #if UP_USE_WII_INPUT_MANAGER if (remote != null) { return(GetWiiButton(i.wii)); } #endif return(Input.GetButton(i.keyboard)); } } Debug.LogWarning("Cannot find action: " + action); return(false); }
// Update is called once per frame void Update() { if (!isLocalPlayer || skill.isCooldown()) { return; } if (CnInputManager.GetButtonDown(simpleButtonName)) { skill.ButtonDown(); } if (CnInputManager.GetButtonUp(simpleButtonName) && !cancelSkill) { skill.ButtonUp(); } if (CnInputManager.GetButtonUp(simpleButtonName) && cancelSkill) { skill.ButtonCancel(); } if (!isPressButton && CnInputManager.GetButton(simpleButtonName)) { skill.ButtonDirection(CnInputManager.GetAxis(verticalButtonName), CnInputManager.GetAxis(horizontalButtonName)); } if (CnInputManager.GetButtonDown("CancelSkill")) { cancelSkill = true; } if (CnInputManager.GetButtonUp("CancelSkill")) { cancelSkill = false; } }
void Input() { if (!isLocalPlayer) { return; } if (CanMove == true) { //get horizontal and vertical input from controller horizontalMovement = CnInputManager.GetAxis("Horizontal"); verticalMovement = CnInputManager.GetAxis("Vertical"); if (movement != Vector3.zero) { targetRotation = Quaternion.LookRotation(movement, Vector3.up); } else { targetRotation = transform.rotation; } CmdMove(horizontalMovement, verticalMovement, targetRotation); } if (CnInputManager.GetButton("Attack")) { //attacking variable isn't really used for anything, but attack doesn't seem to synchronize unless they have at least one parameter. attacking = true; CmdAttack(attacking); } }
// Update is called once per frame void Update() { bool isAbility1 = CnInputManager.GetButton("ability1"); Debug.Log(isAbility1 ? teleportDistance : 1); //m }
void JumpInput() { if (CnInputManager.GetButtonDown("JumpBtn") && isGrounded) { isJumping = true; jumpTimeCounter = jumpTime; rb.velocity = new Vector2(rb.velocity.x, jumpForce); } if (CnInputManager.GetButton("JumpBtn") && isJumping) { if (jumpTimeCounter > 0) { rb.velocity = Vector2.up * jumpForce; jumpTimeCounter -= Time.deltaTime; } else { isJumping = false; } } if (CnInputManager.GetButtonUp("JumpBtn")) { isJumping = false; } }
// Update is called once per frame void Update() { //ax = Input.GetAxis("Button_A"); //if (ax == -0.1861143) //if (Input.GetAxis("mouse 0") != 0) //if (clicker.clicked()) //if (Input.GetKeyDown("Button_A")) //if (CnInputManager.GetButton("Button_A")) //{ // //isWalking = !isWalking; //} if (CnInputManager.GetButton("Button_Y")) { controller.SimpleMove(Camera.main.transform.forward * velocity); } if (CnInputManager.GetButton("Button_A")) { controller.SimpleMove(Camera.main.transform.forward * -velocity); } if (CnInputManager.GetButton("Button_X")) { controller.SimpleMove(Camera.main.transform.right * -velocity); } if (CnInputManager.GetButton("Button_B")) { controller.SimpleMove(Camera.main.transform.right * velocity); } }
void FixedUpdate() { if (isReloading) { return; } if (ammo == 0) { StartCoroutine(Reload()); fireDelay -= Time.deltaTime; return; } else { //if (Input.GetButton("Fire1") && fireDelay < 0) if (CnInputManager.GetButton("Jump") && fireDelay < 0) { fireDelay = 1.5f; isShooting = true; StartCoroutine(Shoot()); } else { fireDelay -= Time.deltaTime; } } }
void ControlWithVirtualPad() { deltaVec = new Vector2(CnInputManager.GetAxis("Horizontal"), CnInputManager.GetAxis("Vertical")); base.Movable(deltaVec); base.Shootable(CnInputManager.GetButton("Push"), CnInputManager.GetButton("Pull"), CnInputManager.GetButtonUp("Pull")); }
void Update() { if (CnInputManager.GetButton("Jump") && Time.time > nextFire) //if (Input.GetButton("Fire1") && Time.time > nextFire) { nextFire = Time.time + fireRate; Instantiate(shot, shotSpawn.position, shotSpawn.rotation); GetComponent <AudioSource> ().Play(); } }
void Update() { if (CnInputManager.GetButton("Jump") && Time.time > nextFire) { nextFire = Time.time + fireRate; Instantiate(shot, shotSpawn.position, shotSpawn.rotation); audioSource.Play(); } }
// Update is called once per frame void Update() { if (ifCanMoove) { horizontalMove = CnInputManager.GetAxisRaw("Horizontal") * Speed; animator.SetFloat("Speed", Mathf.Abs(CnInputManager.GetAxisRaw("Horizontal"))); } #if UNITY_ANDROID if (CnInputManager.GetButtonDown("Run") && controller.m_Grounded) { stateSpeed = !stateSpeed; animator.SetBool("Run", stateSpeed); Speed = stateSpeed? runSpeed:walkSpeed; } //} else if (CnInputManager.GetButtonUp("Run")) { // animator.SetBool("Run", false); // Speed = walkSpeed; //} #else if (CnInputManager.GetButton("Run") && controller.m_Grounded) { animator.SetBool("Run", true); Speed = runSpeed; } else if (CnInputManager.GetButtonUp("Run")) { animator.SetBool("Run", false); Speed = walkSpeed; } #endif //GetSword if (CnInputManager.GetButtonDown("GetSword")) { animator.SetBool("Swording", !animator.GetBool("Swording")); AttakBTN.SetActive(animator.GetBool("Swording")); } if (animator.GetBool("Swording") && CnInputManager.GetButtonDown("Fire1") && forAttack) { animator.SetTrigger("Attack"); sword.SetActive(true); StartCoroutine(WaitSecfloat(1f)); } if (CnInputManager.GetButtonDown("Jump")) { jump = true; } }
private void FixedUpdate() { Crouch = CnInputManager.GetButton("Crouch"); h = CnInputManager.GetAxis("Horizontal"); // Pass all parameters to the character control script. if (!GameController.isGameOver) { Character.Move(h, Crouch, Jump); } Jump = false; }
public static void ReadInputs(PlayerController player) { player.accelerate = CnInputManager.GetButton("Accelerate"); player.Turn(CnInputManager.GetAxisRaw("Rotate")); if (CnInputManager.GetButton("Shoot")) { player.CmdShoot(); } }
void shipMov() { rot = transform.rotation; pos = transform.position; anim.SetBool("IsMoving", false); maxSpeed = 0; if (CnInputManager.GetAxis("Horizontal") != 0) { if (isDown == false) { // ROTATE the ship. // Grab our rotation quaternion // Grab the Z euler angle float z = rot.eulerAngles.z; // Change the Z angle based on input z -= CnInputManager.GetAxis("Horizontal") * rotSpeed * Time.deltaTime; // Recreate the quaternion rot = Quaternion.Euler(0, 0, z); // Feed the quaternion into our rotation transform.rotation = rot; // Finally, update our position!! transform.position = pos; } } if (CnInputManager.GetAxis("Vertical") == 0) { isDown = false; rot = Quaternion.Euler(0, 0, 0); } if (CnInputManager.GetButton("Boost")) { Debug.Log("wea"); source.Play(); maxSpeed = 5f; Vector3 velocity = new Vector3(maxSpeed * Time.deltaTime, 0, 0); pos += transform.rotation * velocity; transform.position = pos; anim.SetBool("IsMoving", true); } if (CnInputManager.GetButtonUp("Boost")) { source.Stop(); } }
void Update() { if (CnInputManager.GetButton("Fire3")) { sw.SetBool("a", true); b.SetBool("a", true); k.SetBool("a", true); if (PlayerPrefs.GetString("playerClass") == "knight") { c.enabled = true; } Invoke("kstop", 1f); Invoke("stop", 0.01f); } }
void Update() { CharacterController controller = GetComponent <CharacterController>(); if (controller.isGrounded || isFlying) { moveDirection = new Vector3(0, 0, CnInputManager.GetAxis("Vertical")); moveDirection = transform.TransformDirection(moveDirection); if (collisionScript.inSpeedZone) { moveDirection *= topSpeed; } else { moveDirection *= speed; } if (CnInputManager.GetButton("Jump")) { if (collisionScript.onTrampoline) { moveDirection.y = topJumpSpeed; } else { moveDirection.y = jumpSpeed; } } } float rotationLigeNu = CnInputManager.GetAxis("Horizontal") * rotationsFart; transform.Rotate(0, rotationLigeNu, 0); moveDirection.y -= gravity * Time.deltaTime; controller.Move(moveDirection * Time.deltaTime); if (CnInputManager.GetButton("Reset")) { transform.position = collisionScript.lastCheckpointPosition; } CheckForAnimation(); }
void Update() { /* rightArrow = Input.GetKey(KeyCode.RightArrow); * leftArrow = Input.GetKey(KeyCode.LeftArrow); * blocking = Input.GetKey(KeyCode.Z);*/ rightArrow = CnInputManager.GetButton("RightArrow"); leftArrow = CnInputManager.GetButton("LeftArrow"); blocking = CnInputManager.GetButton("BlockBtn"); if (CnInputManager.GetButtonDown("AttackBtn")) { animator.SetTrigger("attack"); } animator.SetBool("blocking", blocking); }
public bool GetKey(myKeyCode keyCode) { switch (keyCode) { case myKeyCode.Attack: return(CnInputManager.GetButton(attackButton.ButtonName) || Input.GetKey(attackKeyCode)); case myKeyCode.Jump: return(CnInputManager.GetButton(jumpButton.ButtonName) || Input.GetKey(jumpKeyCode)); case myKeyCode.Skill1: return(CnInputManager.GetButton(skill1Button.ButtonName) || Input.GetKey(skill1KeyCode)); case myKeyCode.Skill2: return(CnInputManager.GetButton(skill2Button.ButtonName) || Input.GetKey(skill2KeyCode)); } return(false); }
void Update() { if (fireRate == 0) { if (CnInputManager.GetButtonDown("Fire")) { Shoot(); } } else { if (CnInputManager.GetButton("Fire") && Time.time > timeToFire) { timeToFire = Time.time + 1 / fireRate; Shoot(); } } }
void FixedUpdate() { CircleColaiderLeft.GetComponent <CircleCollider2D>().enabled = false; CircleColaiderRights.GetComponent <CircleCollider2D>().enabled = false; //анимация бездействия не слишком часто State = CharState.stoping; if (State == CharState.stoping) { danceTime -= Time.deltaTime; } if (danceTime <= 0) { State = CharState.dance; } CheckGround(); if (Convert.ToBoolean(CnInputManager.GetAxis("Horizontal"))) { Run(); } if (isGrounded && CnInputManager.GetButtonDown("Jump")) { Jump(); } if (CnInputManager.GetButton("Attack")) { Shoot(); } ////чтобы часто не стрелять //shotsTimeCounter -= Time.deltaTime; //фича высоко не прыгать if (gameObject.transform.position.y >= 5.500000F) { gameObject.transform.position = new Vector2(gameObject.transform.position.x, 5.500000F); } }
void ControlSprint() { if (SnakeHead.GetComponent <PhotonView>().IsMine == true) { if (PhotonNetwork.LocalPlayer.GetScore() <= 300) { speedMultiplier = 1; return; } { if (CnInputManager.GetButton("Jump")) { speedMultiplier = originalSpeedMultiplier; } else { speedMultiplier = 1; } } } }
// Update is called once per frame void FixedUpdate() { if (!isLocalPlayer) { return; } float horizontal = CnInputManager.GetAxis("Horizontal"); float vertical = CnInputManager.GetAxis("Vertical"); if (anim.GetBool("Attack") == false && anim.GetBool("Blink") == false && anim.GetBool("AttackStaff") == false && anim.GetBool("Death") == false) { if (CnInputManager.GetButton("WalkButton")) { rigidbody.rotation = Util.Turning(horizontal, vertical); } Move(horizontal, vertical); Animating(horizontal, vertical); } }
// Update is called once per frame void LateUpdate() { //check if need to rotate camera transform.position = player.transform.position + offset; if (CnInputManager.GetButton("RightRotate")) { transform.RotateAround(player.transform.position, Vector3.up, 90 * Time.deltaTime); offset = transform.position - player.transform.position; } else if (CnInputManager.GetButton("LeftRotate")) { transform.RotateAround(player.transform.position, Vector3.up * (-1), 90 * Time.deltaTime); offset = transform.position - player.transform.position; } else { transform.position = player.transform.position + offset; // offset=transform.position - player.transform.position; } }
/// <summary> /// Touchscreen update function /// </summary> private void touchUpdate() { if (this.player != null) { #region Player Movement float x = -CnInputManager.GetAxis("Horizontal"); if (x != 0f) { this.commandHandler.AddCommands(new CommandRotate(this.movement, this.movement.RotVel * x)); } float y = CnInputManager.GetAxis("Vertical"); if (y != 0f) { this.commandHandler.AddCommands(new CommandAccelerateDirectional(this.movement, this.movement.Thrust * y)); } #endregion Player Movement #region Player Shooting if (CnInputManager.GetButton("Shoot")) { this.commandHandler.AddCommands(new CommandShoot(this.weapons, 0, 1)); } #endregion Player Shooting } else { } #region Camera this.zoom.ChangeZoom(CnInputManager.GetAxisRaw("Zoom")); #endregion Camera }
private void Update() { // Track the current state of the fire button and make decisions based on the current launch force. m_AimSlider.value = m_MinLaunchForce; //at max charge, not yet fired if (m_CurrentLaunchForce >= m_MaxLaunchForce && !m_Fired) { m_CurrentLaunchForce = m_MaxLaunchForce; Fire(); } // have we pressed the fire button for the first time else if (CnInputManager.GetButtonDown(m_FireButton)) { m_Fired = false; m_CurrentLaunchForce = m_MinLaunchForce; m_ShootingAudio.clip = m_ChargingClip; m_ShootingAudio.Play(); } //Holding the fire button, not yet fired else if (CnInputManager.GetButton(m_FireButton) && !m_Fired) { m_CurrentLaunchForce += m_ChargeSpeed * Time.deltaTime; m_AimSlider.value = m_CurrentLaunchForce; } //We released the fire button, having not fired yet else if (CnInputManager.GetButtonUp(m_FireButton) && !m_Fired) { Fire(); } }
void FixedUpdate() { if (transform.position.x >= 1000) { return; } //get the forward of head; Vector2 forward = new Vector2((float)Math.Cos(transform.eulerAngles.z * Math.PI / 180), (float)Math.Sin(transform.eulerAngles.z * Math.PI / 180)); //speed up,move if (isLocalPlayer) { //change direction Vector2 dstMovement = new Vector2(CnInputManager.GetAxis("Horizontal"), CnInputManager.GetAxis("Vertical")); Vector2 tmpMovement = Vector2.Lerp(forward, dstMovement, 0.125f); float arc = (float)Math.Atan2(tmpMovement.y, tmpMovement.x); transform.rotation = Quaternion.Euler(0, 0, (float)(arc * 180.0f / Math.PI)); if (CnInputManager.GetButton("Accelerate")) { //server execute if (speedScale != 2) { CmdSetSpeedScale(2); } } else { if (speedScale != 1) { CmdSetSpeedScale(1); } } } if (speedScale == 2) { Debug.Log("speed"); } //add path for (int i = 1; i <= speedScale; i++) { path.Add((Vector2)transform.position + forward * dpf * i); } //move head transform.position = new Vector2(path [path.Count - 1].x, path [path.Count - 1].y); //move bodies int lenBody_InPath = (int)Math.Round(lenBody * FPS / speed); //how many locs length of a body in path(list); for (int i = 0; i < lstBody.Count; i++) { Vector2 tmpPosition; /********** * path.Count-1: the last loc in the path; * path.Count - 1 -lenBody_InPath: position of the second node should be (first is snake head); * Math.Min (path.Count -1 - lenBody_InPath, i * lenBody_InPath ): if path is not long enough(when the snake become long suddenly), choose the last node **********/ tmpPosition = path [path.Count - 1 - lenBody_InPath - Math.Min(path.Count - 1 - lenBody_InPath, i * lenBody_InPath)]; lstBody[i].transform.position = new Vector2(tmpPosition.x, tmpPosition.y); } //remove unnecessary path node(save another two node for future "add body") if (path.Count > (lstBody.Count + 1) * lenBody_InPath + lenBody_InPath * 2) { path.RemoveAt(0); } if (isServer) { if (defense == true && System.DateTime.Now.Ticks - timerForDefense >= 30000000) { RpcCloseDefense(); } } }
void Update() { updateCount += 1; if (updateCount > 10) { updateCount = 0; } if (jumpButtonChangeColor) { Image jumpButtonImage = jumpButton.GetComponent <Image> (); if (updateCount == 10) { jumpButtonImage.color = jumpButtonImage.color == Color.blue ? Color.white : Color.blue; // updateCount = 0; } if (CnInputManager.GetButton("Jump")) { Time.timeScale = 1; jumpButtonChangeColor = false; jumpButtonImage.color = Color.white; } } if (rotateCameraButtonChangeColor) { Image rotateCameraImage = rotateCameraButton.GetComponent <Image> (); if (updateCount == 10) { rotateCameraImage.color = rotateCameraImage.color == Color.blue ? Color.white : Color.blue; updateCount = 0; } if (CnInputManager.GetButton("RightRotate")) { Time.timeScale = 1; rotateCameraButtonChangeColor = false; rotateCameraImage.color = Color.white; } } if (IsInGitfRoom()) { roomcarmera.enabled = true; maincamera.enabled = false; } else { roomcarmera.enabled = false; maincamera.enabled = true; } controller = GetComponent <CharacterController> (); if (gameOver) { // Ying restartButton.gameObject.SetActive(true); resumeButton.gameObject.SetActive(true); // backtomainButton.gameObject.SetActive (true); restartText.text = "Restart"; resumeText.text = "Resume"; // backtomainText.text = "Back Home"; //scoreText.text = count.ToString (); GameOver(); restart = true; PlayerController.RotateMove = false; PlayerController.Score = 0; giftScore = 0; } }