private void FixedUpdate() { _autoRunMovement.enabled = _autoRun; if (_autoRun) { return; } float x = Input.GetAxis("Horizontal"); _movement.Move(x, _isJump, IsChangeDirection(x)); _isJump = false; }
// Start is called before the first frame update void Start() { gl = MapController.currentMap.GetComponent <GridLayout>(); transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z); playerMovement = new PlayerMovement(transform, GetComponent <Animator>()); playerMovement.SetPlayerSpeed(player.speed); playerMovement.SetActualSpeed(player.speed); playerMovement.SetRunningSpeed(player.runningSpeed); playerAttack = new PlayerAttack(transform, GetComponent <Animator>(), player.fireManaCost, player.waterManaCost, player.windManaCost, player.rockManaCost); new WaitForEndOfFrame(); hp = player.hp; StartCoroutine(playerMovement.Move()); StartCoroutine(playerAttack.AttackAnimation()); EnemyEventsManager.Instance.onMakeDamage += TakeDamage; GlobalEventManager.Instance.onMapChanged += UpdateGrid; }
private void Update() { if (IsPaused) { return; } Vector2 mousePos = new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y); Vector3 playerPos = cam.WorldToScreenPoint(player.position); float diff = mousePos.x - playerPos.x; if (Mathf.Abs(diff) > mouseDeadZone) { movement.Move(Mathf.Clamp(diff / (mouseDeadZone * speedModifier), -speedClamp, speedClamp)); } if (Mathf.Abs(Input.GetAxisRaw("Jump")) > float.Epsilon) { if (!isJumpDown) { isJumpDown = true; movement.Jump(); } } else { isJumpDown = false; } if (Mathf.Abs(Input.GetAxisRaw("Slide")) > float.Epsilon) { movement.Slide(); } if (Mathf.Abs(Input.GetAxisRaw("Shoot")) > float.Epsilon) { combat.Shoot(); } }