예제 #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.SKILLARRAY:
            if (Index < 0)
            {
                m_Instance.ClearSkillArray(); break;
            }
            if (Index >= m_Instance.SizeSkillArray())
            {
                int Count = Index - m_Instance.SizeSkillArray() + 1;
                for (int i = 0; i < Count; i++)
                {
                    m_Instance.AddSkillArray(new SkillSkillObjWraperV1());
                }
            }
            m_Instance.GetSkillArray(Index).FromMemoryStream(new MemoryStream(updateBuffer));
            break;

        case SyncIdE.SHORTCUTARRAY:
            if (Index < 0)
            {
                m_Instance.ClearShortcutArray(); break;
            }
            if (Index >= m_Instance.SizeShortcutArray())
            {
                int Count = Index - m_Instance.SizeShortcutArray() + 1;
                for (int i = 0; i < Count; i++)
                {
                    m_Instance.AddShortcutArray(new SkillShortcutObjWraperV1());
                }
            }
            m_Instance.GetShortcutArray(Index).FromMemoryStream(new MemoryStream(updateBuffer));
            break;

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

        case SyncIdE.TALENTSKILL:
            if (Index < 0)
            {
                m_Instance.ClearTalentSkill(); break;
            }
            if (Index >= m_Instance.SizeTalentSkill())
            {
                int Count = Index - m_Instance.SizeTalentSkill() + 1;
                for (int i = 0; i < Count; i++)
                {
                    m_Instance.AddTalentSkill(new SkillTalentSlotWraperV1());
                }
            }
            m_Instance.GetTalentSkill(Index).FromMemoryStream(new MemoryStream(updateBuffer));
            break;

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

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

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

        case SyncIdE.LIFESKILLARRAY:
            if (Index < 0)
            {
                m_Instance.ClearLifeSkillArray(); break;
            }
            if (Index >= m_Instance.SizeLifeSkillArray())
            {
                int Count = Index - m_Instance.SizeLifeSkillArray() + 1;
                for (int i = 0; i < Count; i++)
                {
                    m_Instance.AddLifeSkillArray(new SkillSkillObjWraperV1());
                }
            }
            m_Instance.GetLifeSkillArray(Index).FromMemoryStream(new MemoryStream(updateBuffer));
            break;

        default:
            break;
        }

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