Пример #1
0
        public IHttpActionResult GetAllData()
        {
            var result   = new TransferObj <List <ChoiceObject> >();
            var unitCode = _service.GetCurrentUnitCode();
            var data     = _service.Repository.DbSet.Where(x => x.TRANGTHAI == (int)TypeState.USED && x.UNITCODE.Equals(unitCode)).OrderBy(x => x.MAPHONG).ToList();
            List <ChoiceObject> listData = new List <ChoiceObject>();

            if (data.Count > 0)
            {
                foreach (var row in data)
                {
                    var obj = new ChoiceObject()
                    {
                        VALUE                                        = row.MAPHONG,
                        TEXT                                         = row.MAPHONG + " | " + row.TENPHONG,
                        DESCRIPTION                                  = row.TENPHONG,
                        PARENT                                       = row.TANG != null?row.TANG.ToString() : "",
                                                        ID           = row.ID,
                                                        EXTEND_VALUE = row.MALOAIPHONG
                    };
                    listData.Add(obj);
                }
            }
            if (listData.Count > 0)
            {
                result.Data   = listData;
                result.Status = true;
            }
            else
            {
                result.Status = false;
            }
            return(Ok(result));
        }
Пример #2
0
    void GUIChoice()
    {
        GUILayout.Label("Choices", EditorStyles.boldLabel);

        //scrollPosChoice = EditorGUILayout.BeginScrollView(scrollPosChoice,false,false);
        for (int i = 0; i < nbChoice; i++)
        {
            GUILayout.BeginHorizontal();

            choiceList [i].answer = EditorGUILayout.TextField(choiceList [i].answer);
            stringIndex [i]       = EditorGUILayout.TextField("go to sequence from", stringIndex [i]);
            stringIndexEnd [i]    = EditorGUILayout.TextField("to", stringIndexEnd [i]);

            GUILayout.EndHorizontal();

            if (stringIndex [i] != null && stringIndexEnd [i] != null && stringIndex [i].Contains(".") && stringIndexEnd [i].Contains("."))
            {
                string[] res  = stringIndex [i].Split('.');
                string[] res2 = stringIndexEnd [i].Split('.');

                int a, b, a2, b2;

                if (int.TryParse(res [0], out a) && int.TryParse(res [1], out b))
                {
                    choiceList [i].nextSentenceIndex = a * 1000 + b;
                }
                if (int.TryParse(res2 [0], out a2) && int.TryParse(res2 [1], out b2))
                {
                    choiceList [i].endSequenceIndex = a2 * 1000 + b2;
                }

                SentenceObject sO    = TextManager.GetSentence(choiceList [i].nextSentenceIndex);
                SentenceObject sOEnd = TextManager.GetSentence(choiceList [i].endSequenceIndex);

                GUILayout.BeginHorizontal();
                GUILayout.Label(sO.text, EditorStyles.helpBox);
                GUILayout.Label("->");
                GUILayout.Label(sOEnd.text, EditorStyles.helpBox);
                GUILayout.EndHorizontal();
            }
        }
        //EditorGUILayout.EndScrollView();

        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();

        if (GUILayout.Button("New Choice"))
        {
            if (nbChoice < 4)
            {
                nbChoice++;
                choiceList [nbChoice - 1] = new ChoiceObject();
            }
        }

        GUILayout.EndHorizontal();
    }
Пример #3
0
    static void ActionFunction(ChatManager cm, JSONArray choice, string message, int index)
    {
        string newScence = choice[index]["identifier"];

        ChoiceObject.ReplayMessage(cm.m_view, message);
        cm.status["atScene"] = newScence;
        cm.SaveStatusData(newScence);
        // SaveStatusData(scene);
    }
Пример #4
0
    void MakeNewResponse(string newDialog, int choiceValue)
    {
        ChoiceObject newChoiceObject = Instantiate(choicePrefab, choiceHolder.transform).GetComponent <ChoiceObject>();

        newChoiceObject.Setup(newDialog, choiceValue);

        Button choiceButton = newChoiceObject.gameObject.GetComponent <Button>();

        if (choiceButton)
        {
            // Adds the choice value to the listener that is in the onclick part of the button.
            choiceButton.onClick.AddListener(delegate { ChooseChoice(choiceValue); });
        }
    }
Пример #5
0
    static void HandleChoice(ChatManager cm, string line, string scene)
    {
        JSONArray choice = cm.choices[int.Parse(line.Substring(19, line.Length - 21))]["actions"].AsArray;

        ChoiceObject.SetChoiceButton(cm.m_view, new Dictionary <string, Action <string> > {
            // choiceButtonOne
            { choice[0]["choice"], message => {
                  ActionFunction(cm, choice, message, 0);
              } },
            // choiceButtonTwo
            { choice[1]["choice"], message => {
                  ActionFunction(cm, choice, message, 1);
              } }
        });
    }
Пример #6
0
    public void ClearChoices(List <Choice> exclude = null)
    {
        List <string> excludeStrings = new List <string>();

        //if (exclude != null) {foreach (Choice c in exclude) {excludeStrings.Add(c.text);}}
        for (int i = 0; i < choiceAnchor.transform.childCount; i++)
        {
            Transform    t    = choiceAnchor.transform.GetChild(i);
            ChoiceObject cObj = t.GetComponent <ChoiceObject>();
            if (!cObj || !excludeStrings.Contains(cObj.text))
            {
                Destroy(t.gameObject);
            }
        }

        /*
         * for (int i = 0; i < choices.Count; i++) {
         *      if (choices[i] == null) {continue;}
         *      if (choices[i].gameObject) {Destroy(choices[i].gameObject);}
         * }
         */
        choices.Clear();         //RemoveAll(x => !excludeObjs.Contains(x));
    }
Пример #7
0
    IEnumerator SelectChoice(int opt, bool silent = false)
    {
        GameManager.instance.stopWriting = true;
        //Debug.Log("Selected: " + opt);
        List <CanvasGroup> _yourChoice = new List <CanvasGroup>();

        lastChoices = StoryManager.story.currentChoices;

        if (!silent)
        {
            PlaySound(clipOnSelect);
        }

        for (int i = 0; i < choices.Count; i++)
        {
            if (choices[i] == null)
            {
                continue;
            }
            choices[i].GetComponent <Button>().enabled = false;
            ChoiceObject cObj = choices[i].GetComponent <ChoiceObject>();
            if (!cObj || cObj.choiceIndex != opt)
            {
                choices[i].GetComponent <FadeElement>().target = 0;
            }
        }
        if (!silent)
        {
            yield return(new WaitForSeconds(0.3f));
        }

        if (!multiblock)
        {
            foreach (GameObject page in pages)
            {
                if (page)
                {
                    page.GetComponent <FadeElement>().target = 0;
                }
            }
        }
        if (!silent)
        {
            yield return(new WaitForSeconds(0.7f));
        }

        Transform choiceTransform = null;

        foreach (Transform t in choices)
        {
            if (t == null)
            {
                continue;
            }
            ChoiceObject _c = t.GetComponent <ChoiceObject>();
            if (_c && _c.choiceIndex == opt)
            {
                choiceTransform = t; break;
            }
        }
        if (choiceTransform)
        {
            choiceTransform.GetComponent <FadeElement>().target = 0;
            if (!silent)
            {
                yield return(new WaitForSeconds(0.5f));
            }
        }
        else
        {
            if (!silent)
            {
                yield return(new WaitForSeconds(0.5f));
            }
        }
        //string fullText = StoryManager.story.currentChoices[opt].text.Trim();
        StoryManager.story.ChooseChoiceIndex(opt);

        ClearChoices();
        lines.Clear();
        GameManager.instance.stopWriting = false;
        yield return(StartCoroutine(Next()));

        yield break;
    }
Пример #8
0
    IEnumerator LoadChoices(List <Choice> _choices)
    {
        //yield return new WaitForSeconds(0.1f);
        if (_choices.Count > 0)
        {
            ChoiceObject[] prevChoices = GameObject.FindObjectsOfType <ChoiceObject>();
            Debug.Log(prevChoices.Length);
            for (int i = 0; i < _choices.Count; ++i)
            {
                Choice choice = _choices[i];

                if (silentOptions.Contains(CleanText(choice.text)))
                {
                    continue;
                }

                int        ind       = choice.index;
                GameObject choiceObj = null;

                /*
                 * foreach (ChoiceObject c in prevChoices) {
                 *      string _ss = choice.text.Trim();
                 *      Debug.Log(c.text + " != " + _ss);
                 *      if (c.text.Trim() == _ss) {
                 *              Debug.Log(":D");
                 *              choiceObj = c.gameObject;
                 *              FadeElement __fade = c.GetComponent<FadeElement>();
                 *              if (__fade) {__fade.target = 1;}
                 *              Debug.Log(c.gameObject);
                 *              //Destroy(choiceObj.GetComponent<Button>());
                 *              //choiceObj.AddComponent<Button>();
                 *              if (!choices.Contains(c.transform)) {choices.Add(c.transform);}
                 *      }
                 *      else {
                 *              //Debug.Log(cc.text + "!=" + _ss);
                 *      }
                 * }
                 */
                if (choiceObj == null)
                {
                    choiceObj      = GameObject.Instantiate(choicePrefab);
                    choiceObj.name = Random.Range(0, 99999).ToString();
                    choices.Add(choiceObj.transform);
                    choiceObj.transform.SetParent(choiceAnchor);
                }

                RectTransform rect = choiceObj.GetComponent <RectTransform>();
                rect.anchoredPosition = new Vector2(10 * i, rect.anchoredPosition.y);

                UIFadeIn fade = choiceObj.GetComponent <UIFadeIn>();
                if (fade)
                {
                    fade.delay = 0.7f + 0.5f * i;
                }

                Text _t = choiceObj.GetComponentInChildren <Text>();
                _t.text = HandleLine(choice.text);

                Button b = choiceObj.GetComponent <Button>();
                if (b == null)
                {
                    b = choiceObj.AddComponent <Button>();
                }
                else
                {
                    b.enabled = true;
                }
                b.onClick.AddListener(() => StartCoroutine(SelectChoice(ind)));

                ChoiceObject _choiceObj = choiceObj.GetComponent <ChoiceObject>();
                if (_choiceObj == null)
                {
                    _choiceObj = choiceObj.AddComponent <ChoiceObject>();
                }
                _choiceObj.choiceIndex = ind;
                _choiceObj.text        = choice.text;

                StartCoroutine(UIManager.instance.LoadChoice(choiceObj));
            }
        }
        lastChoices.Clear();
        FadeElement _fade = choiceAnchor.GetComponent <FadeElement>();

        if (_fade)
        {
            if (choices.Count > 0)
            {
                _fade.target = 1;
            }
            else
            {
                _fade.target = 0;
            }
        }
        //if (canContinueIndicator) {canContinueIndicator.SetAsLastSibling();}
        Canvas.ForceUpdateCanvases();
        yield return(null);
    }
Пример #9
0
    IEnumerator WriteLine(StoryLine line)
    {
        List <Choice> _choices = StoryManager.story.currentChoices;

        yield return(ManageTextBlock());

        GameObject    go = lastTextBlock;
        Text          t  = go.GetComponentInChildren <Text>();
        RectTransform r  = lastTextBlock.GetComponent <RectTransform>();
        CanvasGroup   g  = lastTextBlock.GetComponent <CanvasGroup>();

        lastTextBlock.GetComponent <FadeElement>().target = 1;
        //r.name = line.text.Trim().Substring(0,30);

        t.text = line.text.Trim() + "\n";
        if (line.tags.Length > 0)
        {
            foreach (string tag in line.tags)
            {
                Debug.Log(tag);
                string[] tokens = tag.Split(':');
                for (int i = 0; i < tokens.Length; i++)
                {
                    tokens[i] = tokens[i].Trim();
                }
                if (tokens.Length > 1)
                {
                    switch (tokens[0])
                    {
                    case "startChoice":
                        if (!storeChoices)
                        {
                            break;
                        }
                        string[] derp = tokens[1].Split(','); for (int i = 0; i < derp.Length; i++)
                        {
                            derp[i] = derp[i].Trim();
                        }
                        if (derp.Length >= 1)
                        {
                            foreach (string s in derp)
                            {
                                CheckStartChoice(s);
                            }
                        }
                        else
                        {
                            CheckStartChoice(tokens[1]);
                        }
                        break;

                    case "endChoice":
                        if (!storeChoices)
                        {
                            break;
                        }
                        int choiceIndex = -1;
                        int.TryParse(tokens[1], out choiceIndex);
                        if (choiceIndex != -1)
                        {
                            for (int ii = 0; ii < choices.Count; ii++)
                            {
                                ChoiceObject _choice = choices[ii].GetComponent <ChoiceObject>();
                                if (_choice.choiceIndex == choiceIndex)
                                {
                                    StartCoroutine(RemoveChoice(_choice.gameObject));
                                }
                            }
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
        }

        Canvas.ForceUpdateCanvases();

        StopCoroutine("ScrollTo");
        //StartCoroutine(ScrollTo(go));
        yield return(null);
    }
Пример #10
0
 void copy(ChoiceObject choiceToCopy)
 {
     answer            = choiceToCopy.answer;
     nextSentenceIndex = choiceToCopy.nextSentenceIndex;
     endSequenceIndex  = choiceToCopy.endSequenceIndex;
 }
Пример #11
0
    void SaveModifs()
    {
        foreach (SentenceObject sO in TextManager.texts.sentences)
        {
            if (sO.index == sentence.index)
            {
                sO.transitionType = transition;
                switch (transition)
                {
                case SentenceObject.Transitions.Simple:
                    sO.fade      = false;
                    sO.crossfade = false;
                    break;

                case SentenceObject.Transitions.Fade:
                    sO.fade      = true;
                    sO.crossfade = false;
                    break;

                case SentenceObject.Transitions.Crossfade:
                    sO.fade      = false;
                    sO.crossfade = true;
                    break;
                }

                sO.isSMS = isSMS;

                sO.fadeDuration = fadeDuration;

                sO.fadeInDuration = fadeDurationIn;

                sO.fadeColorR = fadeColor.r;
                sO.fadeColorG = fadeColor.g;
                sO.fadeColorB = fadeColor.b;

                sO.keepPreviousImages = !posGroupEnabled;

                sO.characterName = options [index];

                sO.delayBeforeAppear = delayBeforeAppear;

                sO.themes = new List <SoundObject> ();

                theme.soundPath         = AssetDatabase.GetAssetPath(theme.sound);
                theme.delayBeforeAppear = themeDelay;
                theme.fadeInDuration    = themeFadeInDuration;
                theme.fadeOutDuration   = themeFadeOutDuration;

                sO.themes.Add(theme);

                soundscape.soundPath         = AssetDatabase.GetAssetPath(soundscape.sound);
                soundscape.delayBeforeAppear = soundscapeDelay;
                soundscape.fadeInDuration    = soundscapeFadeInDuration;
                soundscape.fadeOutDuration   = soundscapeFadeOutDuration;

                sO.themes.Add(soundscape);

                sO.stopTheme = stopMusic;

                sO.images = new List <ImageObject> ();

                for (int i = 0; i < imgList.Length; i++)
                {
                    ImageObject iO = imgList [i];
                    if (iO != null && (iO.image != null || iO.gameObject != null))
                    {
                        if (iO.image != null)
                        {
                            iO.imagePath = AssetDatabase.GetAssetPath(iO.image);
                        }
                        else
                        {
                            iO.imagePath = AssetDatabase.GetAssetPath(iO.gameObject);
                        }

                        iO.animDuration = animDuration [i];

                        iO.beginPosX = beginPos[i].x;
                        iO.beginPosY = beginPos[i].y;

                        iO.beginRot = beginRot[i];

                        iO.beginScaleX = beginScale[i].x;
                        iO.beginScaleY = beginScale[i].y;

                        iO.endPosX = endPos[i].x;
                        iO.endPosY = endPos[i].y;

                        iO.endRot = endRot[i];

                        iO.endScaleX = endScale[i].x;
                        iO.endScaleY = endScale[i].y;

                        iO.appearAfterSentence = appearAfterSentence [i];

                        iO.ease    = ease [i];
                        iO.easeOut = easeOut[i];

                        sO.images.Add(iO);
                    }
                }

                sO.sounds = new List <SoundObject> ();

                for (int i = 0; i < soundList.Length; i++)
                {
                    SoundObject sdO = soundList [i];
                    if (sdO != null && sdO.sound != null)
                    {
                        sdO.soundPath = AssetDatabase.GetAssetPath(sdO.sound);

                        sdO.fadeInDuration    = soundFadeInDuration[i];
                        sdO.fadeOutDuration   = soundFadeOutDuration[i];
                        sdO.delayBeforeAppear = soundDelay[i];
                        sdO.loop = soundLoop [i];

                        sO.sounds.Add(sdO);
                    }
                }

                sO.choices = new List <ChoiceObject> ();

                for (int i = 0; i < choiceList.Length; i++)
                {
                    ChoiceObject cO = choiceList [i];
                    if (cO != null && cO.answer != "" && stringIndex [i] != null && stringIndexEnd [i] != null)
                    {
                        string[] res  = stringIndex [i].Split('.');
                        string[] res2 = stringIndexEnd [i].Split('.');

                        cO.nextSentenceIndex = int.Parse(res[0]) * 1000 + int.Parse(res[1]);
                        cO.endSequenceIndex  = int.Parse(res2[0]) * 1000 + int.Parse(res2[1]);

                        sO.choices.Add(cO);
                    }
                }

                break;
            }
        }

        TextManager.SaveText(fileName);
    }