コード例 #1
0
    public bool LoadFromBinary(byte[] bytes)
    {
        if (this.m_ReplayList == null)
        {
            this.m_ReplayList = new List <NkBattleReplay>();
        }
        else
        {
            this.m_ReplayList.Clear();
        }
        MemoryStream memoryStream = this.UnZipToStream(bytes);

        if (memoryStream == null)
        {
            return(false);
        }
        memoryStream.Position = 0L;
        using (BinaryReader binaryReader = new BinaryReader(memoryStream))
        {
            while (binaryReader.PeekChar() != -1)
            {
                NkBattleReplay nkBattleReplay = new NkBattleReplay();
                nkBattleReplay.fTime = binaryReader.ReadSingle();
                nkBattleReplay.nType = binaryReader.ReadInt32();
                nkBattleReplay.nSize = binaryReader.ReadInt32();
                nkBattleReplay.pData = binaryReader.ReadBytes(nkBattleReplay.nSize);
                this.m_ReplayList.Add(nkBattleReplay);
            }
        }
        this.bGS_BATTLE_INFO_NFY = false;
        this.bGS_BF_TURNINFO_NFY = false;
        this.m_szLoadFile        = string.Empty;
        return(true);
    }
コード例 #2
0
    public void SavePacket(byte[] btBuffer, int nType, int index, int nSize)
    {
        if (this.m_SaveList == null)
        {
            this.m_SaveList      = new List <NkBattleReplay>();
            this.m_fLogStartTime = 0f;
        }
        if (nType == 211 && this.m_fLogStartTime == 0f)
        {
            this.m_fLogStartTime = Time.time;
        }
        NkBattleReplay nkBattleReplay = new NkBattleReplay();

        if (this.m_fLogStartTime == 0f)
        {
            nkBattleReplay.fTime = 0f;
        }
        else
        {
            nkBattleReplay.fTime = Time.time - this.m_fLogStartTime;
        }
        nkBattleReplay.nType = nType;
        nkBattleReplay.nSize = nSize;
        nkBattleReplay.pData = new byte[nSize];
        Array.Copy(btBuffer, index, nkBattleReplay.pData, 0, nSize);
        this.m_SaveList.Add(nkBattleReplay);
    }
コード例 #3
0
    public void LoadReplayData()
    {
        if (this.m_bRequestWebReplay)
        {
            return;
        }
        if (this.m_szLoadFile == string.Empty)
        {
            this.m_szLoadFile = string.Format("{0}/battlereplay.dat", this.m_szDirectory);
        }
        else
        {
            this.m_szLoadFile = string.Format("{0}/{1}", this.m_szDirectory, this.m_szLoadFile);
        }
        string szLoadFile = this.m_szLoadFile;

        if (this.m_ReplayList == null)
        {
            this.m_ReplayList = new List <NkBattleReplay>();
        }
        else
        {
            this.m_ReplayList.Clear();
        }
        if (File.Exists(szLoadFile))
        {
            try
            {
                using (Stream stream = File.Open(szLoadFile, FileMode.Open))
                {
                    using (BinaryReader binaryReader = new BinaryReader(stream))
                    {
                        while (binaryReader.PeekChar() != -1)
                        {
                            NkBattleReplay nkBattleReplay = new NkBattleReplay();
                            nkBattleReplay.fTime = binaryReader.ReadSingle();
                            nkBattleReplay.nType = binaryReader.ReadInt32();
                            nkBattleReplay.nSize = binaryReader.ReadInt32();
                            nkBattleReplay.pData = binaryReader.ReadBytes(nkBattleReplay.nSize);
                            this.m_ReplayList.Add(nkBattleReplay);
                        }
                    }
                }
            }
            catch (Exception obj)
            {
                TsLog.LogWarning(obj);
            }
            this.bGS_BATTLE_INFO_NFY = false;
            this.bGS_BF_TURNINFO_NFY = false;
        }
        this.m_szLoadFile = string.Empty;
    }