// Update is called once per frame void Update() { if (thePlayer == null) { thePlayer = FindObjectOfType <PlayerController> (); } //if (dialogActive && Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) { if (dialogActive && CnInputManager.GetButtonUp("Fire1")) { PlayerController.isTalking = true; //dBox.SetActive (false); //dialogActive = false; currentLine++; } if (currentLine >= dialogLines.Length) { dBox.SetActive(false); dialogActive = false; currentLine = 0; mcontroller.SwitchTrack(bgmtracks [questId]); mcontroller.musicCanPlay = true; thePlayer.canMove = true; PlayerController.isTalking = false; if (questId == 0) { GameObject.Find("door1").SetActive(false); } else if (questId == 1) { GameObject.Find("door6").SetActive(false); } } dText.text = dialogLines [currentLine]; }
// 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 Update() { if (!isActive || !hasInputted || !readNextLine) { return; } if (CnInputManager.GetButtonUp("Jump")) { if (!isTyping) { startFromLine++; if (startFromLine == endAtLine) { arrow.enabled = false; } if (startFromLine > endAtLine) { DisableTextBox(); } else { StartCoroutine(TextScroll(textLines[startFromLine])); } } else if (isTyping && !cancelTyping) { cancelTyping = true; } } }
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; } }
// Выстрел public void Schoot() { if (Input.GetKeyDown(KeyCode.Space) || CnInputManager.GetButtonUp("bombButton")) { bool clone = false; if (allBombInMap.Count > 0) { // Проверяем а есть ли у нас еще бомбы, и не установили ли мы уже бомбу здесь: for (int i = 0; i < allBombInMap.Count; i++) { Bomb next = allBombInMap[i]; if (next.bombPoint.pointPosition == aStar.Vector3toVector3i(this.lostPoint)) { clone = true; } } } if (!clone && allBombInMap.Count < bombLimit) { // Отлично создаем новую бомбу: GameObject clone_Bomb = (GameObject)Instantiate(BombPrefab, lostPoint, Quaternion.identity); Bomb bomb = clone_Bomb.GetComponent <Bomb>(); bomb.bombPoint = aStar.mapPointDictionary[aStar.Vector3toVector3i(this.lostPoint)]; // Реализуем возможность управлять взрывной силой через бонусы: bomb.power_strenght = powerPomb; allBombInMap.Add(bomb); } } }
public override bool IsActionUp(string action) { foreach (var i in inputsMap) { if (i.action == action) { #if UP_USE_CN_INPUT_MANAGER if (SystemInfo.deviceType == DeviceType.Handheld) { return(CnInputManager.GetButtonUp(i.handheld)); } #endif #if UP_USE_WII_INPUT_MANAGER if (remote != null) { return(!GetWiiButton(i.wii)); } #endif return(Input.GetButtonUp(i.keyboard)); } } Debug.LogWarning("Cannot find action: " + action); return(false); }
private void Update() { if (CnInputManager.GetButtonUp("Jump")) { NextTutorial(); } }
// Update is called once per frame void Update() { if (CnInputManager.GetButtonUp("MenuOpen")) { OpenMenu(); } }
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 (level_time > 0) { level_time -= Time.deltaTime; level_time_info.text = level_time.ToString(); } else { // Тут выпускаем гончих: for (int i = 0; i < Map.Instance.extra_enemy_in_map_count; i++) { Map.Instance.createEnemyToMap(1); } // Пусть и не из оригинала но ставим таймер снова level_time = Map.Instance.level_time; } // Выполняем любой код только если игрок жив switch (state) { case playerState.live: // Остальные методы: rotate(); move(nextPosition); if (islocalPlayer) { Schoot(); // Обрабатываем движение вперед: if ((Input.GetAxis("Vertical") > 0) & (!IsMoving) || (CnInputManager.GetButtonUp("moveButton") && (!IsMoving))) { IsMoving = true; nextPosition = getNextPosition(aStar.mapPointDictionary); } } break; case playerState.destroy: // Проигрываем последнюю анимацию: destroy(); state = playerState.off; break; case playerState.off: StartCoroutine(looses()); break; case playerState.win: StartCoroutine(wines()); // Играем победную анимацию: winn(); break; } }
void Update() { if (waitForPress && CnInputManager.GetButtonUp("Jump")) { GameManager.instance.AllowPlayerMovement(false); startPrintingText(); waitForPress = false; } }
void Move() { CorectROT(); position = new Vector3(CnInputManager.GetAxis("Horizontal"), 0f, 0f); if (position.x > 0) { if (CnInputManager.GetButtonDown("Run")) { speed = run; Debug.Log(run); } else { // transform.rotation = Quaternion.Euler(0, 0, 0); speed = memor_speed; Debug.Log(memor_speed); } gameG.SetFloat("MoveX", position.x, 0.1f, Time.deltaTime); RandL = true; gameG.SetBool("RandL", RandL); } else if (position.x < 0) { if (CnInputManager.GetButtonDown("Run")) { speed = run; Debug.Log(run); } else { speed = memor_speed; Debug.Log(memor_speed); } gameG.SetFloat("MoveX", position.x, 0.1f, Time.deltaTime); RandL = false; gameG.SetBool("RandL", RandL); } else if (position.x == 0) { gameG.SetFloat("MoveX", position.x, 0.1f, Time.deltaTime); } if (CnInputManager.GetButtonUp("Jump") && isJump) { gameG.ResetTrigger("idle"); gameG.SetTrigger("Jump"); GetComponent <Rigidbody2D>().AddForce(new Vector2(0f, Jump), ForceMode2D.Impulse); } }
// 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; } }
// Update is called once per frame void Update() { if (CnInputManager.GetButtonDown(gameObject.name)) { transform.localScale = new Vector3(transform.localScale.x - size_del, transform.localScale.y - size_del); } if (CnInputManager.GetButtonUp(gameObject.name)) { transform.localScale = new Vector3(transform.localScale.x + size_del, transform.localScale.y + size_del); } }
void Update() { if (CnInputManager.GetButtonUp("Fire2")) { PauseGame(true); } if (CnInputManager.GetButtonUp("Fire3")) { SettingsManager.instance.OpenSettings(true); } }
// Update is called once per frame void Update() { if (CnInputManager.GetButtonUp("Potion")) { if (CurrentPotion > 0) { CurrentPotion--; int healammount = Mathf.RoundToInt((Player.GetComponent <PlayerHealthManager> ().playerHealthMax *HealMultiplier)); Player.GetComponent <PlayerHealthManager> ().HealPlayer(healammount); UpdatePotion(); } } }
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 OnTriggerStay2D(Collider2D other) { PlayerController.isTalking = true; if (other.gameObject.tag == "Player") { if (CnInputManager.GetButtonUp("Fire1") && dMan.dialogActive == false) { dMan.currentLine = 0; dMan.dialogLines = myDialogLines; dMan.ShowDialog(questId); gameObject.SetActive(false); } } }
// Поворот Игрока на угол: // округление углов void angler() { //Это вращение платформы кнопками. //------------------------------------------------------------Вращение базы влево--------------------------------------- if (Input.GetKeyUp(KeyCode.A) || CnInputManager.GetButtonUp("leftButton")) { baseToLeft(); } //---------------------------------------------------------------Вращение базы вправо------------------------------------ if (Input.GetKeyUp(KeyCode.D) || CnInputManager.GetButtonUp("rightButton")) { baseToRight(); } }
void Update() { if (!itsMe) { return; } int index = -1; if (CnInputManager.GetButtonDown("Smile")) { index = 1; } else if (CnInputManager.GetButtonDown("Bad")) { index = 2; } else if (CnInputManager.GetButtonDown("Angry")) { index = 3; } if (CnInputManager.GetButtonUp("Smile") || CnInputManager.GetButtonUp("Bad") || CnInputManager.GetButtonUp("Angry")) { index = 0; } if (index != -1) { if (index == 0) { NetworkController.instance.SendChangeFace("default@unitychan", 0); } else if (index == 1) { NetworkController.instance.SendChangeFace("smile1@unitychan", 1); } else if (index == 2) { NetworkController.instance.SendChangeFace("disstract1@unitychan", 1); } else if (index == 3) { NetworkController.instance.SendChangeFace("angry2@unitychan", 1); } } }
// Update is called once per frames void Update() { if (CnInputManager.GetButtonUp("MenuClose")) { OpenMenu(); } if (CnInputManager.GetButtonUp("Exit")) { Application.Quit(); Debug.Log("quit"); } if (CnInputManager.GetButtonUp("New Game")) { Debug.Log("New game"); } }
public bool GetKeyUp(myKeyCode keyCode) { switch (keyCode) { case myKeyCode.Attack: return(CnInputManager.GetButtonUp(attackButton.ButtonName) || Input.GetKeyUp(attackKeyCode)); case myKeyCode.Jump: return(CnInputManager.GetButtonUp(jumpButton.ButtonName) || Input.GetKeyUp(jumpKeyCode)); case myKeyCode.Skill1: return(CnInputManager.GetButtonUp(skill1Button.ButtonName) || Input.GetKeyUp(skill1KeyCode)); case myKeyCode.Skill2: return(CnInputManager.GetButtonUp(skill2Button.ButtonName) || Input.GetKeyUp(skill2KeyCode)); } return(false); }
void Attack() { if (CnInputManager.GetButtonUp("Attack")) { CorectRandL(); gameObject.GetComponent <Animator>().SetTrigger("attack"); //if (isJump) //{ // gameObject.GetComponent<Animator>().SetTrigger("idle"); //} //else //{ // gameObject.GetComponent<Animator>().SetTrigger("Jump"); // gameObject.GetComponent<Animator>().ResetTrigger("idle"); //} } }
void Update() { if (CnInputManager.GetButtonUp("Shoot") || Input.GetButtonUp("Shoot")) { shooting = false; } if (shooting && shot >= 0.1f) { Instantiate(SpawnObj, transform.position, transform.rotation); shot = 0; AudioSource.PlayClipAtPoint(laserSound, transform.position); } shot += Time.deltaTime; transform.LookAt(boss); if (CnInputManager.GetButtonDown("Shoot") || Input.GetButtonDown("Shoot")) { shooting = true; } }
// Update is called once per frame void FixedUpdate() { position = new Vector3(CnInputManager.GetAxis("Horizontal"), CnInputManager.GetAxis("Vertical"), 0f); transform.position += position * Time.deltaTime * 5; if (position.x < 0) { transform.rotation = Quaternion.Euler(0, 180, 0); } else { transform.rotation = Quaternion.Euler(0, 0, 0); } if (CnInputManager.GetButtonUp("Jump")) { GetComponent <Rigidbody2D>().AddForce(new Vector2(0f, 5f), ForceMode2D.Impulse); } }
void FixedUpdate() { position = new Vector3(CnInputManager.GetAxis("Horizontal"), CnInputManager.GetAxis("Vertical"), 0f); transform.position += position * Time.deltaTime * 4; if (position.x < 0) { transform.rotation = Quaternion.Euler(0, 180, 0); } else { transform.rotation = Quaternion.Euler(0, 0, 0); } if (CnInputManager.GetButtonUp("Jump")) { Instantiate(dan, transform.position, Quaternion.identity); GetComponent <AudioSource>().clip = audioClip[clip]; GetComponent <AudioSource> ().Play(); } }
protected override Vector2 GetExpectedVelocity() { //todo: разобраться, почему не всегда срабатывает прыжок //todo: возможно стоит перенести рассчет expectedVelocity в Update() и хранить в поле, здесь только возвращать Vector2 expectedVelocity = base.GetExpectedVelocity(); expectedVelocity.x = walkingSpeed * CnInputManager.GetAxisRaw("Horizontal"); if (CnInputManager.GetButtonDown("Jump") && Grounded) { expectedVelocity.y = jumpTakeOffSpeed; } else if (CnInputManager.GetButtonUp("Jump")) { if (VelocityCurrent.y > 0) { expectedVelocity.y = VelocityCurrent.y * 0.5f; } } return(expectedVelocity); //move * maxSpeed; }
private void Update() { CheckGround(); if (isGrounded) { State = CharState.Idle; } if (CnInputManager.GetAxis("Horizontal") != 0) { Run(); } if (isGrounded && CnInputManager.GetButtonUp("Jump")) { Jump(); } if (Input.GetKeyDown(KeyCode.Escape)) { SceneManager.LoadScene("menu"); } }
// Update is called once per frame void Update() { if (CnInputManager.GetButtonUp("RestartLevel")) { Time.timeScale = 1.0f; SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); } if (CnInputManager.GetButtonUp("CloseWeaponsList")) { WeaponLists.SetActive(false); } if (CnInputManager.GetButtonUp("OpenWeaponsList")) { WeaponLists.SetActive(true); } if (CnInputManager.GetButtonUp("ReturnToMenu")) { Time.timeScale = 1.0f; SceneManager.LoadScene("mainMenu"); } }
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(); } }