void Start() { if (mapSlotNodePrefab != null) { int stageCount = (int)((MapSystem.maps.Count - 1) / 10) + 1; int currentStageIndex = 0; // 스테이지 변경이벤트 추가 ScrollSnapMapView.GetComponent <SimpleScrollSnap>().onPanelChanged.RemoveAllListeners(); ScrollSnapMapView.GetComponent <SimpleScrollSnap>().onPanelChanged.AddListener(delegate { OnStagePanelChanged(); }); // Stage 카운트만큼 스크롤스냅뷰 추가 ScrollSnapMapView.GetComponent <DynamicContentController>().AddToBack(stageCount); // 추가된 스테이지 슬롯을 담을 리스트 추가 mapSlotList = new List <GameObject>(); // 맵 노드의 아이디와 슬롯을 담을 리스트 추가 mapNodeList = new Dictionary <int, GameObject>(); // 추가된 스테이지 슬롯에맞는 맵 노드 추가 for (var j = 0; j < ContentView.transform.childCount; j++) { ContentView.transform.GetChild(j).GetChild(1).GetChild(0).GetComponent <Image>().sprite = MapSystem.GetStageThumbnailImage(j + 1); mapSlotList.Add(ContentView.transform.GetChild(j).gameObject); foreach (var mapNode in MapSystem.GetMapNode(j + 1)) { if (mapNode != null) { GameObject mapNodePrefab = Instantiate(mapSlotNodePrefab, mapSlotList[j].transform.GetChild(0).transform); // 맵노드 버튼 이벤트 추가 mapNodePrefab.GetComponent <Button>().onClick.AddListener(delegate { OnMapNodeClick(mapNode.id); }); mapNodePrefab.SetActive(true); // 맵노드리스트에 아이디와 슬롯프리팹을 추가 mapNodeList.Add(mapNode.id, mapNodePrefab); // 아직 갈 수 없는 맵노드에 잠금 아이콘 추가 if (!MapSystem.isAbleMap(mapNode.id)) { mapNodePrefab.transform.GetChild(0).GetComponent <Image>().overrideSprite = Resources.Load <Sprite>("UI/ui_lock_transparent"); mapNodePrefab.transform.GetChild(1).gameObject.SetActive(false); } else { if (mapNode.clearPoint > 2) { mapNodePrefab.transform.GetChild(0).gameObject.SetActive(true); mapNodePrefab.transform.GetChild(1).gameObject.SetActive(true); } else if (mapNode.clearPoint == 2) { mapNodePrefab.transform.GetChild(0).gameObject.SetActive(true); mapNodePrefab.transform.GetChild(1).gameObject.SetActive(false); } else { mapNodePrefab.transform.GetChild(0).gameObject.SetActive(false); mapNodePrefab.transform.GetChild(1).gameObject.SetActive(false); } } } } } // 현재 유저가 갈 수있는 최상단 스테이지를 찾음 currentMapId = MapSystem.GetCurrentMapId(); // 현재 스테이지 넘버인덱스 currentStageIndex = MapSystem.GetMap(currentMapId).stageNumber - 1; for (var i = 0; i < mapSlotList.Count; i++) { if (i > currentStageIndex) { mapSlotList[i].transform.GetChild(1).GetChild(1).gameObject.SetActive(true); } else { mapSlotList[i].transform.GetChild(1).GetChild(1).gameObject.SetActive(false); } } // 찾은 스테이지 정보를 뷰로 보여줌 mapNameText.text = string.Format("{0} <size='40'>{1}</size>", MapSystem.GetStageName(currentStageIndex), MapSystem.GetMap(currentMapId).name); mapDescriptionText.text = MapSystem.GetStageDescription(currentStageIndex); foreach (var node in mapNodeList) { if (node.Key == currentMapId) { mapNodeImage = node.Value.GetComponent <Image>(); break; } } //mapNodeImage.overrideSprite = Resources.Load<Sprite>("UI/ui_container2"); ScrollSnapMapView.GetComponent <SimpleScrollSnap>().GoToPanel(currentStageIndex); if (hero == null) { hero = Instantiate(PrefabsDatabaseManager.instance.GetHeroPrefab(101), mapNodeImage.transform); if (hero.GetComponent <Hero>() != null) { Destroy(hero.GetComponent <Hero>()); } if (hero.GetComponent <Rigidbody2D>() != null) { Destroy(hero.GetComponent <Rigidbody2D>()); } foreach (var sp in hero.GetComponentsInChildren <SpriteRenderer>()) { sp.sortingLayerName = "ShowObject"; sp.gameObject.layer = 16; } hero.transform.localRotation = Quaternion.Euler(0, 180, 0); hero.GetComponent <Animator>().SetBool("isMoving", true); hero.GetComponent <Animator>().SetBool("isRun", true); } ShowHero(); } }