/// <summary> /// 添加关系 /// </summary> private void OnRelationAdd(PacketBase packet) { c2ss.RelationAdd msg = packet as c2ss.RelationAdd; //判断数据有效性 if ((msg.target_id.type == eRelationAddType.Idx && msg.target_id.char_idx <= 0) || (msg.target_id.type == eRelationAddType.Name && string.IsNullOrEmpty(msg.target_id.char_name))) { return; } Player player = UnitManager.Instance.GetPlayerByClientUID(msg.client_uid); if (player == null) { Log.Debug("OnRelationAdd 未找到unit:" + msg.client_uid.srv_uid + ", " + msg.client_uid.conn_idx); return; } //不能加自己 if ((msg.target_id.type == eRelationAddType.Idx && msg.target_id.char_idx == player.char_idx) || (msg.target_id.type == eRelationAddType.Name && msg.target_id.char_name == player.char_name)) { return; } MemberRelation relation = RelationManager.Instance.GetMember(player.char_idx); if (relation != null) { relation.AddRelationClient(msg.target_id, msg.flag, msg.message); } }
/// <summary> /// 登入处理 /// </summary> private void OnPlayerLogin(long char_idx) { this.RemoveMember(char_idx); MemberRelation member = CommonObjectPools.Spawn <MemberRelation>(); member.Setup(char_idx); m_cache_members.Add(char_idx, member); }
/// <summary> /// 登入处理 /// </summary> private void OnPlayerLogin(long char_idx) { this.RemoveMember(char_idx); MemberRelation member = new MemberRelation(); member.Setup(char_idx); m_cache_members.Add(char_idx, member); }
/// <summary> /// 是否存在关系 /// </summary> public bool HaveRelationFlag(long char_idx, long target_char_idx, eRelationFlag flag) { MemberRelation member = this.GetMember(char_idx); if (member != null) { return(member.HaveRelationFlag(target_char_idx, flag)); } return(false); }
public void UpdateAttribute(long char_idx, eUnitModType type, string value) { MemberRelation member = null; foreach (var obj in m_cache_members) { member = obj.Value; member.UpdateAttribute(char_idx, type, value); } }
public void Tick() { MemberRelation member = null; foreach (var obj in m_cache_members) { member = obj.Value; member.Update(); } }
/// <summary> /// 操作 /// </summary> private void OnRelationApplyCommand(PacketBase packet) { ss2gl.RelationApplyCmd msg = packet as ss2gl.RelationApplyCmd; MemberRelation relation = RelationManager.Instance.GetMember(msg.char_idx); if (relation != null) { relation.ApplyRelationCommand(msg.event_idx, msg.target_char_idx, msg.cmd); } }
/// <summary> /// 列表 /// </summary> private void OnRelationList(PacketBase packet) { gl2ss.RelationList msg = packet as gl2ss.RelationList; MemberRelation relation = RelationManager.Instance.GetMember(msg.char_idx); if (relation != null) { relation.RelationListGL(msg.relation_info); } }
/// <summary> /// 赠送 /// </summary> private void OnRelationGive(PacketBase packet) { gl2ss.RelationGive msg = packet as gl2ss.RelationGive; MemberRelation relation = RelationManager.Instance.GetMember(msg.char_idx); if (relation != null) { relation.FriendGiveGL(msg.src_player_id, msg.item_id); } }
/// <summary> /// 移除关系 /// </summary> private void OnRelationRemove(PacketBase packet) { gl2ss.RelationRemove msg = packet as gl2ss.RelationRemove; MemberRelation relation = RelationManager.Instance.GetMember(msg.char_idx); if (relation != null) { relation.RemoveRelationGL(msg.target_idx); } }
/// <summary> /// 添加关系 /// </summary> private void OnRelationAdd(PacketBase packet) { gl2ss.RelationAdd msg = packet as gl2ss.RelationAdd; MemberRelation relation = RelationManager.Instance.GetMember(msg.char_idx); if (relation != null) { relation.AddRelationGL(msg.event_idx, msg.player_id, msg.flag, msg.message); } }
/// <summary> /// 赠送 /// </summary> private void OnRelationGive(PacketBase packet) { ss2gl.RelationGive msg = packet as ss2gl.RelationGive; MemberRelation relation = RelationManager.Instance.GetMember(msg.char_idx); if (relation == null) { return; } relation.FriendGiveCommand(msg.target_char_idx, msg.item_id); }
/// <summary> /// 添加关系 /// </summary> private void OnRelationAdd(PacketBase packet) { ss2gl.RelationAdd msg = packet as ss2gl.RelationAdd; MemberRelation relation = RelationManager.Instance.GetMember(msg.char_idx); if (relation == null) { return; } relation.AddRelationCommand(msg.target_id, msg.flag, msg.message); }
/// <summary> /// 登入处理 /// </summary> private void OnPlayerLogin(long char_idx) { MemberRelation member; if (m_cache_members.TryGetValue(char_idx, out member)) { member.SyncDataFromUnit(); return; } Log.Debug("请求加载玩家关系数据:" + char_idx); member = new MemberRelation(); m_cache_members.Add(char_idx, member); member.Setup(char_idx); }
/// <summary> /// 广播关系事件 /// </summary> /// <param name="char_idx"></param> /// <param name="evt"></param> private void BroadcastEvent(long char_idx, eRelationEvent evt) { Unit player = UnitManager.Instance.GetUnitByIdx(char_idx); if (player == null || !player.is_online) { return; } MemberRelation relation = RelationManager.Instance.GetMember(char_idx); if (relation == null) { return; } relation.OnBroadcastEvent(evt); }
/// <summary> /// 关系列表 /// </summary> private void OnRelationList(PacketBase packet) { c2ss.RelationList msg = packet as c2ss.RelationList; Player player = UnitManager.Instance.GetPlayerByClientUID(msg.client_uid); if (player == null) { Log.Debug("OnRelationList 未找到unit:" + msg.client_uid.srv_uid + ", " + msg.client_uid.conn_idx); return; } MemberRelation relation = RelationManager.Instance.GetMember(player.char_idx); if (relation != null) { relation.RelationListClient(); } }
/// <summary> /// 赠送 /// </summary> private void OnRelationGive(PacketBase packet) { c2ss.RelationGive msg = packet as c2ss.RelationGive; Player player = UnitManager.Instance.GetPlayerByClientUID(msg.client_uid); if (player == null) { Log.Debug("OnRelationGive 未找到unit:" + msg.client_uid.srv_uid + ", " + msg.client_uid.conn_idx); return; } MemberRelation relation = RelationManager.Instance.GetMember(player.char_idx); if (relation != null) { relation.FriendGiveClient(msg.target_char_idx, msg.item_id); } }
/// <summary> /// 操作 /// </summary> private void OnRelationApplyCommand(PacketBase packet) { c2ss.RelationApplyCmd msg = packet as c2ss.RelationApplyCmd; Player player = UnitManager.Instance.GetPlayerByClientUID(msg.client_uid); if (player == null) { Log.Debug("OnRelationApply 未找到unit:" + msg.client_uid.srv_uid + ", " + msg.client_uid.conn_idx); return; } MemberRelation relation = RelationManager.Instance.GetMember(player.char_idx); if (relation != null) { relation.ApplyCommandClient(msg.event_idx, msg.target_char_idx, msg.cmd); } }
public void Tick() { foreach (var obj in m_cache_members) { obj.Value.Update(); } int update_count = 0; MemberRelation member = null; foreach (var obj in m_cache_members) { member = obj.Value; if (member.NeedSave()) { member.Save(); if (++update_count > 60) { break; //当次循环最大保存数量 } } } }