Пример #1
0
    public RoleAttrConfig(string name, int id, int randMin, int randMax, string param, string describe)
    {
        type         = RoleAttrShowType.Text;
        this.name    = name;
        this.id      = id;
        this.randMin = randMin;
        this.randMax = randMax;
        this.param   = param;
        progressMin  = randMin;
        progressMax  = randMax;
        this.param   = param;
        string[] tmp   = param.Split(';');
        int      count = tmp.Length;

        charm_value    = new int[count];
        gril_showcharm = new string[count];
        boy_showcharm  = new string[count];
        this.describe  = describe;
        for (int i = 0; i < count; i++)
        {
            string[] values = tmp[i].Split('*');
            charm_value[i]   = int.Parse(values[0]);
            boy_showcharm[i] = values[1];
            if (values.Length == 3)
            {
                gril_showcharm[i] = values[2];
            }
            else
            {
                gril_showcharm[i] = values[1];
            }
        }
    }
Пример #2
0
    static RoleAttrConfigData()
    {
        var data    = Tools.ReadAllText("Config/roleAttr.txt").Split('\n');
        var attrdes = Tools.ReadAllText("Config/roleAttrDes.txt").Split('\n');
        int level   = 0;
        Dictionary <int, RoleAttrConfig[]> all = new Dictionary <int, RoleAttrConfig[]>();
        List <RoleAttrConfig> levelData        = null;
        int id = 0;

        foreach (var item in data)
        {
            if (string.IsNullOrWhiteSpace(item) || item.StartsWith("#"))
            {
                continue;
            }
            var line = item.Trim();
            var tmp  = line.Split(':');

            switch (tmp[0])
            {
            case "level":
                if (levelData != null)
                {
                    if (levelData.Count != (int)RoleAttribute.end)
                    {
                        Debug.LogErrorFormat("属性数量与枚举不匹配:{0}-{1}", levelData.Count, (int)RoleAttribute.end);
                    }
                    all.Add(level, levelData.ToArray());
                }
                level     = int.Parse(tmp[1]);
                id        = 0;
                levelData = new List <RoleAttrConfig>();
                break;

            default:
                tmp = line.Split(',');
                int              progressMin = 0, progressMax = 0, randMin = 0, randMax = 0;
                string           randattr     = tmp[1];
                RoleAttrShowType typ          = (RoleAttrShowType)int.Parse(tmp[2]);
                string[]         randattrlist = randattr.Split('*');
                if (randattrlist.Length < 1)
                {
                    continue;
                }
                else if (randattrlist.Length == 1)
                {
                    randMin = int.Parse(randattrlist[0]);
                    randMax = randMin;
                }
                else
                {
                    randMin = int.Parse(randattrlist[0]);
                    randMax = int.Parse(randattrlist[1]);
                }
                if (typ == RoleAttrShowType.Progress || typ == RoleAttrShowType.RateProgress)
                {
                    string   progressattr     = tmp[3];
                    string[] progressattrlist = progressattr.Split('*');

                    progressMin = int.Parse(progressattrlist[0]);
                    progressMax = int.Parse(progressattrlist[1]);
                }
                string des = null;
                if (id < attrdes.Length)
                {
                    des = string.Join("\n\n  ", attrdes[id].Split('|'));
                }
                if (typ == RoleAttrShowType.Text)
                {
                    levelData.Add(new RoleAttrConfig(tmp[0], id, randMin, randMax, tmp[3], des));
                }
                else
                {
                    levelData.Add(new RoleAttrConfig()
                    {
                        name      = tmp[0], id = id, progressMin = progressMin, progressMax = progressMax
                        , randMin = randMin, randMax = randMax, type = typ, describe = des
                    });
                }
                id++;
                break;
            }
        }
        all.Add(level, levelData.ToArray());
        dataList = all;
    }