Exemplo n.º 1
0
    public bool LoadJson(string strContent)
    {
        JsonData jsonData = JsonMapper.ToObject(strContent);

        for (int i = 0; i < jsonData.Count; ++i)
        {
            JsonData jd = jsonData[i];
            if (jd.Keys.Count != 5)
            {
                Debug.Log("ScenesCfg.json中列数量与生成的代码不匹配!");
                return(false);
            }

            ScenesCfgElement member = new ScenesCfgElement();
            member.Id                  = (int)jd["Id"];
            member.BigImageName        = (string)jd["BigImageName"];
            member.SmallImageName      = (string)jd["SmallImageName"];
            member.BuyPrice            = (int)jd["BuyPrice"];
            member.GrowthMushroomsList = (string)jd["GrowthMushroomsList"];


            member.IsValidate = true;
            _VecAllElements.Add(member);
            _MapElements[member.Id] = member;
        }
        return(true);
    }
Exemplo n.º 2
0
 private ScenesCfgTable()
 {
     _MapElements    = new Dictionary <int, ScenesCfgElement>();
     _EmptyItem      = new ScenesCfgElement();
     _VecAllElements = new List <ScenesCfgElement>();
 }
Exemplo n.º 3
0
    public bool LoadCsv(string strContent)
    {
        if (strContent.Length == 0)
        {
            return(false);
        }
        _MapElements.Clear();
        _VecAllElements.Clear();
        int           contentOffset = 0;
        List <string> vecLine;

        vecLine = HS_ByteRead.readCsvLine(strContent, ref contentOffset);
        if (vecLine.Count != 5)
        {
            Debug.Log("ScenesCfg.json中列数量与生成的代码不匹配!");
            return(false);
        }
        if (vecLine[0] != "Id")
        {
            Debug.Log("ScenesCfg.json中字段[Id]位置不对应"); return(false);
        }
        if (vecLine[1] != "BigImageName")
        {
            Debug.Log("ScenesCfg.json中字段[BigImageName]位置不对应"); return(false);
        }
        if (vecLine[2] != "SmallImageName")
        {
            Debug.Log("ScenesCfg.json中字段[SmallImageName]位置不对应"); return(false);
        }
        if (vecLine[3] != "BuyPrice")
        {
            Debug.Log("ScenesCfg.json中字段[BuyPrice]位置不对应"); return(false);
        }
        if (vecLine[4] != "GrowthMushroomsList")
        {
            Debug.Log("ScenesCfg.json中字段[GrowthMushroomsList]位置不对应"); return(false);
        }


        while (true)
        {
            vecLine = HS_ByteRead.readCsvLine(strContent, ref contentOffset);
            if ((int)vecLine.Count == 0)
            {
                break;
            }
            if ((int)vecLine.Count != (int)5)
            {
                return(false);
            }
            ScenesCfgElement member = new ScenesCfgElement();
            member.Id                  = Convert.ToInt32(vecLine[0]);
            member.BigImageName        = vecLine[1];
            member.SmallImageName      = vecLine[2];
            member.BuyPrice            = Convert.ToInt32(vecLine[3]);
            member.GrowthMushroomsList = vecLine[4];

            member.IsValidate = true;
            _VecAllElements.Add(member);
            _MapElements[member.Id] = member;
        }
        return(true);
    }
Exemplo n.º 4
0
    public bool LoadBin(byte[] binContent)
    {
        _MapElements.Clear();
        _VecAllElements.Clear();
        int nCol, nRow;
        int readPos = 0;

        readPos += HS_ByteRead.ReadInt32Variant(binContent, readPos, out nCol);
        readPos += HS_ByteRead.ReadInt32Variant(binContent, readPos, out nRow);
        List <string> vecLine     = new List <string>(nCol);
        List <int>    vecHeadType = new List <int>(nCol);
        string        tmpStr;
        int           tmpInt;

        for (int i = 0; i < nCol; i++)
        {
            readPos += HS_ByteRead.ReadString(binContent, readPos, out tmpStr);
            readPos += HS_ByteRead.ReadInt32Variant(binContent, readPos, out tmpInt);
            vecLine.Add(tmpStr);
            vecHeadType.Add(tmpInt);
        }
        if (vecLine.Count != 5)
        {
            Debug.Log("ScenesCfg.json中列数量与生成的代码不匹配!");
            return(false);
        }
        if (vecLine[0] != "Id")
        {
            Debug.Log("ScenesCfg.json中字段[Id]位置不对应"); return(false);
        }
        if (vecLine[1] != "BigImageName")
        {
            Debug.Log("ScenesCfg.json中字段[BigImageName]位置不对应"); return(false);
        }
        if (vecLine[2] != "SmallImageName")
        {
            Debug.Log("ScenesCfg.json中字段[SmallImageName]位置不对应"); return(false);
        }
        if (vecLine[3] != "BuyPrice")
        {
            Debug.Log("ScenesCfg.json中字段[BuyPrice]位置不对应"); return(false);
        }
        if (vecLine[4] != "GrowthMushroomsList")
        {
            Debug.Log("ScenesCfg.json中字段[GrowthMushroomsList]位置不对应"); return(false);
        }


        for (int i = 0; i < nRow; i++)
        {
            ScenesCfgElement member = new ScenesCfgElement();
            readPos += HS_ByteRead.ReadInt32Variant(binContent, readPos, out member.Id);
            readPos += HS_ByteRead.ReadString(binContent, readPos, out member.BigImageName);
            readPos += HS_ByteRead.ReadString(binContent, readPos, out member.SmallImageName);
            readPos += HS_ByteRead.ReadInt32Variant(binContent, readPos, out member.BuyPrice);
            readPos += HS_ByteRead.ReadString(binContent, readPos, out member.GrowthMushroomsList);

            member.IsValidate = true;
            _VecAllElements.Add(member);
            _MapElements[member.Id] = member;
        }
        return(true);
    }