ArtTaskChild.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using ShadowStudio.Model;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using XRTool.Util;
  6. using static ArtTaskAction;
  7. using static ArtTaskInfo;
  8. public class ArtTaskChild : MonoBehaviour
  9. {
  10. public TaskType ttype;
  11. public ArtContainerHandler artContainerHandler;
  12. private void OnDestroy()
  13. {
  14. ArtTaskInfo.removeChild(this);
  15. }
  16. private void Start()
  17. {
  18. ArtTaskInfo.addChild(this);
  19. }
  20. // Update is called once per frame
  21. void Update()
  22. {
  23. checkPos();
  24. }
  25. public bool isFinish;
  26. void checkPos()
  27. {
  28. if(!isFinish&& !CommonMethod.isLookRoom())
  29. {
  30. List<ArtTaskAction> ata = ArtTaskInfo.getTaskList();
  31. for (int i = 0; i < ata.Count; i++)
  32. {
  33. GameObject TaskGame = ata[i].actionGame;
  34. ArtTaskAction taskAction = ata[i];
  35. if(ata[i].ttype==ttype)
  36. {
  37. if (taskAction.aaType == ArtActionType.ACTION)
  38. {
  39. float dic = Vector3.Distance(this.transform.position, TaskGame.transform.position);
  40. if (dic < 0.1f)
  41. {
  42. taskAction.showFinishAction(true);
  43. isFinish = true;
  44. if (artContainerHandler != null)
  45. {
  46. Debug.Log("删除Container");
  47. artContainerHandler.DelArtSync();
  48. }
  49. }
  50. }
  51. }
  52. else
  53. {
  54. if (taskAction.aaType == ArtActionType.ACTION)
  55. {
  56. float dic = Vector3.Distance(this.transform.position, TaskGame.transform.position);
  57. if (dic < 0.1f)
  58. {
  59. taskAction.ShowTipError();
  60. isFinish = true;
  61. if (artContainerHandler != null)
  62. {
  63. Debug.Log("删除Container");
  64. artContainerHandler.DelArtSync();
  65. }
  66. }
  67. }
  68. }
  69. }
  70. }
  71. }
  72. }