Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / item / weapon / RegisterWeapon.cs
@lijincheng lijincheng on 6 Mar 2023 603 bytes 小修改
  1.  
  2. using System;
  3.  
  4. /// <summary>
  5. /// 注册武器
  6. /// </summary>
  7. public class RegisterWeapon : RegisterActivity
  8. {
  9. public WeaponAttribute WeaponAttribute { get; }
  10. public RegisterWeapon(string id, Type attribute) : base(id, null)
  11. {
  12. WeaponAttribute = (WeaponAttribute)Activator.CreateInstance(attribute);
  13. if (WeaponAttribute != null) PrefabPath = WeaponAttribute.WeaponPrefab;
  14. }
  15.  
  16. public override void CustomHandler(ActivityObject instance)
  17. {
  18. if (instance is Weapon weapon)
  19. {
  20. weapon.InitWeapon(WeaponAttribute.Clone());
  21. }
  22. }
  23. }