Ejemplo n.º 1
0
 /// <summary>
 /// 离开队伍
 /// </summary>
 /// <param name="note"></param>
 /// <param name="team"></param>
 private void OutTeam(UserNote note, PlayerTeam team)
 {
     PlayerBusiness player = note.Player;
     if (team.RemoveMember(player))
     {
         var buffer = AmfCodec.Encode(TeamCommand.OutTeamR,
             new object[] { true, team.TeamID, player.ID, player.Name, null });
         if (player.SceneID == team.Captain.SceneID)
         {
             team.Captain.CallAll(buffer);
             //通知其它场景上的用户
             team.CallAway(buffer, team.Captain.SceneID);
         }
         else
         {
             player.Call(buffer);
             //通知其它场景上的用户
             team.CallAway(buffer, player.SceneID);
         }
     }
     var t = player.TeamInstance;
     if (t != null)
     {
         t.Exit(player, true);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 移交队长
 /// </summary>
 /// <param name="note"></param>
 /// <param name="team"></param>
 private void ChangeManager(UserNote note, PlayerTeam team)
 {
     string teamID = team.TeamID;
     string newCaptainID = note.GetString(0);
     PlayerBusiness newCaptain = team.TransferCaptain(newCaptainID);
     if (newCaptain != null)
     {
         //通知
         var buffer = AmfCodec.Encode(TeamCommand.ChangeManagerR, new object[] { teamID, newCaptainID });
         team.Captain.CallAll(buffer);
         team.CallAway(buffer, note.Player.SceneID);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 解散队伍
 /// </summary>
 /// <param name="note"></param>
 private void FreeTeam(UserNote note, PlayerTeam team)
 {
     if (m_teams.TryRemove(team.TeamID, out team))
     {
         var t = note.Player.TeamInstance;
         if (t != null)
         {
             t.Over();
         }
         team.FreeTeam();
         var buffer = AmfCodec.Encode(TeamCommand.FreeTeamR, new object[] { team.TeamID });
         note.Player.CallAll(buffer);
         team.CallAway(buffer, note.Player.SceneID);
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 暂时离开队伍
 /// </summary>
 /// <param name="note"></param>
 /// <param name="team"></param>
 private void AwayTeam(UserNote note, PlayerTeam team)
 {
     PlayerBusiness player = note.Player;
     if (player.TeamJob == TeamJob.Member && player.SetTeam(team, TeamJob.Away))
     {
         var buffer = AmfCodec.Encode(TeamCommand.AwayTeamR,
           new object[] { true, team.TeamID, player.ID, player.Name, null });
         player.CallAll(buffer);
         team.CallAway(buffer, team.Captain.SceneID);
     }
     else
     {
         player.Call(TeamCommand.AwayTeamR, false, team.TeamID, player.ID, player.Name,
             //player.TeamJob == TeamJob.Captain ? "队长不能暂离" : "你已暂离");
             player.TeamJob == TeamJob.Captain ? TipManager.GetMessage(ClientReturn.AwayTeam1) : TipManager.GetMessage(ClientReturn.AwayTeam2));
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 请出队伍
        /// </summary>
        /// <param name="note"></param>
        /// <param name="team"></param>
        private void KillMember(UserNote note, PlayerTeam team)
        {
            string memberID = note.GetString(0);
            PlayerBusiness memeber = team.RemoveMember(memberID);
            if (memeber != null)
            {
                var buffer = AmfCodec.Encode(TeamCommand.OutTeamR,
                    new object[] { true, team.TeamID, memberID, memeber.Name, null });

                team.Captain.CallAll(buffer);
                //通知其它场景上的用户
                team.CallAway(buffer, note.Player.SceneID);

                var t = memeber.TeamInstance;
                if (t != null)
                {
                    t.Exit(memeber, true);
                }
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 更新队伍信息
 /// </summary>
 /// <param name="note"></param>
 /// <param name="team"></param>
 private void UpdateTeam(UserNote note, PlayerTeam team)
 {
     Variant v = note.GetVariant(0);
     team.AutoInto = v.GetBooleanOrDefault("AutoAgree");
     team.ShieldAutoApply = v.GetBooleanOrDefault("ShieldAutoApply");
     team.Explain = v.GetStringOrDefault("Explain");
     team.Icon = v.GetStringOrDefault("Icon");
     var buffer = AmfCodec.Encode(TeamCommand.UpdateTeamR, new object[] { team });
     note.Player.CallAll(buffer);
     team.CallAway(buffer, note.Player.SceneID);
 }
Ejemplo n.º 7
0
        private void UserDisconnected(UserNote note, PlayerTeam team)
        {
            PlayerBusiness player = note.Player;
            if (player != team.Captain)
            {
                if (team.RemoveMember(player))
                {
                    //TODO:通知队员退出
                    var buffer = AmfCodec.Encode(TeamCommand.AwayTeamR,
                    new object[] { true, team.TeamID, player.ID, player.Name, null });
                    team.CallAway(buffer, player.SceneID);
                }
                return;
            }

            //队长退出
            if (team.Count > 1)
            {
                //转让队伍
                PlayerBusiness newCaptain = team.TransferCaptain(string.Empty, true);
                if (newCaptain != null)
                {
                    var buffer = AmfCodec.Encode(TeamCommand.ChangeManagerR, new object[] { team.TeamID, newCaptain.ID });
                    team.Captain.CallAll(buffer);
                    team.CallAway(buffer, newCaptain.SceneID);
                    return;
                }
            }
            FreeTeam(note, team);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 归队
        /// </summary>
        /// <param name="note"></param>
        /// <param name="team"></param>
        private void RejoinTeam(UserNote note, PlayerTeam team)
        {
            PlayerBusiness player = note.Player;
            if (player.TeamJob == TeamJob.Away)
            {
                if (player.SceneID != team.Captain.SceneID)
                {
                    //player.Call(TeamCommand.RejoinTeamR, false, team.TeamID, player.ID, player.Name,"您需要和队伍在同一场景中才能归队");
                    player.Call(TeamCommand.RejoinTeamR, false, team.TeamID, player.ID, player.Name, TipManager.GetMessage(ClientReturn.RejoinTeam1));
                    return;
                }
                if (player.SetTeam(team, TeamJob.Member))
                {
                    var buffer = AmfCodec.Encode(TeamCommand.RejoinTeamR,
                                                 new object[] { true, team.TeamID, player.ID, player.Name, null });

                    team.Captain.CallAll(buffer);
                    team.CallAway(buffer, team.Captain.SceneID);
                }
            }
        }