Exemplo n.º 1
0
        protected void Disconnect(IArenaCallback client)
        {
            if (avatarDictionary.Keys.ToList <IArenaCallback>().Exists(cl => cl.Equals(client)))
            {
                if (_isGameStarted)
                {
                    RobotAvatar robot;
                    avatarDictionary.TryGetValue(client, out robot);
                    removeRobotFromMap(robot.Color);

                    _disconnectedRobotAvatarList.Add(robot);
                    try
                    {
                        if (_currentMovesQueue.Exists(m => m.Client.Equals(client)))
                        {
                            _currentMovesQueue.Remove(_currentMovesQueue.Find(m => m.Client.Equals(client)));
                        }
                    }
                    catch (Exception e)
                    {
                        EventLog.WriteErrorToLog(strErrorLogPath, e);
                    }
                    _currentMovesQueue.Add(new Move(MoveType.Disconnect, _currentMap, client, avatarDictionary, avatarDictionary[client], Directions.Down, _currentRound));
                }

                try
                {
                    _currentMap.StartingPositionList.Find(pos => pos.X == avatarDictionary[client].InitialPosition.X && pos.Y == avatarDictionary[client].InitialPosition.Y).Used = false;
                }
                catch (Exception e)
                {
                    EventLog.WriteErrorToLog(strErrorLogPath, e);
                }
                colorList.Add(avatarDictionary[client].Color);
                PlayerDisconnectEvent(this, new PlayerLoginArgs(avatarDictionary[client]));
                EventLog.WriteMessageToLog(strLogPath, "Login of Client: " + avatarDictionary[client].Login + " DISCONNECTED");
                avatarDictionary.Remove(client);
                _numberOfLoggedRobots--;
            }
        }