Beispiel #1
0
 // 맵노드 클릭 이벤트
 public void OnMapNodeClick(int mapId, int index)
 {
     SoundManager.instance.EffectSourcePlay(AudioClipManager.instance.ui_button_default);
     if (MapSystem.isAbleMap(mapId))
     {
         currentMapId = GetMapId(index);
         Debugging.Log(index + "번째 노드클릭");
         mapNodeImage = ContentView.transform.GetChild(index).GetComponent <Image>();
         this.GetComponentInChildren <SimpleScrollSnap>().GoToPanel(index);
         ShowMapInfo(mapId);
         ShowHero();
     }
     else
     {
         Debugging.Log(mapId + " 의 맵은 아직 열리지 않은 맵입니다.");
     }
 }
Beispiel #2
0
 // 맵노드 클릭 이벤트
 public void OnMapNodeClick(int mapId)
 {
     SoundManager.instance.EffectSourcePlay(AudioClipManager.instance.ui_button_default);
     if (MapSystem.isAbleMap(mapId))
     {
         currentMapId     = mapId;
         mapNameText.text = string.Format("{0} <size='40'>{1}</size>", MapSystem.GetStageName(MapSystem.GetMap(currentMapId).stageNumber - 1), MapSystem.GetMap(currentMapId).name);
         foreach (var node in mapNodeList)
         {
             if (node.Key == mapId)
             {
                 mapNodeImage = node.Value.GetComponent <Image>();
                 break;
             }
         }
         mapInfoPanel.GetComponent <AiryUIAnimatedElement>().ShowElement();
         ShowHero();
     }
     else
     {
         Debugging.Log(mapId + " 의 맵은 아직 열리지 않은 맵입니다.");
     }
 }
Beispiel #3
0
    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();
        }
    }
Beispiel #4
0
 public IEnumerator ShowSelectMap()
 {
     while (ContentView.transform.childCount < MapSystem.GetMapCount())
     {
         Debugging.Log("로딩........");
         yield return(null);
     }
     currentMapId    = MapSystem.GetCurrentAllMapId();
     currentMapIndex = GetMapIndex(currentMapId);
     Debugging.Log(currentMapIndex + "번째 인덱스가 현재 맵입니다.");
     for (int i = 0; i < ContentView.transform.childCount; i++)
     {
         int tempEventIndex = i;
         if (i == currentMapIndex)
         {
             mapNodeImage = ContentView.transform.GetChild(i).GetComponent <Image>();
             ShowMapInfo(GetMapId(i));
             if (hero == null)
             {
                 hero = Instantiate(PrefabsDatabaseManager.instance.GetHeroPrefab(101), mapNodeImage.transform);
                 if (hero.GetComponent <Hero>() != null)
                 {
                     DestroyImmediate(hero.GetComponent <Hero>());
                 }
                 if (hero.GetComponent <Rigidbody2D>() != null)
                 {
                     DestroyImmediate(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);
             }
             this.GetComponentInChildren <SimpleScrollSnap>().GoToPanel(tempEventIndex);
             ShowHero();
         }
         ContentView.transform.GetChild(i).GetComponent <Button>().onClick.RemoveAllListeners();
         ContentView.transform.GetChild(i).GetComponent <Button>().onClick.AddListener(delegate
         {
             OnMapNodeClick(MapSystem.GetMap(GetMapId(tempEventIndex)).id, tempEventIndex);
         });
         if (!MapSystem.isAbleMap(MapSystem.GetMap(GetMapId(i)).id))
         {
             ContentView.transform.GetChild(i).transform.GetChild(0).GetComponent <Image>().overrideSprite = Resources.Load <Sprite>("UI/ui_lock_transparent");
         }
         else
         {
             if (MapSystem.GetMap(GetMapId(i)).clearPoint < 1)
             {
                 ContentView.transform.GetChild(i).transform.GetChild(0).GetComponent <Image>().color = new Color(1, 1, 1, 0);
             }
             else
             {
                 ContentView.transform.GetChild(i).transform.GetChild(0).GetComponent <Image>().color = new Color(1, 1, 1, 1);
             }
         }
     }
 }