Esempio n. 1
0
    public static void ReadByteConfig()
    {
        StaticCnf.Clear();
        byte[]       bytes  = ResManager.instance.LoadByte(CnfConst.DATA_BYTE_NAME);
        MemoryStream ms     = new MemoryStream(bytes);
        BinaryReader br     = new BinaryReader(ms);
        int          length = 0;

        length = br.ReadInt32();
        Dictionary <int, BuffCnf> buffcnf = new Dictionary <int, BuffCnf>();

        for (int i = 0; i < length; i++)
        {
            BuffCnf tmp = new BuffCnf();
            tmp.ToByteRead(br);
            buffcnf.Add(tmp.id, tmp);
        }
        StaticCnf.Add(buffcnf);

        length = br.ReadInt32();
        Dictionary <int, BuffEffectCnf> buffeffectcnf = new Dictionary <int, BuffEffectCnf>();

        for (int i = 0; i < length; i++)
        {
            BuffEffectCnf tmp = new BuffEffectCnf();
            tmp.ToByteRead(br);
            buffeffectcnf.Add(tmp.id, tmp);
        }
        StaticCnf.Add(buffeffectcnf);

        length = br.ReadInt32();
        Dictionary <int, HeroInfoCnf> heroinfocnf = new Dictionary <int, HeroInfoCnf>();

        for (int i = 0; i < length; i++)
        {
            HeroInfoCnf tmp = new HeroInfoCnf();
            tmp.ToByteRead(br);
            heroinfocnf.Add(tmp.id, tmp);
        }
        StaticCnf.Add(heroinfocnf);

        length = br.ReadInt32();
        Dictionary <int, SpellInfoCnf> spellinfocnf = new Dictionary <int, SpellInfoCnf>();

        for (int i = 0; i < length; i++)
        {
            SpellInfoCnf tmp = new SpellInfoCnf();
            tmp.ToByteRead(br);
            spellinfocnf.Add(tmp.id, tmp);
        }
        StaticCnf.Add(spellinfocnf);
        ms.Flush();
        ms.Close();
        br.Close();
        ms.Dispose();
    }
Esempio n. 2
0
    public static void WriteByteConfig()
    {
        FileInfo file_info = new FileInfo(CnfConst.data_byte_path);

        if (file_info.Exists)
        {
            file_info.Delete();
        }
        FileStream   file_stream = file_info.Create();
        BinaryWriter bw          = new BinaryWriter(file_stream);
        int          length      = 0;

        List <BuffCnf> tmp_buffcnf = new List <BuffCnf>(StaticCnf.FindMap <BuffCnf>().Values);

        length = tmp_buffcnf.Count;
        bw.Write(length);
        for (int i = 0; i < length; i++)
        {
            BuffCnf data = tmp_buffcnf[i];
            data.ToByteWrite(bw);
        }

        List <BuffEffectCnf> tmp_buffeffectcnf = new List <BuffEffectCnf>(StaticCnf.FindMap <BuffEffectCnf>().Values);

        length = tmp_buffeffectcnf.Count;
        bw.Write(length);
        for (int i = 0; i < length; i++)
        {
            BuffEffectCnf data = tmp_buffeffectcnf[i];
            data.ToByteWrite(bw);
        }

        List <HeroInfoCnf> tmp_heroinfocnf = new List <HeroInfoCnf>(StaticCnf.FindMap <HeroInfoCnf>().Values);

        length = tmp_heroinfocnf.Count;
        bw.Write(length);
        for (int i = 0; i < length; i++)
        {
            HeroInfoCnf data = tmp_heroinfocnf[i];
            data.ToByteWrite(bw);
        }

        List <SpellInfoCnf> tmp_spellinfocnf = new List <SpellInfoCnf>(StaticCnf.FindMap <SpellInfoCnf>().Values);

        length = tmp_spellinfocnf.Count;
        bw.Write(length);
        for (int i = 0; i < length; i++)
        {
            SpellInfoCnf data = tmp_spellinfocnf[i];
            data.ToByteWrite(bw);
        }
        file_stream.Flush();
        file_stream.Close();
        bw.Close();
        file_stream.Dispose();
    }
Esempio n. 3
0
    public static void ReadLocalConfig()
    {
        StaticCnf.Clear();
        int length = 0;
        Dictionary <string, BaseCsvInfo> csv_infos = CnfHelper.LoadFileContent();
        BaseCsvInfo info = null;

        info = csv_infos["BuffCnf"];
        Dictionary <int, BuffCnf> buffcnf = new Dictionary <int, BuffCnf>();

        length = info._datas.Count;
        for (int i = 0; i < length; i++)
        {
            BuffCnf tmp = new BuffCnf();
            tmp.ToLocalRead(info._datas[i]);
            buffcnf.Add(tmp.id, tmp);
        }
        StaticCnf.Add(buffcnf);

        info = csv_infos["BuffEffectCnf"];
        Dictionary <int, BuffEffectCnf> buffeffectcnf = new Dictionary <int, BuffEffectCnf>();

        length = info._datas.Count;
        for (int i = 0; i < length; i++)
        {
            BuffEffectCnf tmp = new BuffEffectCnf();
            tmp.ToLocalRead(info._datas[i]);
            buffeffectcnf.Add(tmp.id, tmp);
        }
        StaticCnf.Add(buffeffectcnf);

        info = csv_infos["HeroInfoCnf"];
        Dictionary <int, HeroInfoCnf> heroinfocnf = new Dictionary <int, HeroInfoCnf>();

        length = info._datas.Count;
        for (int i = 0; i < length; i++)
        {
            HeroInfoCnf tmp = new HeroInfoCnf();
            tmp.ToLocalRead(info._datas[i]);
            heroinfocnf.Add(tmp.id, tmp);
        }
        StaticCnf.Add(heroinfocnf);

        info = csv_infos["SpellInfoCnf"];
        Dictionary <int, SpellInfoCnf> spellinfocnf = new Dictionary <int, SpellInfoCnf>();

        length = info._datas.Count;
        for (int i = 0; i < length; i++)
        {
            SpellInfoCnf tmp = new SpellInfoCnf();
            tmp.ToLocalRead(info._datas[i]);
            spellinfocnf.Add(tmp.id, tmp);
        }
        StaticCnf.Add(spellinfocnf);
    }
Esempio n. 4
0
 public static BuffCnf FindBuffById(int buffId)
 {
     if (_buff == null)
     {
         _buff = StaticCnf.FindMap <BuffCnf>();
     }
     if (_buff.ContainsKey(buffId))
     {
         return(_buff[buffId]);
     }
     return(null);
 }
Esempio n. 5
0
    public void _init_csv_sound()
    {
        _sound_map_id   = StaticCnf.FindMap <SoundCnf>();
        _sound_map_name = new Dictionary <string, SoundCnf>();

        foreach (var info in _sound_map_id)
        {
            if (_sound_map_name.ContainsKey(info.Value.name))
            {
                continue;
            }
            _sound_map_name.Add(info.Value.name, info.Value);
        }

        //_sound_type.Add(1, E_GameResType.MUSIC_BGM);
        //_sound_type.Add(3, E_GameResType.MUSIC_SOUND);
        //_sound_type.Add(2, E_GameResType.MUSIC_VOICE);
    }
Esempio n. 6
0
 public void ClickToByte(EButton button)
 {
     StaticCnf.Clear();
     ConfigManager.ReadLocalConfig();
     ConfigManager.WriteByteConfig();
 }