Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / activity / weapon / gun / Gun.cs
@小李xl 小李xl on 19 Sep 2023 939 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) * Attribute.CameraShake);
  15. }
  16.  
  17. //创建开火特效
  18. var packedScene = ResourceManager.Load<PackedScene>(ResourcePath.prefab_effect_weapon_ShotFire_tscn);
  19. var sprite = packedScene.Instantiate<AutoDestroySprite>();
  20. // sprite.GlobalPosition = FirePoint.GlobalPosition;
  21. // sprite.GlobalRotation = FirePoint.GlobalRotation;
  22. // sprite.AddToActivityRoot(RoomLayerEnum.YSortLayer);
  23. sprite.Position = GetLocalFirePosition();
  24. AddChild(sprite);
  25. }
  26.  
  27. protected override void OnShoot(float fireRotation)
  28. {
  29. ShootBullet(fireRotation, Attribute.BulletId);
  30. }
  31. }