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