コード例 #1
0
ファイル: MushroomsCfg.cs プロジェクト: qipa/HSFramework
    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("MushroomsCfg.json中列数量与生成的代码不匹配!");
                return(false);
            }

            MushroomsCfgElement member = new MushroomsCfgElement();
            member.Id            = (int)jd["Id"];
            member.AnimationName = (string)jd["AnimationName"];
            member.RipeTime      = (int)jd["RipeTime"];
            member.SalePrice     = (int)jd["SalePrice"];
            member.isOk          = (bool)jd["isOk"];


            member.IsValidate = true;
            _VecAllElements.Add(member);
            _MapElements[member.Id] = member;
        }
        return(true);
    }
コード例 #2
0
    public void Init(MushroomsCfgElement e)
    {
        //         scheduler.Timeout(() =>
        //         {
        //             HS_ViewManager.Open<UILoginView>();
        //             HS_ViewManager.Close<UILogoView>();
        //         }, 2);

        GameObject obj = new GameObject();

        _Image        = obj.AddComponent <Image>();
        _Image.sprite = HS_ResourceManager.LoadAsset <Sprite>(e.AnimationName);
        obj.AddComponent <MushroomsRipeStateBehaviour>().Init(this);
        obj.AddComponent <MushroomsWitherStateBehaviour>().Init(this);;
    }
コード例 #3
0
    public void Create(MushroomsCfgElement e)
    {
        Mushrooms m = _MushroomsPool.New();

        m.Init(e);
    }
コード例 #4
0
ファイル: MushroomsCfg.cs プロジェクト: qipa/HSFramework
 private MushroomsCfgTable()
 {
     _MapElements    = new Dictionary <int, MushroomsCfgElement>();
     _EmptyItem      = new MushroomsCfgElement();
     _VecAllElements = new List <MushroomsCfgElement>();
 }
コード例 #5
0
ファイル: MushroomsCfg.cs プロジェクト: qipa/HSFramework
    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);
    }
コード例 #6
0
ファイル: MushroomsCfg.cs プロジェクト: qipa/HSFramework
    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("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);
        }


        for (int i = 0; i < nRow; i++)
        {
            MushroomsCfgElement member = new MushroomsCfgElement();
            readPos += HS_ByteRead.ReadInt32Variant(binContent, readPos, out member.Id);
            readPos += HS_ByteRead.ReadString(binContent, readPos, out member.AnimationName);
            readPos += HS_ByteRead.ReadInt32Variant(binContent, readPos, out member.RipeTime);
            readPos += HS_ByteRead.ReadInt32Variant(binContent, readPos, out member.SalePrice);
            readPos += HS_ByteRead.ReadBool(binContent, readPos, out member.isOk);

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