IT_FaultToolList.cs 3.9 KB

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