Exemple #1
0
        private void receiveUpdate2(BoardInfo board)
        {
            if (form.boardByRound.ContainsValue(board))
            {
                return;
            }

            while (!freeze && temporaryBoard.Count != 0 && !temporaryBoard.ContainsKey(board.RoundID))
            {
                Thread.Sleep(100);
                if (!freeze && temporaryBoard.Count == 0)
                {
                    break;
                }
            }
            if (!freeze)
            {
                if (board.move != "")
                {
                    Action act = () =>
                    {
                        movePlayer(board.RoundID, board.move);
                    };
                    Thread thread = new Thread((new ThreadStart(act)));
                    thread.Start();
                }
                if (board.Monsters != "")
                {
                    Action act2 = () =>
                    {
                        moveGhost(board.RoundID, board.Monsters);
                    };
                    Thread thread2 = new Thread((new ThreadStart(act2)));
                    thread2.Start();
                }
                if (board.Coins != "")
                {
                    Action act3 = () =>
                    {
                        coinEaten(board.RoundID, board.Coins);
                    };
                    Thread thread3 = new Thread((new ThreadStart(act3)));
                    thread3.Start();
                }
                form.roundID = board.RoundID + 1;
                try
                {
                    form.boardByRound.Add(board.RoundID, board);
                }
                catch (Exception e)
                {
                    form.debugFunction("\r\nErrorID:" + form.roundID);
                }
            }
            else if (freeze)
            {
                temporaryBoard.Add(board.RoundID, board);
                return;
            }
        }