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