Net_FaultToolList.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using GameFramework.Event;
  5. using UnityEngine;
  6. public class Net_FaultToolList : MonoBehaviour
  7. {
  8. private GameObject hand;
  9. private GameObject handWithGloves;
  10. private GameObject gloves;
  11. private GameObject screwdriver;
  12. private GameObject chassisCover;
  13. private GameObject netWordCard;
  14. private GameObject lightModel;
  15. private GameObject opticalFiber;
  16. private void Awake()
  17. {
  18. hand = this.transform.Find("hand").gameObject;
  19. handWithGloves = this.transform.Find("handWithGloves").gameObject;
  20. gloves = this.transform.Find("gloves").gameObject;
  21. screwdriver = this.transform.Find("screwdriver").gameObject;
  22. chassisCover = this.transform.Find("chassisCover").gameObject;
  23. netWordCard = this.transform.Find("netWordCard").gameObject;
  24. lightModel = this.transform.Find("lightModel").gameObject;
  25. opticalFiber = this.transform.Find("opticalFiber").gameObject;
  26. ReSetToolList(0);
  27. }
  28. private void Start()
  29. {
  30. GameMain.Event.Subscribe(UI_ItemMoveDoneEvent.EventId, OnGetUI_ItemMoveDone);
  31. }
  32. private void OnDestroy()
  33. {
  34. if (GameMain.Event.Check(UI_ItemMoveDoneEvent.EventId, OnGetUI_ItemMoveDone))
  35. {
  36. GameMain.Event.Unsubscribe(UI_ItemMoveDoneEvent.EventId, OnGetUI_ItemMoveDone);
  37. }
  38. }
  39. //初始化隐藏 戴手套的手、机箱盖
  40. public void ReSetToolList(int type)
  41. {
  42. hand.SetActive(true);
  43. handWithGloves.SetActive(false);
  44. gloves.SetActive(true);
  45. screwdriver.SetActive(true);
  46. chassisCover.SetActive(false);
  47. netWordCard.SetActive(false);
  48. lightModel.SetActive(false);
  49. opticalFiber.SetActive(false);
  50. }
  51. public void ShowChassisCover()
  52. {
  53. chassisCover.SetActive(true);
  54. }
  55. public void ShowNetWordCard()
  56. {
  57. netWordCard.SetActive(true);
  58. }
  59. public void ShowLightModel()
  60. {
  61. lightModel.SetActive(true);
  62. }
  63. public void ShowOpticalFiber()
  64. {
  65. opticalFiber.SetActive(true);
  66. }
  67. private void OnGetUI_ItemMoveDone(object sender,GameEventArgs e)
  68. {
  69. UI_ItemMoveDoneEvent args = (UI_ItemMoveDoneEvent)e;
  70. //合成戴手套的手
  71. bool getHandWithGloves = false;
  72. if (args.item_1 == UI_TriggerItemType.hand)
  73. {
  74. if (args.item_2 == UI_TriggerItemType.gloves)
  75. {
  76. getHandWithGloves = true;
  77. }
  78. }
  79. else if(args.item_2 == UI_TriggerItemType.hand)
  80. {
  81. if (args.item_1 == UI_TriggerItemType.gloves)
  82. {
  83. getHandWithGloves = true;
  84. }
  85. }
  86. if (getHandWithGloves)
  87. {
  88. hand.SetActive(false);
  89. handWithGloves.SetActive(true);
  90. gloves.SetActive(false);
  91. return;
  92. }
  93. //拆掉机箱盖
  94. bool getChassisCover = false;
  95. if (args.item_1 == UI_TriggerItemType.handWithGloves)
  96. {
  97. if (args.item_2 == UI_TriggerItemType.chassisCover)
  98. {
  99. getChassisCover = true;
  100. }
  101. }
  102. else if (args.item_2 == UI_TriggerItemType.handWithGloves)
  103. {
  104. if (args.item_1 == UI_TriggerItemType.chassisCover)
  105. {
  106. getChassisCover = true;
  107. }
  108. }
  109. if (getChassisCover)
  110. {
  111. chassisCover.SetActive(true);
  112. }
  113. }
  114. }