/// <summary> /// Broast all peers in team, beside self /// e.g BroadcastType is Chat /// e.g BroadcastType is Region,that will send same region action /// </summary> /// <param name="peer"></param> /// <param name="bundle"></param> public void BroadcastEvent(MarsPeer peer, Bundle bundle, BroadcastType broadcastType = BroadcastType.Notice) { Team team = null; List <MarsPeer> peerList = new List <MarsPeer>(); if (Rooms.TryGetValue(peer.team.teamId, out team) == true) { foreach (MarsPeer for_p in team.peers) { if (for_p != peer) { if (broadcastType == BroadcastType.Region) { if (peer.region != for_p.region || peer.region == Constants.SelectRole) { continue; } } peerList.Add(for_p); } } } if (peerList.Count > 0) { MarsPeer.BroadCastEvent(peerList, bundle); } }
void SetBroadMsg(Role role) { //get all online peers, in public region List <MarsPeer> peers = Actor.Instance.HandleAccountListOnlineBySamePos(this.marsPeer); if (peers.Count >= 0) { Bundle bundle = new Bundle(); bundle.role = role; bundle.cmd = Command.UpdatePlayer; MarsPeer.BroadCastEvent(peers, bundle); } }
private void GetEnterGameData(Role role) { Role newRole = new Role();//this.Role;//RoleMySQL.instance.getRoleByRoleId(roleId); if (newRole != null) { newRole.accountId = marsPeer.Role.accountId; newRole.roleId = marsPeer.Role.roleId; newRole.roleName = marsPeer.Role.roleName; newRole.sex = marsPeer.Role.sex; newRole.exp = marsPeer.Role.exp; newRole.profession = marsPeer.Role.profession; newRole.level = marsPeer.Role.level; newRole.expMax = ExpMySQL.instance.GetNextExp(marsPeer.Role.level + 1); PropertyValue pv = Property.instance.GetValueByK(newRole.profession); newRole.strength = pv.strength; newRole.stamina = pv.stamina; newRole.wit = pv.wit; newRole.agility = pv.agility; newRole.critical = pv.critical; bundle.onlineRoles = Actor.Instance.HandleRoleListOnlineBySamePos(this.marsPeer); bundle.role = newRole; } //get all online peers, in public region List <MarsPeer> peers = Actor.Instance.HandleAccountListOnlineBySamePos(this.marsPeer); //new Role if (peers.Count >= 0) { Role mRole = new Role(); mRole.roleId = newRole.roleId; mRole.roleName = newRole.roleName; mRole.profession = newRole.profession; Bundle mBundle = new Bundle(); mBundle.cmd = Command.AddNewPlayer; mBundle.role = mRole; MarsPeer.BroadCastEvent(peers, mBundle); } }
public override void ExecuteOperation(Command cmd, params object[] objs) { base.ExecuteOperation(cmd, objs); Message message = (Message)objs[0]; bundle.message = message; List <MarsPeer> peers = null;// new List<MarsPeer>(); switch (message.chatType) { case ChatType.World: peers = HandleWorldChat(); break; case ChatType.Team: HandleTeamChat(); return; } if (peers != null && peers.Count > 0) { MarsPeer.BroadCastEvent(peers, bundle); } }