Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / activity / weapon / gun / Gun.cs
  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. if (!string.IsNullOrEmpty(Attribute.FireEffect))
  19. {
  20. var packedScene = ResourceManager.Load<PackedScene>(Attribute.FireEffect);
  21. var sprite = packedScene.Instantiate<AutoDestroySprite>();
  22. // sprite.GlobalPosition = FirePoint.GlobalPosition;
  23. // sprite.GlobalRotation = FirePoint.GlobalRotation;
  24. // sprite.AddToActivityRoot(RoomLayerEnum.YSortLayer);
  25. sprite.Position = GetLocalFirePosition();
  26. AddChild(sprite);
  27. }
  28. }
  29.  
  30. protected override void OnShoot(float fireRotation)
  31. {
  32. ShootBullet(fireRotation, Attribute.Bullet);
  33. }
  34.  
  35. // //测试用, 敌人被消灭时触发手上武器开火
  36. // protected override void OnRemove(Role master)
  37. // {
  38. // base.OnRemove(master);
  39. //
  40. // if (master.IsDie && master.IsEnemyWithPlayer())
  41. // {
  42. // this.CallDelay(0, () =>
  43. // {
  44. // Debug.Log("敌人扔掉武器触发攻击");
  45. // Trigger(master);
  46. // });
  47. // }
  48. // }
  49. }