SW 중심대학 OSS GIT 서버 박건태, 이승준, 고기완, 이준호 새로운 배포
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

402 lines
14 KiB

4 years ago
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using DG.Tweening;
  5. using UnityEngine.UI;
  6. using UnityEngineInternal;
  7. using UnityEditor;
  8. using ARLocation;
  9. using System;
  10. public class UITest : MonoBehaviour
  11. {
  12. public GameObject op;
  13. public LocationPath locationPath;
  14. List<TracingMarker> tracingMarkers = new List<TracingMarker>();
  15. public GameObject compass;
  16. public GameObject compass_1;
  17. private GameObject instantiatedOBJ;
  18. private float time = 1f;
  19. public GameObject lastPosition;
  20. public GameObject lastPosition_Mom;
  21. public GameObject[] obj_Choice;
  22. public GameObject spawnPosition;
  23. public Sprite[] icons;
  24. public GameObject arSe;
  25. public Camera arCamera;
  26. public GameObject[] navis;
  27. public GameObject arrowON;
  28. public GameObject start_Panel;
  29. public GameObject select_Panel;
  30. public Button[] main_buttons;
  31. public GameObject naviSub_Panel;
  32. public Text[] text;
  33. public GameObject[] buildings;
  34. public GameObject[] buttons;
  35. public Button select_Button;
  36. public Sprite[] select_Image;
  37. public Button naviStart_Button;
  38. public Button[] start_Point;
  39. public GameObject obj_ChoicePanel;
  40. private int building_count1 = 0;
  41. private int building_count2 = 0;
  42. private int select_count = 0;
  43. private int functions = 0;
  44. private int ID;
  45. private int delay_Time = 0;
  46. private int x,y;
  47. public void ClickMap_Button()
  48. {
  49. Tweener startTweenr = start_Panel.transform.DOMoveY(300, 1f);
  50. startTweenr.OnComplete(() => OnCompleteText());
  51. buttons[0].SetActive(true);
  52. arSe.GetComponent<Selection__1>().enabled = false;
  53. main_buttons[0].GetComponent<RectTransform>().transform.DOMoveY(-226, 0.5f);
  54. main_buttons[1].GetComponent<RectTransform>().transform.DOMoveY(-226, 0.5f);
  55. main_buttons[2].GetComponent<RectTransform>().transform.DOMoveY(-226, 0.5f);
  56. main_buttons[3].GetComponent<RectTransform>().transform.DOMoveY(-226, 0.5f);
  57. }
  58. public void OnCompleteText()
  59. {
  60. text[0].DOText("확인하실 건물을 선택하십시오!", 1f);
  61. text[1].DOText("프라임관", 1f);
  62. select_Panel.SetActive(true);
  63. }
  64. public void Notyet_Button()
  65. {
  66. Tweener objT = text[2].DOText("곧 구현될 기능입니다.", 1f);
  67. objT.OnComplete(() => NotYet());
  68. }
  69. public void NotYet()
  70. {
  71. text[2].text = "";
  72. }
  73. public void Click_FirstB(string tag)
  74. {
  75. GameObject[] gameObjects = GameObject.FindGameObjectsWithTag(tag);
  76. foreach (GameObject target in gameObjects)
  77. {
  78. GameObject.Destroy(target);
  79. compass_1.SetActive(false);
  80. }
  81. Invoke("Late1", 0.1f);
  82. if (select_count == 0)
  83. {
  84. building_count1 += 1; //count 1
  85. buildings[0].SetActive(true);
  86. arSe.GetComponent<Object_Control>().enabled = true;
  87. //instantiatedOBJ = (GameObject)Instantiate(buildings[0], spawnPosition.transform.position, spawnPosition.transform.rotation);
  88. buildings[0].GetComponent<TracingMarker>().icon = icons[4];
  89. lastPosition.GetComponent<TracingMarker>().icon = icons[5];
  90. start_Panel.transform.DOMoveY(-340, 1f);
  91. buttons[0].SetActive(true); //Exit 버튼
  92. buttons[1].SetActive(true); //UP Down 버튼
  93. compass.SetActive(true);
  94. }
  95. else if (select_count == 1) {
  96. building_count2 += 1;
  97. buildings[2].SetActive(true);
  98. buildings[2].GetComponent<TracingMarker>().icon = icons[4];
  99. buildings[0].GetComponent<TracingMarker>().icon = icons[5];
  100. buildings[1].GetComponent<TracingMarker>().icon = icons[5];
  101. buttons[0].SetActive(true);
  102. buttons[1].SetActive(true);
  103. compass.SetActive(true);
  104. start_Panel.transform.DOMoveY(-340, 1f);
  105. }
  106. else//count가 0 이 아닐때 즉 아래층을 눌렀을때.
  107. {
  108. Tweener objT = text[2].DOText("도면이 구현되지 않았습니다.", 1f);
  109. objT.OnComplete(() => NotYet());
  110. }
  111. }
  112. // 오브젝트 컨트롤 부분
  113. public void Obj_Button()
  114. {
  115. obj_ChoicePanel.transform.DOMoveX(0, 0.5f);
  116. arSe.GetComponent<Selection__1>().enabled = true;
  117. buttons[0].SetActive(true);
  118. main_buttons[0].GetComponent<RectTransform>().transform.DOMoveY(-226, 0.5f);
  119. main_buttons[1].GetComponent<RectTransform>().transform.DOMoveY(-226, 0.5f);
  120. main_buttons[2].GetComponent<RectTransform>().transform.DOMoveY(-226, 0.5f);
  121. main_buttons[3].GetComponent<RectTransform>().transform.DOMoveY(-226, 0.5f);
  122. }
  123. public void Obj_ChoiceButton()
  124. {
  125. arSe.GetComponent<Selection__1>().placePrefab = obj_Choice[0];
  126. }
  127. public void Obj_ChoiceButton1()
  128. {
  129. arSe.GetComponent<Selection__1>().placePrefab = obj_Choice[1];
  130. }
  131. public void Obj_ChoiceButton2()
  132. {
  133. arSe.GetComponent<Selection__1>().placePrefab = obj_Choice[2];
  134. }
  135. public void Obj_ChoiceButton3()
  136. {
  137. arSe.GetComponent<Selection__1>().placePrefab = obj_Choice[3];
  138. }
  139. // 모든거 다 Exit 할때
  140. public void Click_Exit()
  141. {
  142. compass_1.SetActive(false);
  143. start_Panel.transform.DOMoveY(-340, 1f);
  144. buildings[0].SetActive(false);
  145. buildings[1].SetActive(false);
  146. buildings[2].SetActive(false);
  147. //Destroy(GameObject.Find("GameObject (1)(Clone)"));
  148. buildings[1].SetActive(false);
  149. buttons[1].SetActive(false);
  150. building_count1 = 0;
  151. building_count2 = 0;
  152. arSe.GetComponent<Selection__1>().enabled = false;
  153. naviSub_Panel.transform.DOLocalMoveY(-2600, 1f);
  154. compass.SetActive(false);
  155. buttons[0].SetActive(false);
  156. arSe.GetComponent<Selection__1>().enabled = false;
  157. obj_ChoicePanel.transform.DOMoveX(-205, 0.5f);
  158. main_buttons[0].GetComponent<RectTransform>().transform.DOMoveY(160, 0.5f);
  159. main_buttons[1].GetComponent<RectTransform>().transform.DOMoveY(160, 0.5f);
  160. main_buttons[2].GetComponent<RectTransform>().transform.DOMoveY(160, 0.5f);
  161. main_buttons[3].GetComponent<RectTransform>().transform.DOMoveY(160, 0.5f);
  162. }
  163. public void Click_UpButton(string tag)
  164. {
  165. if (building_count1 == 1)
  166. {
  167. GameObject[] gameObjects = GameObject.FindGameObjectsWithTag(tag);
  168. foreach(GameObject target in gameObjects)
  169. {
  170. GameObject.Destroy(target);
  171. compass_1.SetActive(false);
  172. }
  173. Invoke("Late1", 0.1f);
  174. buildings[0].SetActive(false);
  175. buildings[1].SetActive(true);
  176. buildings[0].GetComponent<TracingMarker>().icon = icons[5];
  177. buildings[1].GetComponent<TracingMarker>().icon = icons[4];
  178. lastPosition.GetComponent<TracingMarker>().icon = icons[5];
  179. building_count1 += 1;
  180. }
  181. else if(building_count1 > 1){
  182. Tweener objT = text[2].DOText("아직 2층밖에 없습니다.", 1f);
  183. objT.OnComplete(() => NotYet());
  184. }
  185. if (building_count2 == 1)
  186. {
  187. Tweener objT = text[2].DOText("2층은 아직 없습니다.", 1f);
  188. objT.OnComplete(() => NotYet());
  189. /*GameObject[] gameObjects = GameObject.FindGameObjectsWithTag(tag);
  190. foreach (GameObject tartget in gameObjects)
  191. {
  192. GameObject.Destroy(tartget);
  193. compass_1.SetActive(false);
  194. }*/
  195. }
  196. }
  197. void Late1()
  198. {
  199. compass_1.SetActive(true);
  200. }
  201. public void Click_DownButton(string tag)
  202. {
  203. if (building_count1 == 1)
  204. {
  205. Tweener objT = text[2].DOText("내려갈 층이 없습니다.", 1f);
  206. objT.OnComplete(() => NotYet());
  207. }
  208. else if (building_count1 == 2)
  209. {
  210. GameObject[] gameObjects = GameObject.FindGameObjectsWithTag(tag);
  211. foreach (GameObject target in gameObjects)
  212. {
  213. GameObject.Destroy(target);
  214. compass_1.SetActive(false);
  215. }
  216. Invoke("Late1", 0.1f);
  217. buildings[0].SetActive(true);
  218. buildings[1].SetActive(false);
  219. buildings[0].GetComponent<TracingMarker>().icon = icons[4];
  220. buildings[1].GetComponent<TracingMarker>().icon = icons[5];
  221. lastPosition.GetComponent<TracingMarker>().icon = icons[5];
  222. building_count1 -= 1;
  223. }
  224. }
  225. public void Click_Right() //장소 선택에서 오른쪽 버튼 눌렀을때.
  226. {
  227. switch (select_count)
  228. {
  229. case 0:
  230. select_Button.GetComponent<Button>().image.sprite = select_Image[1];
  231. select_count += 1;
  232. text[1].DOText("공대", 1.5f);
  233. break;
  234. default:
  235. Tweener objT = text[2].DOText("다음 장소가 존재 하지 않습니다.", 1f);
  236. objT.OnComplete(() => NotYet());
  237. break;
  238. }
  239. }
  240. public void Click_Left() // 장소 선택 에서 왼쪽 버튼 눌렀을때.
  241. {
  242. switch (select_count)
  243. {
  244. case 1:
  245. select_Button.GetComponent<Button>().image.sprite = select_Image[0];
  246. select_count -= 1;
  247. text[1].DOText("프라임관", 1.5f);
  248. break;
  249. default:
  250. Tweener objT = text[2].DOText("이전 장소가 존재 하지 않습니다.", 1f);
  251. objT.OnComplete(() => NotYet());
  252. break;
  253. }
  254. }
  255. public void Navi_Button()
  256. {
  257. Tweener navi = naviSub_Panel.transform.DOLocalMoveY(-640, 1f);
  258. navi.OnComplete(() => naviOn());
  259. buildings[0].GetComponent<TracingMarker>().icon = icons[5];
  260. buildings[1].GetComponent<TracingMarker>().icon = icons[5];
  261. lastPosition.GetComponent<TracingMarker>().icon = icons[6];
  262. buttons[0].SetActive(true);
  263. compass_1.SetActive(false);
  264. arSe.GetComponent<Selection__1>().enabled = false;
  265. main_buttons[0].GetComponent<RectTransform>().transform.DOMoveY(-226, 0.5f);
  266. main_buttons[1].GetComponent<RectTransform>().transform.DOMoveY(-226, 0.5f);
  267. main_buttons[2].GetComponent<RectTransform>().transform.DOMoveY(-226, 0.5f);
  268. main_buttons[3].GetComponent<RectTransform>().transform.DOMoveY(-226, 0.5f);
  269. }
  270. public void naviOn()
  271. {
  272. text[3].DOText("시작위치를 골라주세요.", 1f);
  273. }
  274. public void click_0Button()
  275. {
  276. ID = 0;
  277. FirstStart_Point();
  278. start_Point[1].GetComponent<Button>().image.DOColor(Color.red, 1f);
  279. }
  280. public void click_40Button()
  281. {
  282. ID = 40;
  283. FirstStart_Point();
  284. start_Point[3].GetComponent<Button>().image.DOColor(Color.red, 1f);
  285. }
  286. public void click_13Button()
  287. {
  288. ID = 13;
  289. FirstStart_Point();
  290. start_Point[2].GetComponent<Button>().image.DOColor(Color.red, 1f);
  291. }
  292. public void click_7Button()
  293. {
  294. ID = 7;
  295. FirstStart_Point();
  296. start_Point[0].GetComponent<Button>().image.DOColor(Color.red, 1f);
  297. }
  298. public void click_19Button()
  299. {
  300. ID = 19;
  301. FirstStart_Point();
  302. start_Point[4].GetComponent<Button>().image.DOColor(Color.red, 1f);
  303. }
  304. public void click_25Button()
  305. {
  306. ID = 25;
  307. FirstStart_Point();
  308. start_Point[6].GetComponent<Button>().image.DOColor(Color.red, 1f);
  309. }
  310. public void click_29Button()
  311. {
  312. ID = 29;
  313. FirstStart_Point();
  314. start_Point[5].GetComponent<Button>().image.DOColor(Color.red, 1f);
  315. }
  316. public void FirstStart_Point()
  317. {
  318. Invoke("Delays", 0.5f);
  319. }
  320. //테스트는 0 -> 7 0 -> 13 으로 하기.
  321. void Delays()
  322. {
  323. if (delay_Time == 0)
  324. {
  325. x = ID;
  326. delay_Time++;
  327. text[3].DOText("첫번째 경로가 선택 되었습니다.", 0.5f);
  328. }
  329. else if (delay_Time == 1)
  330. {
  331. y = ID;
  332. if(x == 0 && y== 7) {
  333. Tweener textTw = text[3].DOText(start_Point[4].name+"를 골랐습니다.", 1f);
  334. textTw.OnComplete(() => Finish());
  335. NaviStart();
  336. }
  337. else if (x == 0 && y == 13) {
  338. Tweener textTw = text[3].DOText(start_Point[2].name + "를 골랐습니다.", 1f);
  339. textTw.OnComplete(() => Finish());
  340. NaviStart();
  341. }
  342. }
  343. }
  344. public void First_to_End1()
  345. {
  346. Tweener textTw =text[3].DOText("End1 를 골랐습니다.", 1f);
  347. textTw.OnComplete(() => Finish());
  348. naviStart_Button.gameObject.SetActive(true);
  349. }
  350. public void Finish()
  351. {
  352. text[3].DOText("경로가 생성되었습니다.", 1f);
  353. }
  354. public void NaviStart()
  355. {
  356. op.SetActive(true);
  357. arrowON.SetActive(true);
  358. navis[0].GetComponent<MoveAlongPath>().PlaybackSettings.Speed = 2f;
  359. text[3].text = "";
  360. compass.SetActive(true);
  361. compass_1.SetActive(true);
  362. Invoke("Late1", 0.1f);
  363. for (int i = 0; i < 7; i++)
  364. {
  365. start_Point[i].GetComponent<Button>().image.DOColor(Color.black, 1f);
  366. start_Point[i].gameObject.SetActive(true);
  367. }
  368. Tweener navi = naviSub_Panel.transform.DOLocalMoveY(-2470, 0.5f);
  369. naviStart_Button.gameObject.SetActive(false);
  370. naviSub_Panel.transform.DOLocalMoveY(-2600, 1f);
  371. buttons[0].SetActive(false);
  372. }
  373. public void NotYet_Point()
  374. {
  375. Tweener wrongPath = text[3].DOText("아직 경로가 없습니다.", 1f);
  376. wrongPath.OnComplete(() => RewriteWord());
  377. }
  378. public void RewriteWord()
  379. {
  380. text[3].DOText("출발 위치를 골라주세요.",1f);
  381. }
  382. }