Exemplo n.º 1
0
        public string ConvertToString()
        {
            StringTable table = new StringTable();

            table.Add("UserGroupIDs", StringUtil.Join(UserGroupIDs));
            table.Add("TotalPoint", TotalPoint.ToString());
            table.Add("Points", StringUtil.Join(Points));
            table.Add("TotalPosts", TotalPosts.ToString());
            table.Add("OnlineTime", OnlineTime.ToString());
            table.Add("OtherMissionIDs", StringUtil.Join(OtherMissionIDs));
            table.Add("MaxApplyCount", MaxApplyCount.ToString());

            return(table.ToString());
        }
Exemplo n.º 2
0
    public static void ParseData(FreshLevels.Type lvlType, string data)
    {
        if (data == null)
        {
            return;
        }
        if (data.Length < 3)
        {
            return;
        }                                        // must be rubbish data, white space, to be so short

        //Debug.Log("HERE1");

        //find or create the totalData and recalc it
        int lvlIndex = -1;

        for (int i = 0; i < lvlStats.Count; i++)
        {
            if (lvlStats[i].levelType == lvlType)
            {
                lvlIndex = i;
            }
        }
        if (lvlIndex == -1)
        {
            //create it
            TotalPoint tp = new TotalPoint();
            tp.levelType = lvlType;
            lvlIndex     = lvlStats.Count;
            lvlStats.Add(tp);
        }
        //Debug.Log("RAW DATA: " + lvlType + ", " + data);

        //Ok, now parse the data
        string[] chunks = data.Split(',');
        //Debug.Log("HERE2 " + chunks.Length);

        List <string> names = new List <string>();
        List <float>  times = new List <float>();

        for (int d = 0; d < chunks.Length; d++)
        {
            if (chunks[d].Length < 3)
            {
                continue;
            }
            //Debug.Log("HERE3 " + chunks[d]);
            string[] bits = chunks[d].Split(':');
            names.Add(bits[0]);
            float r = -1;
            float.TryParse(bits[1], out r);
            times.Add(r);
        }
        //Debug.Log("HERE 4");



        for (int i = 0; i < names.Count; i++)
        {
            //Debug.Log(names[i]);
            lvlStats[lvlIndex].names.Add(names[i]);

            bool unique = true;
            for (int a = 0; a < lvlStats[lvlIndex].names.Count; a++)
            {
                if (lvlStats[lvlIndex].names[a] == names[i])
                {
                    unique = false;
                }
            }
            if (unique)
            {
                Debug.Log(names[i]);
                lvlStats[lvlIndex].names.Add(names[i]);
            }
        }

        for (int i = 0; i < times.Count; i++)
        {
            //	Debug.Log(times[i]);
            lvlStats[lvlIndex].times.Add(times[i]);
        }

        /*
         * for (int d = 0; d < chunks.Length; d++)
         * {
         *      string[] bits = chunks[d].Split(':');
         *
         *      Debug.Log("HERE5 " + chunks[d]);
         *      Debug.Log("HERE6 " + bits[0] + "--" + bits[1] + ", Chunk length: " + chunks.Length);
         *
         *
         *
         *      lvlStats[lvlIndex].times.Add(float.Parse(bits[1]));
         *
         *
         *      //check if name already exists, if so, don't add it
         *      bool unique = true;
         *      for (int a = 0; a < lvlStats[lvlIndex].names.Count; a++)
         *      {
         *              if (lvlStats[lvlIndex].names[a] == bits[0])
         *              {
         *                      unique = false;
         *              }
         *      }
         *      if (unique)
         *      {
         *              lvlStats[lvlIndex].names.Add(bits[0]);
         *      }
         * }*/
        lvlStats[lvlIndex].rawData = data;
        lvlStats[lvlIndex].Calc();
    }