Exemplo n.º 1
0
    public void Init()
    {
        //读取自带的版本号
        LoadInnerVersion();

        //读取SD卡的版本
        byte[] data = RuntimeInfo.GetLocalFile(RuntimeInfo.GetVersionFileName());
        if (data == null || data.Length != ResManager.RES_NUM * 4 + 4)
        {
            return;
        }
        uint crc = Crc.Crc32(data, 4, data.Length - 4);

        if (crc != System.BitConverter.ToUInt32(data, 0))
        {
            return;
        }

        for (int i = 0, idx = 4; i < ResManager.RES_NUM; ++i, idx += 4)
        {
            uint     resCrc = System.BitConverter.ToUInt32(data, idx);
            string   path   = RuntimeInfo.GetResPersistentPath((ResType)i);
            FileInfo fi     = new FileInfo(path);
            if (!fi.Exists)
            {
                continue;
            }
            m_ResVer[i].ResSize = (uint)fi.Length;
            m_ResVer[i].ResCrc  = resCrc;
        }
        m_bHasVerFile = true;
    }
Exemplo n.º 2
0
    public void ShowGold(uint nGold, uint nTime)
    {
        m_sharetype = ShareType.SHARE_GOLD;
        InIt();
        m_labelWin.text      = NumtoString(nGold);
        m_labelgametime.text = nTime.ToString() + "分钟";

        uint nMaxWin = 0;

        byte[] data = RuntimeInfo.GetLocalFile(RuntimeInfo.GameShareMaxWin());
        if (data != null)//第一次
        {
            nMaxWin = System.BitConverter.ToUInt32(data, 0);
        }

        if (nGold > nMaxWin)
        {
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            System.IO.BinaryWriter bw = new System.IO.BinaryWriter(ms);
            bw.Write(nGold);
            RuntimeInfo.SaveLocalFile(RuntimeInfo.GameShareMaxWin(), ms.ToArray());
        }

        m_labelmaxwin.text = NumtoString(nMaxWin);
    }
Exemplo n.º 3
0
    private bool LoadRoleRankXml(bool IsError = false)
    {
        if (IsError)
        {
            m_IsLoadXmlInfo = true;
            RankXmlMap.Clear();               //清空数据
            tagRankXmlChangeEvent pEvent = new tagRankXmlChangeEvent();
            MsgEventHandle.HandleMsg(pEvent); //添加排行榜XML文件读取成功的函数
            return(true);
        }
        //读取配置文件 并且加载到数据集合里面去
        DateTime time     = SystemTime.Instance.GetSystemDateTime;
        UInt32   WriteSec = FishConfig.Instance.GetWriteSec();

        time = time.AddSeconds(WriteSec * -1);
        string FileName = string.Format("Rank_{0}_{1}_{2}.xml", time.Year, time.Month, time.Day);

        Byte[]      FileText = RuntimeInfo.GetLocalFile(FileName);
        XmlDocument doc      = new XmlDocument();

        doc.LoadXml(System.Text.Encoding.UTF8.GetString(FileText));
        XmlElement pRankConfig = doc.DocumentElement;

        for (int i = 0; i < doc.ChildNodes.Count; ++i)
        {
            if (doc.ChildNodes[i].Name == "FishRanks")
            {
                for (int k = 0; k < doc.ChildNodes[i].ChildNodes.Count; ++k)
                {
                    if (doc.ChildNodes[i].ChildNodes[k].Name == "FishRook")
                    {
                        RankInfo pRankInfo = new RankInfo();
                        pRankInfo.RankID = Convert.ToByte(doc.ChildNodes[i].ChildNodes[k].Attributes["TypeID"].Value);

                        for (int j = 0; j < doc.ChildNodes[i].ChildNodes[k].ChildNodes.Count; ++j)
                        {
                            if (doc.ChildNodes[i].ChildNodes[k].ChildNodes[j].Name == "Info")
                            {
                                tagRankInfo pInfo = new tagRankInfo();
                                pInfo.bIndex   = Convert.ToByte(doc.ChildNodes[i].ChildNodes[k].ChildNodes[j].Attributes["Index"].Value);
                                pInfo.dwFaceID = Convert.ToUInt32(doc.ChildNodes[i].ChildNodes[k].ChildNodes[j].Attributes["FaceID"].Value);
                                pInfo.dwUserID = Convert.ToUInt32(doc.ChildNodes[i].ChildNodes[k].ChildNodes[j].Attributes["UserID"].Value);
                                pInfo.Gender   = Convert.ToByte(doc.ChildNodes[i].ChildNodes[k].ChildNodes[j].Attributes["Gender"].Value) == 1 ? true : false;
                                pInfo.NickName = Convert.ToString(doc.ChildNodes[i].ChildNodes[k].ChildNodes[j].Attributes["Name"].Value);
                                pInfo.TitleID  = Convert.ToByte(doc.ChildNodes[i].ChildNodes[k].ChildNodes[j].Attributes["TitleID"].Value);
                                pInfo.Param    = Convert.ToInt64(doc.ChildNodes[i].ChildNodes[k].ChildNodes[j].Attributes["Param"].Value);

                                pRankInfo.RankMap.Add(pInfo.bIndex, pInfo);
                            }
                        }
                        RankXmlMap.Add(pRankInfo.RankID, pRankInfo);
                    }
                }
                m_IsLoadXmlInfo = true;
                return(true);
            }
        }
        return(false);
    }
Exemplo n.º 4
0
    public void LoadAccountData()
    {
        byte[] data = RuntimeInfo.GetLocalFile(RuntimeInfo.GetAccountFileName());
        if (data == null)
        {
            Init();
            return;
        }
        System.IO.MemoryStream ms = new System.IO.MemoryStream(data);
        System.IO.BinaryReader br = new System.IO.BinaryReader(ms);
        this.KEY = br.ReadUInt32();
        if (this.KEY == ConstValue.FILE_END_MAGIC)
        {
            this.VER = br.ReadByte();
            this.TAG = br.ReadByte();

            this.AccountInfo.UID       = br.ReadString();
            this.bIsSavePassword       = true;
            this.AccountInfo.CRC1      = br.ReadUInt32();
            this.AccountInfo.CRC2      = br.ReadUInt32();
            this.AccountInfo.CRC3      = br.ReadUInt32();
            this.PhoneInfo.PhoneNumber = 0;
            this.bIsSavePhonePassword  = true;
            this.PhoneInfo.phoneCRC1   = 0;
            this.PhoneInfo.phoneCRC2   = 0;
            this.PhoneInfo.phoneCRC3   = 0;
        }
        else if (this.KEY == ConstValue.FILE_END_MAGIC + 1)
        {
            this.VER = br.ReadByte();
            this.TAG = br.ReadByte();

            this.AccountInfo.UID       = br.ReadString();
            this.bIsSavePassword       = br.ReadBoolean();
            this.AccountInfo.CRC1      = br.ReadUInt32();
            this.AccountInfo.CRC2      = br.ReadUInt32();
            this.AccountInfo.CRC3      = br.ReadUInt32();
            this.PhoneInfo.PhoneNumber = br.ReadUInt64();
            this.bIsSavePhonePassword  = br.ReadBoolean();
            this.PhoneInfo.phoneCRC1   = br.ReadUInt32();
            this.PhoneInfo.phoneCRC2   = br.ReadUInt32();
            this.PhoneInfo.phoneCRC3   = br.ReadUInt32();
        }
        ms.Close();
        br.Close();
    }
Exemplo n.º 5
0
    private bool LoadMonthRankXml(string FilePath, bool IsErrror = false)
    {
        Byte MonthID = GetMonthIDByFileName(FilePath);

        if (IsErrror)
        {
            tagMonthRankOnce pOnce = new tagMonthRankOnce();
            pOnce.MonthID    = MonthID;
            pOnce.FileName   = FilePath;
            pOnce.m_RankInfo = null;
            m_MonthRankMap.m_RankInfo.Remove(MonthID);
            m_MonthRankMap.m_RankInfo.Add(MonthID, pOnce);
            return(true);
        }
        //读取指定名称的战场的排行数据
        Byte[]      FileText = RuntimeInfo.GetLocalFile(FilePath);
        XmlDocument doc      = new XmlDocument();

        doc.LoadXml(System.Text.Encoding.UTF8.GetString(FileText));
        XmlElement       pFishMonth  = doc.DocumentElement;
        Byte             FileMonthID = Convert.ToByte(pFishMonth.Attributes["MonthID"].Value);
        tagMonthRankOnce pOnce2      = new tagMonthRankOnce();

        foreach (XmlNode var1 in pFishMonth.ChildNodes)
        {
            if (var1.Name == "RoleInfo")
            {
                tagMonthRank pRank = new tagMonthRank();
                pRank.Index     = Convert.ToByte(var1.Attributes["Index"].Value);
                pRank.UserID    = Convert.ToUInt32(var1.Attributes["UserID"].Value);
                pRank.NickName  = Convert.ToString(var1.Attributes["NickName"].Value);
                pRank.Socres    = Convert.ToUInt32(var1.Attributes["Socre"].Value);
                pRank.VipSocres = Convert.ToUInt32(var1.Attributes["VipSocre"].Value);
                pRank.FaceID    = Convert.ToUInt32(var1.Attributes["FaceID"].Value);
                pOnce2.m_RankInfo.Add(pRank.Index, pRank);
            }
        }
        pOnce2.MonthID  = FileMonthID;
        pOnce2.FileName = FilePath;
        if (m_MonthRankMap.m_RankInfo.ContainsKey(FileMonthID))
        {
            m_MonthRankMap.m_RankInfo.Remove(FileMonthID);
        }
        m_MonthRankMap.m_RankInfo.Add(FileMonthID, pOnce2);
        return(true);
    }
Exemplo n.º 6
0
    public bool LoadSubmarinePos()
    {
        //读取SD卡的潜艇位置
        byte[] data = RuntimeInfo.GetLocalFile(RuntimeInfo.GetSubmarinePosFileName());
        if (data == null)
        {
            return(false);
        }

        System.IO.MemoryStream ms = new System.IO.MemoryStream(data);
        System.IO.BinaryReader br = new System.IO.BinaryReader(ms);
        m_SubmarinePos = br.ReadByte();
        uint UserID = br.ReadUInt32();

        //m_SubmarinePos = data[0];

        if (UserID != PlayerRole.Instance.RoleInfo.RoleMe.GetUserID())
        {
            return(false);
        }
        return(true);
    }
    public bool LoadGuide()
    {
        //读取SD卡的潜艇位置
        byte[] data = RuntimeInfo.GetLocalFile(RuntimeInfo.GetMatchGuideFileName());
        if (data == null)
        {
            return(false);
        }

        System.IO.MemoryStream ms = new System.IO.MemoryStream(data);
        System.IO.BinaryReader br = new System.IO.BinaryReader(ms);
        m_IsMatchGuide = br.ReadByte();
        uint UserID = br.ReadUInt32();

        ms.Close();
        br.Close();
        if (UserID != PlayerRole.Instance.RoleInfo.RoleMe.GetUserID())
        {
            m_IsMatchGuide = 1;
        }
        return(true);
    }
Exemplo n.º 8
0
        public bool LoadAudioValue()
        {
            //读取SD卡的版本
            byte[] data = RuntimeInfo.GetLocalFile(RuntimeInfo.GetAudioFileName());
            if (data == null || data.Length != 2 * 4)
            {
                return(false);
            }

            for (int i = 0, idx = 0; i < 2; ++i, idx += 4)
            {
                float value = System.BitConverter.ToSingle(data, idx);
                if (i == 0)
                {
                    m_BgValue = value;
                }
                else
                {
                    m_Value = value;
                }
            }
            return(true);
        }