示例#1
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("MushroomsCfg.json中列数量与生成的代码不匹配!");
            return(false);
        }
        if (vecLine[0] != "Id")
        {
            Debug.Log("MushroomsCfg.json中字段[Id]位置不对应"); return(false);
        }
        if (vecLine[1] != "AnimationName")
        {
            Debug.Log("MushroomsCfg.json中字段[AnimationName]位置不对应"); return(false);
        }
        if (vecLine[2] != "RipeTime")
        {
            Debug.Log("MushroomsCfg.json中字段[RipeTime]位置不对应"); return(false);
        }
        if (vecLine[3] != "SalePrice")
        {
            Debug.Log("MushroomsCfg.json中字段[SalePrice]位置不对应"); return(false);
        }
        if (vecLine[4] != "isOk")
        {
            Debug.Log("MushroomsCfg.json中字段[isOk]位置不对应"); 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);
            }
            MushroomsCfgElement member = new MushroomsCfgElement();
            member.Id            = Convert.ToInt32(vecLine[0]);
            member.AnimationName = vecLine[1];
            member.RipeTime      = Convert.ToInt32(vecLine[2]);
            member.SalePrice     = Convert.ToInt32(vecLine[3]);
            member.isOk          = Convert.ToBoolean(vecLine[4]);

            member.IsValidate = true;
            _VecAllElements.Add(member);
            _MapElements[member.Id] = member;
        }
        return(true);
    }
示例#2
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);
    }