Beispiel #1
0
    public void UpdateField(int Id, int Index, byte[] buff, int start, int len)
    {
        SyncIdE SyncId = (SyncIdE)Id;

        byte[] updateBuffer = new byte[len];
        Array.Copy(buff, start, updateBuffer, 0, len);
        int  iValue = 0;
        long lValue = 0;

        switch (SyncId)
        {
        case SyncIdE.GOODSARRAY:
            if (Index < 0)
            {
                m_Instance.ClearGoodsArray(); break;
            }
            if (Index >= m_Instance.SizeGoodsArray())
            {
                int Count = Index - m_Instance.SizeGoodsArray() + 1;
                for (int i = 0; i < Count; i++)
                {
                    m_Instance.AddGoodsArray(new TransportGoodsObjWraperV1());
                }
            }
            m_Instance.GetGoodsArray(Index).FromMemoryStream(new MemoryStream(updateBuffer));
            break;

        case SyncIdE.ASKNUM:
            GameAssist.ReadInt32Variant(updateBuffer, 0, out iValue);
            m_Instance.AskNum = iValue;
            break;

        case SyncIdE.HELPNUM:
            GameAssist.ReadInt32Variant(updateBuffer, 0, out iValue);
            m_Instance.HelpNum = iValue;
            break;

        case SyncIdE.REWARDARRY:
            if (Index < 0)
            {
                m_Instance.ClearRewardArry(); break;
            }
            if (Index >= m_Instance.SizeRewardArry())
            {
                int Count = Index - m_Instance.SizeRewardArry() + 1;
                for (int i = 0; i < Count; i++)
                {
                    m_Instance.AddRewardArry(new TransportRewardObjWraperV1());
                }
            }
            m_Instance.GetRewardArry(Index).FromMemoryStream(new MemoryStream(updateBuffer));
            break;

        case SyncIdE.REWARDFLAG:
            m_Instance.RewardFlag = BitConverter.ToBoolean(updateBuffer, 0);
            break;

        case SyncIdE.PICKTASKFLAG:
            m_Instance.PickTaskFlag = BitConverter.ToBoolean(updateBuffer, 0);
            break;

        default:
            break;
        }

        try
        {
            if (NotifySyncValueChanged != null)
            {
                NotifySyncValueChanged(Id, Index);
            }
        }
        catch
        {
            Ex.Logger.Log("TransportData.NotifySyncValueChanged catch exception");
        }
        updateBuffer.GetType();
        iValue++;
        lValue++;
    }