예제 #1
0
    public IEnumerator InitAllSubchapterNode()
    {
        //StartCoroutine(CheckChapterChildCount());

        DespawnAllSubchapterNode();

        if (GameManager.Instance.allSubchapterData.Count > 0)
        {
            Sequence       sequence = DOTween.Sequence();
            SubchapterNode subchapterNode;
            for (int i = 0; i < GameManager.Instance.allSubchapterData.Count; i++)
            {
                string currentSubchapterKey = GameManager.Instance.allSubchapterData.Keys.ElementAt(i);
                string chapterKey           = currentSubchapterKey.Substring(0, currentSubchapterKey.IndexOf("|"));
                Debug.Log(currentSubchapterKey);
                Debug.Log(chapterKey);
                if (chapterKey == DataManager.Instance.currentChapterName)
                {
                    SubchapterSO subchapterSO = GameManager.Instance.allSubchapterData[currentSubchapterKey];
                    subchapterNode = LeanPool.Spawn(subchapterNodePrefab, subchapterNodeParent).GetComponent <SubchapterNode>();
                    subchapterNode.InitSubchapter(subchapterSO);

                    sequence.Join(subchapterNode.transform.DOPunchScale(Vector3.one * 0.2f, 0.2f, 3, 1));
                    yield return(new WaitForSeconds(0.1f));
                }
            }
        }
    }
예제 #2
0
    public void InitSubchapter(SubchapterSO _subchapterSO)
    {
        panelType               = _subchapterSO.panelType;
        subchapterID            = _subchapterSO.subchapterID;
        subchapterName          = _subchapterSO.subchapterName;
        subchapterTitle         = _subchapterSO.subchapterTitle;
        subchapterTitleTxt.text = subchapterTitle;

        if (DataManager.Instance != null)
        {
            if (DataManager.Instance.playerData != null)
            {
                if (DataManager.Instance.currentChapterType == ChapterSO.ChapterType.Content)
                {
                    string currentSubchapterKey = DataManager.Instance.currentChapterName + "|" + _subchapterSO.subchapterName;
                    Debug.Log("current subchapter key " + currentSubchapterKey);
                    if (DataManager.Instance.playerData.subchapterUnlocked.ContainsKey(currentSubchapterKey))
                    {
                        subchapterUnlocked = DataManager.Instance.playerData.subchapterUnlocked[currentSubchapterKey];
                        Debug.Log("subchapter unlocked " + currentSubchapterKey + " unlocked " + subchapterUnlocked);
                        if (subchapterUnlocked)
                        {
                            subchapterButton.interactable = true;
                            subchapterButton.onClick.RemoveAllListeners();
                            subchapterButton.onClick.AddListener(() =>
                            {
                                OpenContentPanel();
                            });
                        }

                        else
                        {
                            subchapterButton.interactable = false;
                        }
                    }

                    else
                    {
                        subchapterUnlocked            = false;
                        subchapterButton.interactable = false;
                    }
                }

                else
                {
                    subchapterUnlocked            = true;
                    subchapterButton.interactable = true;
                    subchapterButton.onClick.RemoveAllListeners();
                    subchapterButton.onClick.AddListener(() =>
                    {
                        OpenContentPanel();
                    });
                }
            }
        }
    }
예제 #3
0
    public void InitAllContents()
    {
        DespawnAllContents();

        PanelController.Instance.backButton.gameObject.SetActive(true);
        //PanelController.Instance.backButton.interactable = false;
        contentTitleText.text = currentSubchapterTitle;

        ActivateDeactivateNavigationButton();

        if (GameManager.Instance.allSubchapterData.Count > 0)
        {
            if (GetInstance().currentSubchapterName != "")
            {
                SubchapterSO subchapterSO = GameManager.Instance.allSubchapterData[GetInstance().currentChapterName + "|" + GetInstance().currentSubchapterName];
                ContentNode  contentNode;
                for (int i = 0; i < subchapterSO.subchapterContents.Count; i++)
                {
                    ContentPartSO contentPartSO = subchapterSO.subchapterContents[i];

                    switch (contentPartSO.contentType)
                    {
                    case ContentPartSO.ContentType.Image:
                        contentNode = LeanPool.Spawn(contentImagePrefab, contentNodeParent).GetComponent <ContentNode>();
                        contentNode.InitContentNode(contentPartSO, i);
                        subchapterContentNodes.Add(contentNode);
                        break;

                    case ContentPartSO.ContentType.Text:
                        contentNode = LeanPool.Spawn(contentTextPrefab, contentNodeParent).GetComponent <ContentNode>();
                        contentNode.InitContentNode(contentPartSO, i);
                        subchapterContentNodes.Add(contentNode);
                        break;

                    case ContentPartSO.ContentType.Video:
                        contentNode = LeanPool.Spawn(contentVideoPrefab, contentNodeParent).GetComponent <ContentNode>();
                        contentNode.InitContentNode(contentPartSO, i);
                        subchapterContentNodes.Add(contentNode);
                        break;

                    case ContentPartSO.ContentType.Question:
                        contentNode = LeanPool.Spawn(contentQuestionPrefab, contentNodeParent).GetComponent <ContentNode>();
                        contentNode.InitContentNode(contentPartSO, i);
                        subchapterContentNodes.Add(contentNode);
                        break;

                    case ContentPartSO.ContentType.AR:
                        contentNode = LeanPool.Spawn(contentARPrefab, contentNodeParent).GetComponent <ContentNode>();
                        contentNode.InitContentNode(contentPartSO, i);
                        subchapterContentNodes.Add(contentNode);
                        break;

                    case ContentPartSO.ContentType.Subject:
                        contentNode = LeanPool.Spawn(contentSubjectPrefab, contentNodeParent).GetComponent <ContentNode>();
                        contentNode.InitContentNode(contentPartSO, i);
                        subchapterContentNodes.Add(contentNode);
                        break;

                    default:
                        break;
                    }
                }

                PanelController.Instance.backButton.interactable = true;

                if (DataManager.Instance.currentChapterType == ChapterSO.ChapterType.Content)
                {
                    nextButton.gameObject.SetActive(true);
                }

                else
                {
                    nextButton.gameObject.SetActive(false);
                }

                foreach (var button in buttonsInContentLayout)
                {
                    button.transform.SetAsLastSibling();
                }
                //buttonsInContentLayout.transform.SetAsLastSibling();
                ScrollToTop(scrollRect);
            }
        }
    }