Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / activity / weapon / gun / Gun.cs
@小李xl 小李xl on 14 Jun 2023 915 bytes 完善武器音效
  1. using Godot;
  2.  
  3. /// <summary>
  4. /// 普通的枪
  5. /// </summary>
  6. [Tool, GlobalClass]
  7. public partial class Gun : Weapon
  8. {
  9. protected override void OnFire()
  10. {
  11. //创建一个弹壳
  12. ThrowShell(ActivityObject.Ids.Id_shell0001);
  13.  
  14. if (Master == Player.Current)
  15. {
  16. //创建抖动
  17. GameCamera.Main.DirectionalShake(Vector2.Right.Rotated(GlobalRotation) * 2f);
  18. }
  19.  
  20. //创建开火特效
  21. var packedScene = ResourceManager.Load<PackedScene>(ResourcePath.prefab_effect_ShotFire_tscn);
  22. var sprite = packedScene.Instantiate<Sprite2D>();
  23. sprite.GlobalPosition = FirePoint.GlobalPosition;
  24. sprite.GlobalRotation = FirePoint.GlobalRotation;
  25. sprite.AddToActivityRoot(RoomLayerEnum.YSortLayer);
  26. }
  27.  
  28. protected override void OnShoot(float fireRotation)
  29. {
  30. ShootBullet(fireRotation, Attribute.BulletId);
  31. }
  32. }