Beispiel #1
0
        public void Leave(Player player, bool kicked = false)
        {
            foreach (var member in Members)
            {
                if (member.Value.GameSession == null)
                {
                    continue;
                }
                if (kicked && member.Value.Id == Leader.Id)
                {
                    continue;
                }
                member.Value.SendCommand(GroupPlayerLeaveCommand.write(player.Id, kicked ? GroupPlayerLeaveCommand.KICK : GroupPlayerLeaveCommand.LEAVE));
            }

            if (Members.Count == 2)
            {
                Destroy();
            }
            else
            {
                player.Group = null;
                Members.TryRemove(player.Id, out player);
                if (player != Leader)
                {
                    SendInitToAll();
                }
                else
                {
                    ChangeLeader(Members.FirstOrDefault().Value);
                }
            }
        }
Beispiel #2
0
 public void Destroy()
 {
     Program.TickManager.RemoveTick(this);
     GameManager.Groups.Remove(this);
     foreach (var member in Members)
     {
         member.Value.Group = null;
         member.Value.SendCommand(GroupPlayerLeaveCommand.write(member.Value.Id, GroupPlayerLeaveCommand.LEAVE));
     }
 }