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 effect = ObjectManager.GetPoolItem<IEffect>(Attribute.FireEffect);
  21. var sprite = (Node2D)effect;
  22. // sprite.GlobalPosition = FirePoint.GlobalPosition;
  23. // sprite.GlobalRotation = FirePoint.GlobalRotation;
  24. // sprite.AddToActivityRoot(RoomLayerEnum.YSortLayer);
  25. sprite.Position = GetLocalFirePosition();
  26. AddChild(sprite);
  27. effect.PlayEffect();
  28. }
  29. }
  30.  
  31. protected override void OnShoot(float fireRotation)
  32. {
  33. FireManager.ShootBullet(this, fireRotation, Attribute.Bullet);
  34. }
  35.  
  36. // //测试用, 敌人被消灭时触发手上武器开火
  37. // protected override void OnRemove(Role master)
  38. // {
  39. // base.OnRemove(master);
  40. //
  41. // if (master.IsDie && master.IsEnemyWithPlayer())
  42. // {
  43. // this.CallDelay(0, () =>
  44. // {
  45. // Debug.Log("敌人扔掉武器触发攻击");
  46. // Trigger(master);
  47. // });
  48. // }
  49. // }
  50. }