Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / activity / prop / PropActivity.cs
  1. using Godot;
  2.  
  3. /// <summary>
  4. /// 道具基类
  5. /// </summary>
  6. public abstract partial class PropActivity : ActivityObject
  7. {
  8. /// <summary>
  9. /// 道具所属角色
  10. /// </summary>
  11. public Role Master { get; set; }
  12.  
  13. /// <summary>
  14. /// 当道具被拾起时调用 (在 Master 赋值之后调用)
  15. /// </summary>
  16. public abstract void OnPickUpItem();
  17.  
  18. /// <summary>
  19. /// 当道具被移除时调用 (在 Master 置为 null 之前调用)
  20. /// </summary>
  21. public abstract void OnRemoveItem();
  22.  
  23. public override void OnInit()
  24. {
  25. ThrowCollisionMask = PhysicsLayer.Wall;
  26. }
  27.  
  28. /// <summary>
  29. /// 触发扔掉道具效果, 并不会管道具是否在道具背包中
  30. /// </summary>
  31. /// <param name="master">触发扔掉该道具的的角色</param>
  32. public void ThrowProp(Role master)
  33. {
  34. ThrowProp(master, master.GlobalPosition);
  35. }
  36. /// <summary>
  37. /// 触发扔掉道具效果, 并不会管道具是否在道具背包中
  38. /// </summary>
  39. /// <param name="master">触发扔掉该道具的的角色</param>
  40. /// <param name="startPosition">投抛起始位置</param>
  41. public void ThrowProp(Role master, Vector2 startPosition)
  42. {
  43. //阴影偏移
  44. ShadowOffset = new Vector2(0, 2);
  45. GlobalRotation = 0;
  46. var startHeight = 8;
  47. Throw(startPosition, startHeight, 0, Vector2.Zero, 0);
  48.  
  49. //继承role的移动速度
  50. InheritVelocity(master);
  51. }
  52. }