コード例 #1
0
        private void FixedUpdate()
        {
            _autoRunMovement.enabled = _autoRun;
            if (_autoRun)
            {
                return;
            }

            float x = Input.GetAxis("Horizontal");

            _movement.Move(x, _isJump, IsChangeDirection(x));
            _isJump = false;
        }
コード例 #2
0
ファイル: Player.cs プロジェクト: Erox7/Erox-Adventure
 // 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;
 }
コード例 #3
0
        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();
            }
        }