// ダッシュの初期化 public void StartDash() { if (_timer == 0) { SoundManager.Instance.PlaySe("Dash Light Armor 2_04"); FindObjectOfType <RippleEffect>().Emit(Camera.main.WorldToViewportPoint(_sprite.position)); _timer = _dashTime; _dashParticle.Play(); if (_gamepad == null) { _gamepad = GetComponent <BetterPlayerControl>().GetGamepad(); } // 一定の角度にダッシュできる if (_sprite.transform.eulerAngles.y == 180.0f) { _stickVelocity = new Vector2(-1.0f, _gamepad.GetStickL().Y / 2.0f); } else { _stickVelocity = new Vector2(1.0f, _gamepad.GetStickL().Y / 2.0f); } _isDashing = true; // ジャンプダッシュはエフェクト残像を生成しない if (_jumpState.GetIsGrounded()) { SpawnClone(); } } }
// 更新 void Update() { if (_controllerIndex == 0) { return; } _gamepad = GamePadManager.Instance.GetGamepad(_controllerIndex); if (_gamepad == null || !_gamepad.IsConnected) { return; } // 入力の値を渡す _character.MoveInput = new Vector2(_gamepad.GetStickL().X, _gamepad.GetStickL().Y); if (_character.EnableTurn) { if (_gamepad.GetStickL().X < -0.01f) { _sprite.transform.localRotation = Quaternion.Euler(0f, 180f, 0f); } else if (_gamepad.GetStickL().X > 0.01f) { _sprite.transform.localRotation = Quaternion.Euler(0f, 0, 0f); } } // 強攻撃 if (_gamepad.GetButtonDown("Y") && _character.EnableAttack) { if (_animator.GetCurrentAnimatorStateInfo(0).IsTag("Last")) { return; } if (_animator.GetCurrentAnimatorStateInfo(0).IsName("Player_Dash")) { _dasher.StopDash(); } if (_heaith.HP < 0) { if (_heaith.transform.parent.TryGetComponent(out BetterPlayerControl _better)) { _better.Resurrect.SetHeal(); pushCount++; if (pushCount >= 5) { _heaith._hp = _better.Resurrect.GetHeal(); _better.Resurrect.gameObject.SetActive(false); _better.Revive(); pushCount = 0; _better.Resurrect.ResetHeel(); } } } else { _animator.SetTrigger("Attack"); if (_jumpStatus.GetIsGrounded()) { _character.EnableMove = false; } } } // ジャンプ if (_gamepad.GetButtonDown("A")) { if (_animator.GetCurrentAnimatorStateInfo(0).IsName("Player_Attack_Air3_End")) { return; } if (_animator.GetCurrentAnimatorStateInfo(0).IsName("Player_Die")) { return; } if (_dasher.IsDashing) { _animator.SetTrigger("JumpAttack"); _dasher.StopDash(); } _animator.SetBool("IsJumping", true); _jumpStatus.StartJump(); _character.EnableAttack = true; if (_heaith != null) { pushCount = 0; if (_heaith.HP < 0) { if (_resurrection != null) { _resurrection.ResetHeel(); } } } } // ダッシュ if (_gamepad.GetButtonDown("B")) { if (_animator.GetCurrentAnimatorStateInfo(0).IsName("Player_Die")) { return; } _dasher.StartDash(); _character.EnableMove = false; _character.EnableTurn = false; _character.EnableAttack = true; } // 弱攻撃 if (_gamepad.GetButtonDown("X")) { if (_animator.GetCurrentAnimatorStateInfo(0).IsTag("Last")) { return; } if (_animator.GetCurrentAnimatorStateInfo(0).IsName("Player_Dash")) { _dasher.StopDash(); } _animator.SetTrigger("Punch"); if (_jumpStatus.GetIsGrounded()) { _character.EnableMove = false; } } // 残像攻撃(技) if (_gamepad.GetButtonDown("RB")) { _skillManager.StartSkill(); } // 死ぬ制御 var health = _sprite.GetComponent <Health>(); if (health.HP <= 0) { _resurrection.gameObject.SetActive(true); _character.IsDie = true; } // 足元のエフェクトの制御 if (_character.EnableMove && _jumpStatus.GetIsGrounded()) { float movingSpeed = Mathf.Abs(_gamepad.GetStickL().X) + Mathf.Abs(_gamepad.GetStickL().Y); _dustEmission.rateOverTime = _dustOverRate * Mathf.Clamp01(movingSpeed); } else { _dustEmission.rateOverTime = 0.0f; } }