Exemple #1
0
    private void OnRoleSkillDataResponse(byte[] buffer)
    {
        RoleSkillDataResponseProto proto = RoleSkillDataResponseProto.GetProto(buffer);

        GlobalInit.Instance.PlayerInfo.LoadSkill(proto);
        PlayerCtrl.Instance.LastInWorldMapId = m_LastInWorldMapId;
        SceneMgr.Instance.LoadToWorldMap(m_LastInWorldMapId);
    }
    public static RoleSkillDataResponseProto GetProto(byte[] buffer)
    {
        RoleSkillDataResponseProto proto = new RoleSkillDataResponseProto();

        using (MMO_MemoryStream ms = new MMO_MemoryStream(buffer))
        {
            proto.SkillCount        = (byte)ms.ReadByte();
            proto.CurrSkillDataList = new List <SkillData>();
            for (int i = 0; i < proto.SkillCount; i++)
            {
                SkillData _CurrSkillData = new SkillData();
                _CurrSkillData.SkillId    = ms.ReadInt();
                _CurrSkillData.SkillLevel = ms.ReadInt();
                _CurrSkillData.SlotsNode  = (byte)ms.ReadByte();
                proto.CurrSkillDataList.Add(_CurrSkillData);
            }
        }
        return(proto);
    }
        private void OnRoleSkillResponse(Role role)
        {
            RoleSkillDataResponseProto proto = new RoleSkillDataResponseProto();
            List <RoleSkillEntity>     list  = RoleSkillDBModel.Instance.GetList(condition: "[RoleId]=" + role.RoleId);

            if (list != null)
            {
                proto.SkillCount        = (byte)list.Count;
                proto.CurrSkillDataList = new List <RoleSkillDataResponseProto.SkillData>();
                for (int i = 0; i < list.Count; i++)
                {
                    proto.CurrSkillDataList.Add(new RoleSkillDataResponseProto.SkillData()
                    {
                        SkillId    = list[i].SkillId,
                        SkillLevel = list[i].SkillLevel,
                        SlotsNode  = list[i].SlotsNode
                    });
                }
            }
            role.ClientSocket.SendMsg(proto.ToArray());
        }
Exemple #4
0
    /// <summary> 加载角色已经学会的技能 </summary>
    /// <param name="proto">服务端返回的技能列表协议</param>
    public void LoadSkill(RoleSkillDataResponseProto proto)
    {
        SkillDic.Clear();
        int[] dataSkillIdArray = JobDBModel.Instance.Get(JobId).SkillAttackIdArray;
        SkillIdArrayBySlots = new int[dataSkillIdArray.Length];
        for (int i = 0; i < proto.CurrSkillDataList.Count; i++)
        {
            SkillDic[proto.CurrSkillDataList[i].SlotsNode] = new RoleSkillInfo()
            {
                SkillId    = proto.CurrSkillDataList[i].SkillId,
                SkillLevel = proto.CurrSkillDataList[i].SkillLevel,
                SlotsNode  = proto.CurrSkillDataList[i].SlotsNode
            };
            SkillIdArrayBySlots[proto.CurrSkillDataList[i].SlotsNode - 1] = proto.CurrSkillDataList[i].SkillId;
        }

        for (int i = 0; i < dataSkillIdArray.Length; i++)
        {
            bool isHave = false;
            for (int j = 0; j < SkillIdArrayBySlots.Length; j++)
            {
                if (dataSkillIdArray[i] == SkillIdArrayBySlots[j])
                {
                    isHave = true;
                }
            }
            if (!isHave)
            {
                for (int j = 0; j < SkillIdArrayBySlots.Length; j++)
                {
                    if (SkillIdArrayBySlots[j] == 0)
                    {
                        SkillIdArrayBySlots[j] = dataSkillIdArray[i];
                        break;
                    }
                }
            }
        }
    }