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. 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.  
  32. protected override void OnRemove(Role master)
  33. {
  34. base.OnRemove(master);
  35.  
  36. if (master.IsDie && master.IsEnemyWithPlayer())
  37. {
  38. this.CallDelay(0, () =>
  39. {
  40. Debug.Log("敌人扔掉武器触发攻击");
  41. Trigger(master);
  42. });
  43. }
  44. }
  45. }