Пример #1
0
        public TurnGamePlayer getPlayerWithScreenPos(int screenPos, bool onlyHuman = false)
        {
            List <int> keys = new List <int>(clientsMap.Keys);

            foreach (int key in keys)
            {
                Client         client     = clientsMap[key];
                GamePlayer     gamePlayer = client.getPlayer(getId());
                TurnGamePlayer turnPlayer = (TurnGamePlayer)gamePlayer;
                if (turnPlayer.screenPos == screenPos)
                {
                    return(turnPlayer);
                }
            }

            if (onlyHuman)
            {
                return(null);
            }

            // if checking not only human check the robots
            keys = new List <int>(robotsMap.Keys);
            foreach (int key in keys)
            {
                TurnGamePlayer turnPlayer = (TurnGamePlayer)robotsMap[key];
                if (turnPlayer.screenPos == screenPos)
                {
                    return(turnPlayer);
                }
            }

            return(null);
        }
Пример #2
0
        public void notifyCurrentPlayerRobot(RobotInterface robot, CompletionCallback callback)
        {
            JesterLogger.log("TurnGameSpace.notifyCurrentPlayerRobot(), robot: " + robot);
            TurnGamePlayer robotPlayer = (TurnGamePlayer)robot;

            if (robotPlayer == null)
            {
                throw new Exception("NullPointerException()");
            }
            JesterLogger.log("TurnGameSpace.notifyCurrentPlayerRobot(), robot:2");
            this.currentPlayer = robotPlayer;
            JesterLogger.log("TurnGameSpace.notifyCurrentPlayerRobot(), robot:3");
            List <Object> objects = new List <Object>();

            objects.Add(robot);
            JesterLogger.log("TurnGameSpace.notifyCurrentPlayerRobot(), robot:4");
            eventQueue.addFunction(new Event(TurnGameProtocol.NOTIFY_CURRENT_PLAYER_ROBOT, objects));
            JesterLogger.log("TurnGameSpace.notifyCurrentPlayerRobot() out");
        }
Пример #3
0
        public void notifyCurrentPlayer(Client client, CompletionCallback callback)
        {
            JesterLogger.log("TurnGameSpace.notifyCurrentPlayer");
            int id = getId();

            JesterLogger.log("getId(): " + id);
            GamePlayer gamePlayer = client.getPlayer(id);

            JesterLogger.log("GamePlayer: " + gamePlayer);
            JesterLogger.log("GamePlayer2: " + gamePlayer.getName());
            this.currentPlayer = (TurnGamePlayer)gamePlayer;
            JesterLogger.log("GamePlayer3: " + this.currentPlayer);
            JesterLogger.log("TurnGameSpace.notifyCurrentPlayer, currentPlayer: " + currentPlayer.getId());

            List <Object> objects = new List <Object>();

            objects.Add(client);
            eventQueue.addFunction(new Event(TurnGameProtocol.NOTIFY_CURRENT_PLAYER, objects));
        }