Example #1
0
    public static DialogueContents ParseJSONFile(string pFileName)
    {
        string[] directory = new string[] { "" };
        //Load our file
        TextAsset jsonObject = Resources.Load <TextAsset>(GetJSONPath(pFileName, out directory));

        //Create a new contents instance
        DialogueContents contents = new DialogueContents();

        //Load a JSONNode from the file.
        JSONNode jsonObj = JSON.Parse(jsonObject.text);

        //Create an array from only the designer-spesified arrays within that JSON file.
        JSONArray arrayNames = jsonObj[Settings.JSON_DEF_DEFINED_ARRAYS].AsArray;

        //Find, store and push the identifier keywords to the content class
        JSONArray identifiers = jsonObj[Settings.JSON_DEF_IDENTIFIER_KEYWORDS].AsArray;

        string[] identiferStrings = new string[identifiers.Count];
        for (int i = 0; i < identifiers.Count; i++)
        {
            identiferStrings[i] = identifiers[i].ToString();
        }
        contents.SetIdentifierKeywords(identiferStrings);


        //Go through each array in the file
        for (int i = 0; i < arrayNames.Count; i++)
        {
            //A JSONArray that represents a single array in our file
            JSONArray singleArray = jsonObj[arrayNames[i].Value].AsArray;

            //The number of elements present in that array
            int numberOfElements = jsonObj[arrayNames[i].Value].Count;
            Debug.Log("number ele: " + numberOfElements);

            //The number of fields present in each element of that array
            int[] numberOfFields = new int[numberOfElements];
            for (int j = 0; j < numberOfElements; j++)
            {
                numberOfFields[j] = jsonObj[arrayNames[i].Value][j].Count;
                Debug.Log("num fields: " + numberOfFields[j]);
            }
            contents.AddDialogueArray(arrayNames[i].ToString(), singleArray, numberOfElements, numberOfFields);
        }

        return(contents);
    }
    protected override async UniTask FirstEvent(CancellationToken token)
    {
        //上下黒クロップいれて映画っぽい演出から始めてもいいな。
        FindObjectOfType <RoomHandController>().SwitchClickable(false);
        var monologueText = FindObjectOfType <SubtitleCanvas>().monologueText;
        var lang          = FindObjectOfType <CommonManager>().PlayLang;

        _contents = lang == Lang.ja ? contents_ja : contents_en;
        if (_contents.timeCount.Length != _contents.dialogues.Length + 1)
        {
            Debug.LogWarning("コンテンツの情報が適切にセットされていません。");
        }
        for (int i = 0; i < _contents.dialogues.Length; i++)
        {
            await UniTask.Delay((int)(_contents.timeCount[0] * 1000), cancellationToken : token);

            await TextAnim.TypeAnim(monologueText, _contents.dialogues[i], typingDuration, token);

            while (true)
            {
                await UniTask.Yield(PlayerLoopTiming.Update, cancellationToken : token);

                if (Input.GetMouseButtonDown(0))
                {
                    break;
                }
            }
            if (i != _contents.dialogues.Length - 1)
            {
                monologueText.text = "";
            }
        }
        var duration = 3f;
        await TextAnim.FadeOutText(monologueText, duration, token);

        FindObjectOfType <RoomHandController>().SwitchClickable(true);
    }
Example #3
0
    // Start is called before the first frame update

    public static void LoadAreaDialogue(string pAreaName)
    {
        currentAreaName = pAreaName;
        contents        = JsonParser.ParseJSONFile(pAreaName);
    }