Esempio n. 1
0
        /// <summary>
        /// 用户离开
        /// </summary>
        /// <param name="client"></param>
        private void Leave(ClientPeer client)
        {
            SingleExecute.Instance.Execute(
                () =>
            {
                //玩家在线
                if (user.IsOnLine(client) == false)
                {
                    return;
                }

                int userId = user.GetIdByClient(client);
                if (fight.IsFightIng(userId) == false)
                {
                    return;
                }
                ///TODO  玩家离开导致报错
                FightRoom room = fight.GetRoomByUid(userId);

                room.LeaveUidList.Add(userId);
                Brocast(room, OpCode.FIGHT, FightCode.LEAVE_BRO, userId);

                //全跑了
                if (room.LeaveUidList.Count == 3)
                {
                    for (int i = 0; i < room.LeaveUidList.Count; i++)
                    {
                        UserModel model = user.GetModelByUserId(room.LeaveUidList[i]);
                        model.runCount++;
                        model.been -= (room.Mutiple * 1000) * 3;
                        model.exp  += 0;
                        user.Update(model);
                    }
                    fight.Destroy(room);
                }
            }
                );
        }