예제 #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.EQUIPARRAY:
            if (Index < 0)
            {
                m_Instance.ClearEquipArray(); break;
            }
            if (Index >= m_Instance.SizeEquipArray())
            {
                int Count = Index - m_Instance.SizeEquipArray() + 1;
                for (int i = 0; i < Count; i++)
                {
                    m_Instance.AddEquipArray(new EquipmentEquipInfoWraperV1());
                }
            }
            m_Instance.GetEquipArray(Index).FromMemoryStream(new MemoryStream(updateBuffer));
            break;

        case SyncIdE.WEAREQUIP:
            if (Index < 0)
            {
                m_Instance.ClearWearEquip(); break;
            }
            if (Index >= m_Instance.SizeWearEquip())
            {
                int Count = Index - m_Instance.SizeWearEquip() + 1;
                for (int i = 0; i < Count; i++)
                {
                    m_Instance.AddWearEquip(new EquipmentEquipInfoWraperV1());
                }
            }
            m_Instance.GetWearEquip(Index).FromMemoryStream(new MemoryStream(updateBuffer));
            break;

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

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

        default:
            break;
        }

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