예제 #1
0
    public DialogOption(string kvs)
    {
        kvs = DialogMetaData.CleanStatusValue(kvs);
        if (kvs[0] == '{')
        {
            kvs = kvs.Remove(0, 1);
        }
        if (kvs[kvs.Length - 1] == '}')
        {
            kvs = kvs.Remove(kvs.Length - 1, 1);
        }
        Debug.Log(kvs);
        var optionKVs = kvs.Split(new string[] { "," }, StringSplitOptions.None);

        foreach (var option in optionKVs)
        {
            var optionKV = DialogMetaData.GetKeyAndValue(option);
            switch (optionKV.Key.ToLower())
            {
            case "name": name = optionKV.Value; break;

            case "goto": gotoMeta = optionKV.Value; break;
            }
        }
    }
예제 #2
0
 void Clear()
 {
     MetaData          = new DialogMetaData();
     mode              = GameStatusMode.Idle;
     DayID             = 0;
     CurrentMeta       = new List <string>();
     PlayerOwningItems = new PlayerItems();
     CurrentID         = 0;
     options           = new List <DialogOption>();
     ExtraValue        = new Dictionary <string, string>();
 }
예제 #3
0
    void UpdateValueStatus(string status)
    {
        string[] values = status.Split(new string[] { "," }, StringSplitOptions.None);
        foreach (var valueStatus in values)
        {
            var kv = DialogMetaData.GetKeyAndValue(valueStatus);
            switch (kv.Key.ToLower())
            {
            case "stress": Stress += int.Parse(kv.Value); break;

            case "satisfaction": Satisfaction += int.Parse(kv.Value); break;

            case "living": Living += int.Parse(kv.Value); break;
            }
        }
    }
예제 #4
0
    public PlayerItem(string value)
    {
        Clear();
        string[] values = value.Split(new string[] { "," }, StringSplitOptions.None);
        foreach (var valueStatus in values)
        {
            var kv = DialogMetaData.GetKeyAndValue(valueStatus);
            switch (kv.Key.ToLower())
            {
            case "name": name = kv.Value.ToLower(); break;

            default:
                extraAttr[kv.Key.ToLower()] = kv.Value;
                break;
            }
        }
    }
예제 #5
0
    void AnalysisKV(string status)
    {
        print("Analysis!");
        var    kv    = DialogMetaData.GetKeyAndValue(status);
        string key   = kv.Key;
        string value = kv.Value;

        print(key);
        print(value);
        print("==========");
        switch (key)
        {
        case "photo":
            PhotoImage = DialogMetaData.LoadImage(value);
            break;

        case "theme":
            theme = value;
            if (theme != "dialog")
            {
                mode = GameStatusMode.SelectItem;
            }
            break;

        case "item":
            //playerItems.Add(new PlayerItem(value));
            int start = value.IndexOf("{");
            int end   = value.IndexOf("}");
            value = value.Substring(start + 1, end - start - 1);
            PlayerOwningItems.Add(new PlayerItem(value));

            break;

        case "dialog":
            if (value[0] == '"')
            {
                value = value.Remove(0, 1);
            }
            if (value[value.Length - 1] == '"')
            {
                value = value.Remove(value.Length - 1, 1);
            }
            DialogSentence = value;
            break;

        case "backgroundImage":
            BackgroundImage = DialogMetaData.LoadImage(value);
            break;

        case "dialogImage":
        case "image":
            DialogImage = DialogMetaData.LoadImage(value);
            break;

        case "time":
            DialogTime = value;
            break;

        case "valueset":
            var valueChange = value;
            start       = valueChange.IndexOf("{");
            end         = valueChange.IndexOf("}");
            valueChange = valueChange.Substring(start + 1, end - start - 1);
            NewValueStatus(valueChange);
            break;

        case "valueupdate":
            valueChange = value;
            start       = valueChange.IndexOf("{");
            end         = valueChange.IndexOf("}");
            valueChange = valueChange.Substring(start + 1, end - start - 1);
            UpdateValueStatus(valueChange);
            break;

        case "option":
            mode        = GameStatusMode.Option;
            valueChange = value;
            print(valueChange);
            start       = valueChange.IndexOf("[");
            end         = valueChange.IndexOf("]");
            valueChange = valueChange.Substring(start + 1, end - start - 1);
            var values = SplitByDelim(valueChange, ',');
            foreach (var valueStatus in values)
            {
                if (DialogMetaData.CleanStatusValue(valueStatus) == "")
                {
                    continue;
                }
                options.Add(new DialogOption(valueStatus));
            }
            print(options.Count);
            break;

        case "mode":
            switch (value.ToLower())
            {
            case "dialog": mode = GameStatusMode.Dialog; break;

            case "option": mode = GameStatusMode.Option; break;

            case "selectitem": mode = GameStatusMode.SelectItem; break;

            case "idle": mode = GameStatusMode.Idle; break;
            }
            break;

        case "goto":
            mode = GameStatusMode.Dialog;
            GotoMeta(value);
            break;

        default:
            ExtraValue[key] = value;
            print("extra");
            break;
        }
    }