示例#1
0
        public static void joinGame(int roomName, Player player)
        {
            player.sendCommand(Command.joinGameCommand(0, roomName));
            player.gs = gss[roomName];
            if (player.gsID != player.gs.roomID)
            {
                player.score = 0;
            }
            gss[roomName].addPlayer(player);

            player.gsID = player.gs.roomID;
            if(gss[roomName].gameStarted)
            {
                Player[] lockedPlayerList;

                lock (playerList)
                {
                    lockedPlayerList = new Player[gss[roomName].playerList.Count];
                    gss[roomName].playerList.CopyTo(lockedPlayerList);
                }

                player.resetPosition();
                player.sendCommand(Command.startGameInProgressCommand(0, lockedPlayerList, gss[roomName].pelletList));
            }

            roomUpdateToAllPlayers(player.gs);

            Console.WriteLine(player.playerName + " has joined " + gss[roomName].roomName + ".");
            startStopGame(gss[roomName]);
        }
示例#2
0
        public void death(Player p)
        {
            p.isDead = true;
            p.resetPosition();
            Player[] lockedPlayerList;

            lock (playerList)
            {
                lockedPlayerList = new Player[playerList.Count];
                playerList.CopyTo(lockedPlayerList);
            }
            foreach (Player player in lockedPlayerList)
            {
                player.sendCommand(Command.deathCommand(0, p));
            }
            //p.isDead = false;
        }
示例#3
0
        public void eatPlayer(Player p1, Player p2)
        {
            p2.isDead = true;
            p1.increaseSize(p2.size);
            p1.addScore(10);
            p2.resetPosition();

            Player[] lockedPlayerList;

            lock (playerList)
            {
                lockedPlayerList = new Player[playerList.Count];
                playerList.CopyTo(lockedPlayerList);
            }
            foreach (Player player in lockedPlayerList)
            {
                player.sendCommand(Command.eatPlayerCommand(0, p1, p2));
            }
            //p2.isDead = false;
        }