Exemplo n.º 1
0
    public void GetResourcesData()
    {
        if (Instance == null)
        {
            Instance = this;
        }

        allChapterList    = new List <ChapterSO>(Resources.LoadAll <ChapterSO>("Scriptable Object/Chapter"));
        sortedChapterList = new List <ChapterSO>();
        allChapterData    = new Dictionary <string, ChapterSO>();
        allSubchapterData = new Dictionary <string, SubchapterSO>();
        for (int i = 0; i < allChapterList.Count; i++)
        {
            ChapterSO currentChapterSO = allChapterList[i];
            if (currentChapterSO.chapterType == ChapterSO.ChapterType.Content)
            {
                sortedChapterList.Add(currentChapterSO);
                Debug.Log(currentChapterSO.chapterName);

                allChapterData.Add(currentChapterSO.chapterName, currentChapterSO);

                if (currentChapterSO.subchapterList.Count > 0)
                {
                    allSubchapterList = new List <SubchapterSO>(currentChapterSO.subchapterList);
                    for (int j = 0; j < currentChapterSO.subchapterList.Count; j++)
                    {
                        string subchapterKey = currentChapterSO.chapterName + "|" + currentChapterSO.subchapterList[j].subchapterName;
                        allSubchapterData.Add(subchapterKey, allSubchapterList[j]);
                    }
                }
            }

            else
            {
                allChapterData.Add(currentChapterSO.chapterName, currentChapterSO);
                if (currentChapterSO.subchapterList.Count > 0)
                {
                    allSubchapterList = new List <SubchapterSO>(currentChapterSO.subchapterList);
                    for (int j = 0; j < currentChapterSO.subchapterList.Count; j++)
                    {
                        string subchapterKey = currentChapterSO.chapterName + "|" + currentChapterSO.subchapterList[j].subchapterName;
                        allSubchapterData.Add(subchapterKey, allSubchapterList[j]);
                    }
                }
            }
            //Debug.Log(allChapterList[i].chapterName);

            //allChapterData.Add(allChapterList[i].chapterName, allChapterList[i]);

            //if (allChapterList[i].subchapterList.Count > 0)
            //{
            //    allSubchapterList = new List<SubchapterSO>(allChapterList[i].subchapterList);
            //    for (int j = 0; j < allChapterList[i].subchapterList.Count; j++)
            //    {
            //        string subchapterKey = allChapterList[i].chapterName + "|" + allChapterList[i].subchapterList[j].subchapterName;
            //        allSubchapterData.Add(subchapterKey, allSubchapterList[j]);
            //    }
            //}
        }
    }
Exemplo n.º 2
0
    public void InitChapterNode(ChapterSO _chapterSO)
    {
        chapterSO                = _chapterSO;
        chapterID                = _chapterSO.chapterID;
        chapterName              = _chapterSO.chapterName;
        chapterTitle             = _chapterSO.chapterTitle;
        totalSubchapter          = _chapterSO.subchapterList.Count;
        chapterNameText.text     = chapterTitle;
        titleFontSize            = _chapterSO.fontSize;
        chapterNameText.fontSize = titleFontSize;

        if (_chapterSO.chapterType == ChapterSO.ChapterType.Content)
        {
            if (DataManager.Instance.playerData.allChapterUnlocked.ContainsKey(chapterName))
            {
                chapterUnlocked = DataManager.Instance.playerData.chapterUnlocked[chapterName];

                if (chapterUnlocked)
                {
                    chapterButton.interactable = chapterUnlocked;
                    chapterButton.onClick.RemoveAllListeners();
                    chapterButton.onClick.AddListener(() =>
                    {
                        OpenSubchapterPanel();
                    });
                }

                else
                {
                    chapterButton.interactable = false;
                }
            }

            else
            {
                chapterUnlocked            = false;
                chapterButton.interactable = false;
            }
        }

        else
        {
            ChapterFillerType          = _chapterSO.chapterFillerType;
            chapterButton.interactable = true;
            chapterButton.onClick.RemoveAllListeners();
            chapterButton.onClick.AddListener(() =>
            {
                PanelController.Instance.ActiveDeactivePanel("filler", "chapter");
                DataManager.Instance._chapterFillerType = _chapterSO.chapterFillerType;

                FillerPanel.Instance.ActivateChildrenPanel();
            });
        }
    }
Exemplo n.º 3
0
    public IEnumerator InitAllChapterNode()
    {
        DespawnAllChapterNode();

        Sequence sequence = DOTween.Sequence();

        if (GameManager.Instance.allChapterData.Count > 0)
        {
            ChapterNode chapterNode;
            for (int i = 0; i < GameManager.Instance.allChapterList.Count; i++)
            {
                //ChapterSO chapterSO = GameManager.Instance.allChapterData[GameManager.Instance.allChapterList[i].chapterName];
                ChapterSO chapterSO = GameManager.Instance.allChapterList[i];
                chapterNode = LeanPool.Spawn(chapterNodePrefab, chapterNodeParent).GetComponent <ChapterNode>();
                chapterNode.InitChapterNode(chapterSO);

                sequence.Join(chapterNode.transform.DOPunchScale(Vector3.one * 0.2f, 0.2f, 3, 1));
                yield return(new WaitForSeconds(0.1f));
            }
        }
    }
Exemplo n.º 4
0
 public void LoadLevelsParam(ChapterSO _chapter)
 {
     chapter           = _chapter;
     background.sprite = _chapter.background;
     Init();
 }