GoodsContainer.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. using ShadowStudio.Tool;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. using XRTool.Util;
  7. namespace ShadowStudio.Model
  8. {
  9. /// <summary>
  10. ///
  11. /// </summary>
  12. public class GoodsContainer : ArtContainerHandler
  13. {
  14. private TransferCell transfer;
  15. public virtual void Start()
  16. {
  17. if (Transfer)
  18. {
  19. //if (!CommonMethod.isLookRoom())
  20. //{
  21. // Transfer.EditTransfer += OnEditTransfer;
  22. // //Transfer.TransferSelect += OnTransferSelect;
  23. // Transfer.ZoomTransfer += OnZoomTransfer;
  24. //}
  25. //else
  26. //{
  27. // Transfer.IsCanEditor = false;
  28. //}
  29. //Transfer.TransferStateChange += OnTransferStateChange;
  30. //Transfer.Box.ScaleStopped.AddListener(OnStopScale);
  31. //Transfer.Box.ScaleStarted.AddListener(ScaleStarted);
  32. }
  33. }
  34. /// <summary>
  35. /// 缩放事件
  36. /// </summary>
  37. /// <param name="state"></param>
  38. public virtual void OnZoomTransfer(TransferState state)
  39. {
  40. if (state == TransferState.Stop)
  41. {
  42. if (transform.localScale.x < 0)
  43. {
  44. transform.localScale = -transform.localScale;
  45. }
  46. OnEditTransfer(state);
  47. }
  48. }
  49. /// <summary>
  50. /// 当编辑了物体时
  51. /// </summary>
  52. /// <param name="state"></param>
  53. public virtual void OnEditTransfer(TransferState state)
  54. {
  55. if (state == TransferState.Stop)
  56. {
  57. OnTransferSelect(true);
  58. }
  59. else if (state == TransferState.Over)
  60. {
  61. OnTransferSelect(false);
  62. }
  63. SendTransfer(2, (int)state);
  64. }
  65. /// <summary>
  66. /// 当某物体被选中或被释放
  67. /// </summary>
  68. /// <param name="arg1"></param>
  69. /// <param name="select"></param>
  70. public virtual void OnTransferSelect(bool select)
  71. {
  72. ArtInfoMgr.Instance.SetContainerSelect(this, select);
  73. }
  74. //public virtual void OnStopScale()
  75. //{
  76. // if (transform.localScale.x < 0)
  77. // {
  78. // transform.localScale = -transform.localScale;
  79. // }
  80. //}
  81. public override TransferCell Transfer
  82. {
  83. get
  84. {
  85. if (!transfer)
  86. {
  87. transfer = GetComponent<TransferCell>();
  88. }
  89. return transfer;
  90. }
  91. }
  92. public override void ResetEditorPosition()
  93. {
  94. if (EditorRoot)
  95. {
  96. //Vector3 point = Transfer.GetCastPoint(GameSession.Instance.gameHead.position);
  97. //point.y -= 0.05f;
  98. //EditorRoot.position = point;
  99. //Vector3 forwad = point - transform.position;
  100. //forwad.y = 0;
  101. //EditorRoot.forward = -forwad;
  102. }
  103. }
  104. public override void LockContainer()
  105. {
  106. base.LockContainer();
  107. if (Transfer)
  108. {
  109. Transfer.IsLock = true;
  110. }
  111. }
  112. public override void UnLockContainer()
  113. {
  114. base.UnLockContainer();
  115. if (Transfer)
  116. {
  117. Transfer.IsLock = false;
  118. }
  119. }
  120. public override void SetSelect()
  121. {
  122. base.SetSelect();
  123. if (Transfer && !Transfer.IsLock)
  124. {
  125. Transfer.IsDragEnable = true;
  126. }
  127. }
  128. public override void UnSetSelect()
  129. {
  130. base.UnSetSelect();
  131. if (Transfer && !Transfer.IsLock)
  132. {
  133. Transfer.IsDragEnable = false;
  134. //Transfer.DisActiveCell();
  135. }
  136. }
  137. public override int AheadCount()
  138. {
  139. if (Transfer)
  140. {
  141. return Transfer.PostureAhead.Count;
  142. }
  143. return base.AheadCount();
  144. }
  145. public override int BackCount()
  146. {
  147. if (Transfer)
  148. {
  149. return Transfer.PostureBack.Count;
  150. }
  151. return base.BackCount();
  152. }
  153. public override bool GoAhead()
  154. {
  155. if (Transfer)
  156. {
  157. return Transfer.PeekAheadNode();
  158. }
  159. return base.GoAhead();
  160. }
  161. public override bool GoBack()
  162. {
  163. if (Transfer)
  164. {
  165. return Transfer.PeekBackNode();
  166. }
  167. return base.GoBack();
  168. }
  169. }
  170. }