public void Fire(Transform firePosition) { if (currentState != WeaponState.Idle || shotTimer > 0 || reloadTimer > 0) { return; } // 子弹数量不足不能开火 if (currentBulletClipNumer - 1 < 0) { return; } shotTimer = shotRate; currentState = WeaponState.Firing; // 播放开火动画 animator.SetTrigger("fire"); animator.SetBool("idle", false); //Debug.Log("开火"); // 播放开火音乐 source.pitch = Random.Range(0.7f, 1.0f); source.PlayOneShot(FireAudioClip); // 相机震动 CameraShaker.Instance.Shake(0.2f, 0.05f * 0.6f); // 发射子弹 GameObject bullet = Director.GetInstance().CurrentBulletFactory.GetBullet(firePosition, BulletOwner.Player, Director.GetInstance().CurrentWeaponsManager.CurrentWeaponType); if (Director.GetInstance().CurrentWeaponsManager.CurrentWeaponType == WeaponType.Normal) { bullet.GetComponent <Bullet>().hurt = ATK; } currentBulletClipNumer--; weaponsManager.ChangeWeaponBulletClip(currentBulletClipNumer, singleBulletClipNumer); }
private void Start() { weaponsManager = Director.GetInstance().CurrentWeaponsManager; weaponsManager.ChangeWeaponBulletClip(currentBulletClipNumer, singleBulletClipNumer); }