Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / activity / weapon / gun / Gun.cs
@小李xl 小李xl on 29 Oct 2023 1 KB 激光武器,开发中
  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. //ShootLaser(fireRotation);
  31. }
  32.  
  33. // //测试用, 敌人被消灭时触发手上武器开火
  34. // protected override void OnRemove(Role master)
  35. // {
  36. // base.OnRemove(master);
  37. //
  38. // if (master.IsDie && master.IsEnemyWithPlayer())
  39. // {
  40. // this.CallDelay(0, () =>
  41. // {
  42. // Debug.Log("敌人扔掉武器触发攻击");
  43. // Trigger(master);
  44. // });
  45. // }
  46. // }
  47. }