DressUpRemoveOperation.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using UnityEngine;
  2. using YooAsset;
  3. using static FairyGUI.ControllerAction;
  4. namespace GFGGame
  5. {
  6. public class DressUpRemoveOperation : DressUpOperationBase
  7. {
  8. internal int itemID;
  9. internal GameObject parentObj;
  10. public DressUpRemoveOperation(int itemID, GameObject parentObj)
  11. {
  12. this.itemID = itemID;
  13. this.parentObj = parentObj;
  14. Debug.Log($"remove init {itemID}");
  15. }
  16. internal override void Release()
  17. {
  18. this.parentObj = null;
  19. }
  20. internal override void Start()
  21. {
  22. Status = EOperationStatus.Succeed;
  23. }
  24. internal override void Update()
  25. {
  26. }
  27. internal override void Cancel()
  28. {
  29. Status = EOperationStatus.Failed;
  30. Error = "User cancel.";
  31. }
  32. internal override bool CheckRepeated(DressUpOperationBase t)
  33. {
  34. DressUpLayerOperation layerOperation = t as DressUpLayerOperation;
  35. if (layerOperation != null && layerOperation.actionType == DressUpLayerOperation.EAction.Layer)
  36. {
  37. return (this.itemID == layerOperation.itemCfg.id
  38. && this.parentObj == layerOperation.parentObj);
  39. }
  40. var removeOperation = t as DressUpRemoveOperation;
  41. return (removeOperation != null
  42. && removeOperation.itemID == this.itemID
  43. && removeOperation.parentObj == this.parentObj);
  44. }
  45. internal override void UpdateView()
  46. {
  47. if(parentObj == null)
  48. {
  49. this.Release();
  50. return;
  51. }
  52. Debug.Log($"remove UpdateView {itemID}");
  53. DressUpUtil.RemoveItem(this.itemID, this.parentObj);
  54. }
  55. }
  56. }