public override void processMessage(RawMessage message, User user)
        {
            if (user.player != null && user.player.playerState != Player.PlayerState.DEAD &&        // adam oyunda mi, ölü mü
                user.player.game.gameState == Science_Wars_Server.Game.GameState.PLAYTIME &&        // oyun pause olmamis ya da bitmemis degil mi?
                user.player.board.nextBoard.boardState != Board.BoardState.COLLAPSING)              // onumuzdeki board çöküyor mu?
            {
                int oldMinionTypeId = message.getInt("tid");
                int upgradedMinionTypeId = message.getInt("utid");

                if ((oldMinionTypeId < 0 || oldMinionTypeId >= user.player.availableMinions.Length) &&  // verilen typeId'ler mantikli.
                    (upgradedMinionTypeId < 0 || upgradedMinionTypeId >= user.player.availableMinions.Length))
                    return;

                if (user.player.availableMinions[oldMinionTypeId] == false || user.unlockedMinions[upgradedMinionTypeId] == false) // bu minionlar unlocked mi? (dikkat: birinin unlock durumuna bakiyoruz digerinin available durumuna )
                    return;

                if( checkIfMinionUpgradableTo( oldMinionTypeId, TypeIdGenerator.getMinionType(upgradedMinionTypeId) ) == false ) // bu minion verilen miniona upgrade edilebilir mi
                    return;

                Minion minion = (Minion) Activator.CreateInstance(TypeIdGenerator.getMinionType(upgradedMinionTypeId),user.player.game, user.player);   // bir instance olusturuyoruz. tek sebebi upgradeCost u ogrenmek. damn...

                if (user.player.trySpendCash(minion.getUpgradeCost()))
                {
                    user.player.availableMinions[oldMinionTypeId] = false;
                    user.player.availableMinions[upgradedMinionTypeId] = true;
                    OutgoingMessages.Game.GUpgradeMinionResult.sendMessage(user.player, oldMinionTypeId, upgradedMinionTypeId);
                }

            }
        }
		public override void processMessage (RawMessage message)
		{
            MutantEightLeggedMinion parentMinion = (MutantEightLeggedMinion) Engine.Game.getMinionById( message.getInt("iid"));

		    int spawningCount = message.getInt("c");

		    if (spawningCount == 0)
		        return;

		    int[] spawningIds = message.getIntArray("sid");
		    int[] deadIds = message.getIntArray("did");

            List<MutantEightLeggedSpawningMinion> spawnings = new List<MutantEightLeggedSpawningMinion>();
		    MutantEightLeggedSpawningMinion spawning;
		    Minion deadMinion;
		    for (int i = 0; i < spawningCount; i++)
		    {
		        deadMinion = Engine.Game.getMinionById(deadIds[i]);
		        if (deadMinion != null)
		        {
		            spawning = parentMinion.createSpawning();
		            spawning.instanceId = spawningIds[i];
                    spawnings.Add(spawning);
		            deadMinion.position.board.AddMinionSpecificPosition(spawning, deadMinion.position.pathPosition);
		        }
                
		    }

            Runner.Graphics.minion_mutantEightLegged_spawn(parentMinion,spawnings);
		}
Exemplo n.º 3
0
        public override void processMessage(RawMessage message)
        {
            int    tid    = message.getInt("tid");
            Minion minion = (Minion)System.Activator.CreateInstance(TypeIdGenerator.getMinionType(tid));

            User user = Assets.Scripts.Engine.Game.getUserById(message.getInt("uid"));

            if (user != null)           // random minionlarda null gelebilir.
            {
                minion.ownerPlayer = user.player;

                if (user.player == PlayerMe.self)
                {
                    PlayerMe.income += minion.getIncome();
                    PlayerMe.cash   -= minion.getCost();
                    Runner.Graphics.updateCashAndIncome();
                }
            }

            minion.instanceId                       = message.getInt("iid");
            minion.position                         = new MinionPosition();
            minion.position.pathPosition            = new PathPosition(0, 0);
            minion.position.board                   = Assets.Scripts.Engine.Game.getBoardById(message.getInt("bid"));
            minion.position.pathPosition.pointIndex = message.getInt("cid");
            minion.position.pathPosition.ratio      = message.getFloat("t");

            minion.position.board.AddMinion(minion);
            Runner.Graphics.createMinion(minion);
        }
        public override void processMessage(RawMessage message, User user)
        {
            if (user.player != null && user.player.playerState != Player.PlayerState.DEAD &&        // adam oyunda mi, ölü mü
                user.player.game.gameState == Science_Wars_Server.Game.GameState.PLAYTIME &&        // oyun pause olmamis ya da bitmemis degil mi?
                user.player.board.nextBoard.boardState != Board.BoardState.COLLAPSING)              // onumuzdeki board çöküyor mu?
            {
                int oldMinionTypeId      = message.getInt("tid");
                int upgradedMinionTypeId = message.getInt("utid");

                if ((oldMinionTypeId < 0 || oldMinionTypeId >= user.player.availableMinions.Length) &&  // verilen typeId'ler mantikli.
                    (upgradedMinionTypeId < 0 || upgradedMinionTypeId >= user.player.availableMinions.Length))
                {
                    return;
                }

                if (user.player.availableMinions[oldMinionTypeId] == false || user.unlockedMinions[upgradedMinionTypeId] == false) // bu minionlar unlocked mi? (dikkat: birinin unlock durumuna bakiyoruz digerinin available durumuna )
                {
                    return;
                }

                if (checkIfMinionUpgradableTo(oldMinionTypeId, TypeIdGenerator.getMinionType(upgradedMinionTypeId)) == false)    // bu minion verilen miniona upgrade edilebilir mi
                {
                    return;
                }

                Minion minion = (Minion)Activator.CreateInstance(TypeIdGenerator.getMinionType(upgradedMinionTypeId), user.player.game, user.player);   // bir instance olusturuyoruz. tek sebebi upgradeCost u ogrenmek. damn...

                if (user.player.trySpendCash(minion.getUpgradeCost()))
                {
                    user.player.availableMinions[oldMinionTypeId]      = false;
                    user.player.availableMinions[upgradedMinionTypeId] = true;
                    OutgoingMessages.Game.GUpgradeMinionResult.sendMessage(user.player, oldMinionTypeId, upgradedMinionTypeId);
                }
            }
        }
Exemplo n.º 5
0
		public override void processMessage (RawMessage message)
		{
			int tid = message.getInt("tid");
			Minion minion = (Minion) System.Activator.CreateInstance( TypeIdGenerator.getMinionType( tid ));
            
		    User user = Assets.Scripts.Engine.Game.getUserById(message.getInt("uid"));
		    if (user != null)   // random minionlarda null gelebilir.
		    {
		        minion.ownerPlayer = user.player;

		        if (user.player == PlayerMe.self)
		        {
		            PlayerMe.income += minion.getIncome();
		            PlayerMe.cash -= minion.getCost();
					Runner.Graphics.updateCashAndIncome();
		        }
		    }

			minion.instanceId = message.getInt("iid");
			minion.position = new MinionPosition();
			minion.position.pathPosition = new PathPosition(0,0);
			minion.position.board = Assets.Scripts.Engine.Game.getBoardById( message.getInt ("bid"));
			minion.position.pathPosition.pointIndex = message.getInt("cid");
			minion.position.pathPosition.ratio = message.getFloat("t");

			minion.position.board.AddMinion(minion);
			Runner.Graphics.createMinion(minion);
		}
Exemplo n.º 6
0
        public override void processMessage(RawMessage message)
        {
            Board board = Engine.Game.getBoardById(message.getInt("bid"));

            if (board != null)
            {
                int index = message.getInt("iob");
                if (board.towers[index] != null)
                {
                    board.towers[index].destroyable = true;
                }
            }
        }
Exemplo n.º 7
0
 public override void processMessage(RawMessage message)
 {
     Board board = Engine.Game.getBoardById(message.getInt("bid"));
     
     if (board != null)
     {
         int index = message.getInt("iob");
         if (board.towers[index] != null)
         {
             board.towers[index].destroyable = true;
         }
     }
 }
        public override void processMessage(RawMessage message)
        {
            Vector3 position = new Vector3(message.getFloat("x"), message.getFloat("y"), message.getFloat("z"));
 
            Minion targetMinion = Engine.Game.getMinionById(message.getInt("mid"));
            if (position != null && targetMinion != null)
            {
                Missile missile = (Missile)Activator.CreateInstance(TypeIdGenerator.getMissileType(message.getInt("tid")),
                    message.getInt("iid"), position, targetMinion);


                Engine.Game.AddMissile(missile);
                Runner.Graphics.createMissile(missile);
            }
        }
Exemplo n.º 9
0
        public override void processMessage(RawMessage message, User user)
        {
            if (user.player != null && user.player.playerState != Player.PlayerState.DEAD &&        // adam oyunda mi, ölü mü
                user.player.game.gameState == Science_Wars_Server.Game.GameState.PLAYTIME &&        // oyun pause olmamis ya da bitmemis degil mi?
                user.player.board.nextBoard.boardState != Board.BoardState.COLLAPSING)              // onumuzdeki board çöküyor mu?
            {
                int typeId = message.getInt("tid");

                if (typeId < 0 || typeId >= user.unlockedMinions.Length)
                {
                    return;
                }

                if (user.player.availableMinions[typeId] == false)  // bu availableMinions zaten sadece o scienceType a ait minionlara true iceriyor. Bir daha science type kontrolu yapmaya gerek yok
                {
                    return;
                }

                Minion minion = (Minion)Activator.CreateInstance(TypeIdGenerator.getMinionType(typeId), user.player.game, user.player);

                if (user.player.trySpendCash(minion.getCost()))
                {
                    // STATCODE
                    PlayerStats pStats = user.player.game.statTracker.getPlayerStatsOfPlayer(user.player);
                    pStats.minionsSend += 1;

                    user.player.addIncome(minion.getIncome());
                    user.player.board.nextBoard.AddMinion(minion);
                    OutgoingMessages.Game.GCreateMinionResult.sendMessage(user.player.game.players, minion);
                }
            }
        }
        public override void processMessage(RawMessage message)
        {
            Vector3 position = new Vector3(message.getFloat("x"), message.getFloat("y"), message.getFloat("z"));

            Minion targetMinion = Engine.Game.getMinionById(message.getInt("mid"));

            if (position != null && targetMinion != null)
            {
                Missile missile = (Missile)Activator.CreateInstance(TypeIdGenerator.getMissileType(message.getInt("tid")),
                                                                    message.getInt("iid"), position, targetMinion);


                Engine.Game.AddMissile(missile);
                Runner.Graphics.createMissile(missile);
            }
        }
Exemplo n.º 11
0
        public override void processMessage(RawMessage message)
        {
            MutantEightLeggedMinion parentMinion = (MutantEightLeggedMinion)Engine.Game.getMinionById(message.getInt("iid"));

            int spawningCount = message.getInt("c");

            if (spawningCount == 0)
            {
                return;
            }

            int[] spawningIds = message.getIntArray("sid");
            int[] deadIds     = message.getIntArray("did");

            List <MutantEightLeggedSpawningMinion> spawnings = new List <MutantEightLeggedSpawningMinion>();
            MutantEightLeggedSpawningMinion        spawning;
            Minion deadMinion;

            for (int i = 0; i < spawningCount; i++)
            {
                deadMinion = Engine.Game.getMinionById(deadIds[i]);
                if (deadMinion != null)
                {
                    spawning            = parentMinion.createSpawning();
                    spawning.instanceId = spawningIds[i];
                    spawnings.Add(spawning);
                    deadMinion.position.board.AddMinionSpecificPosition(spawning, deadMinion.position.pathPosition);
                }
            }

            Runner.Graphics.minion_mutantEightLegged_spawn(parentMinion, spawnings);
        }
Exemplo n.º 12
0
		public override void processMessage (RawMessage message)
		{
            Type currentMinionType = TypeIdGenerator.getMinionType(message.getInt("tid"));
            Type upgradedMinionType = TypeIdGenerator.getMinionType(message.getInt("utid"));


            for (int i = 0; i < PlayerMe.availableMinionTypes.Count; i++)
            {
                if (currentMinionType == PlayerMe.availableMinionTypes[i])
                {
                    PlayerMe.availableMinionTypes[i] = upgradedMinionType;
                    break;
                }
            }
			Runner.Graphics.upgradeMinion(currentMinionType,upgradedMinionType);
		}
Exemplo n.º 13
0
        public override void processMessage(RawMessage message, User user)
        {
            if (user.player != null && user.player.playerState != Player.PlayerState.DEAD &&        // adam oyunda mi, ölü mü
                user.player.game.gameState == Science_Wars_Server.Game.GameState.PLAYTIME &&        // oyun pause olmamis ya da bitmemis degil mi?
                user.player.board.nextBoard.boardState != Board.BoardState.COLLAPSING)              // onumuzdeki board çöküyor mu?
            {
                int typeId = message.getInt("tid");

                if (typeId < 0 || typeId >= user.unlockedMinions.Length)
                    return;

                if (user.player.availableMinions[typeId] == false)  // bu availableMinions zaten sadece o scienceType a ait minionlara true iceriyor. Bir daha science type kontrolu yapmaya gerek yok
                    return;

                Minion minion = (Minion) Activator.CreateInstance(TypeIdGenerator.getMinionType(typeId),user.player.game, user.player);

                if (user.player.trySpendCash(minion.getCost()))
                {

                    // STATCODE
                    PlayerStats pStats = user.player.game.statTracker.getPlayerStatsOfPlayer(user.player);
                    pStats.minionsSend += 1;

                    user.player.addIncome(minion.getIncome());
                    user.player.board.nextBoard.AddMinion(minion);
                    OutgoingMessages.Game.GCreateMinionResult.sendMessage(user.player.game.players, minion);
                }

            }
        }
Exemplo n.º 14
0
        public override void processMessage(RawMessage message)
        {
            FrankenScientistMinion parentMinion = (FrankenScientistMinion)Engine.Game.getMinionById(message.getInt("iid"));
            int stackCount = message.getInt("c");

            Runner.Graphics.minion_frankenScientist_stackChanged(parentMinion, stackCount);
        }
Exemplo n.º 15
0
        public override void processMessage(RawMessage message)
        {
            Type currentMinionType  = TypeIdGenerator.getMinionType(message.getInt("tid"));
            Type upgradedMinionType = TypeIdGenerator.getMinionType(message.getInt("utid"));


            for (int i = 0; i < PlayerMe.availableMinionTypes.Count; i++)
            {
                if (currentMinionType == PlayerMe.availableMinionTypes[i])
                {
                    PlayerMe.availableMinionTypes[i] = upgradedMinionType;
                    break;
                }
            }
            Runner.Graphics.upgradeMinion(currentMinionType, upgradedMinionType);
        }
Exemplo n.º 16
0
        public override void processMessage(RawMessage message)
        {
            bool result = message.getBool("r");

            if (result)
            {                
                UserMe.initializeUserMe(message.getInt("ui"),
                                        message.getUTF8String("un"),
                                        message.getInt("psp"),
                                        message.getInt("csp"),
                                        message.getInt("bsp"),
                                        message.getBoolArray("usn"));
            }
            else
                ;//TODO login fail. handle it
            
        }
Exemplo n.º 17
0
        public override void processMessage(RawMessage message)
        {
            bool result = message.getBool("r");

            if (result)
            {
                UserMe.initializeUserMe(message.getInt("ui"),
                                        message.getUTF8String("un"),
                                        message.getInt("psp"),
                                        message.getInt("csp"),
                                        message.getInt("bsp"),
                                        message.getBoolArray("usn"));
            }
            else
            {
                ;//TODO login fail. handle it
            }
        }
Exemplo n.º 18
0
        public override void processMessage(RawMessage message)
        {
            Board board = Engine.Game.getBoardById(message.getInt("bid"));
            if (board != null)
            {
                Tower ownerTower = board.towers[message.getInt("iob")];
                Minion targetMinion = Engine.Game.getMinionById(message.getInt("mid"));
                if (ownerTower != null && targetMinion != null)
                {
                    Missile missile = (Missile)Activator.CreateInstance(TypeIdGenerator.getMissileType(message.getInt("tid")),
                        message.getInt("iid"), ownerTower, targetMinion);


                    Engine.Game.AddMissile(missile);
                    Runner.Graphics.createMissile(missile);
                }
            }
        }
		public override void processMessage(RawMessage message)
		{
			int countOfPlayers = message.getInt ("c");
			int[] playerIDs = new int[countOfPlayers];
			int [] minionsKilled = new int[countOfPlayers];
			int[] minionsSend = new int[countOfPlayers];
			int[] towersBuilt = new int[countOfPlayers];
			int[] missilesFired = new int[countOfPlayers];
			int[] minionsPassed = new int[countOfPlayers];
			float[] moneyEarned = new float[countOfPlayers];
			float[] moneySpend = new float[countOfPlayers];
			int[] cashs = new int[countOfPlayers];
			int[] incomes = new int[countOfPlayers];

			playerIDs = message.getIntArray ("pids");
			minionsKilled = message.getIntArray ("mk");
			minionsSend = message.getIntArray ("ms");
			towersBuilt = message.getIntArray ("tb");
			missilesFired = message.getIntArray ("mf");
			minionsPassed = message.getIntArray ("mp");
			moneyEarned = message.getFloatArray ("mme");
			moneySpend = message.getFloatArray ("mms");
			cashs = message.getIntArray ("cs");
			incomes = message.getIntArray ("inc");

			Assets.Scripts.Engine.Game.statTracker = new StatTracker ();
			Assets.Scripts.Engine.Game.statTracker.playerStatsList = new List<PlayerStats>();

			for (int i = 0; i < countOfPlayers; i++) 
			{
				Player currentPlayer = null;
				foreach (Player player in Assets.Scripts.Engine.Game.players)
				{
					if(player.id == playerIDs[i])
					{
						currentPlayer = player;
						break;
					}
				}

				PlayerStats newStats = new PlayerStats(currentPlayer);
				newStats.minionsKilled = minionsKilled[i];
				newStats.minionsSend = minionsSend[i];
				newStats.towersBuilt = towersBuilt[i];
				newStats.missilesFired = missilesFired[i];
				newStats.minionsPassed = minionsPassed[i];
				newStats.moneyEarned = moneyEarned[i];
				newStats.moneySpend = moneySpend[i];
				newStats.cash = cashs[i];
				newStats.income = incomes[i];

				Assets.Scripts.Engine.Game.statTracker.playerStatsList.Add(newStats);
			}

			Runner.Graphics.displayEndGameStatistics ();

		}
        public override void processMessage(RawMessage message)
        {
            int countOfPlayers = message.getInt("c");

            int[]   playerIDs     = new int[countOfPlayers];
            int []  minionsKilled = new int[countOfPlayers];
            int[]   minionsSend   = new int[countOfPlayers];
            int[]   towersBuilt   = new int[countOfPlayers];
            int[]   missilesFired = new int[countOfPlayers];
            int[]   minionsPassed = new int[countOfPlayers];
            float[] moneyEarned   = new float[countOfPlayers];
            float[] moneySpend    = new float[countOfPlayers];
            int[]   cashs         = new int[countOfPlayers];
            int[]   incomes       = new int[countOfPlayers];

            playerIDs     = message.getIntArray("pids");
            minionsKilled = message.getIntArray("mk");
            minionsSend   = message.getIntArray("ms");
            towersBuilt   = message.getIntArray("tb");
            missilesFired = message.getIntArray("mf");
            minionsPassed = message.getIntArray("mp");
            moneyEarned   = message.getFloatArray("mme");
            moneySpend    = message.getFloatArray("mms");
            cashs         = message.getIntArray("cs");
            incomes       = message.getIntArray("inc");

            Assets.Scripts.Engine.Game.statTracker = new StatTracker();
            Assets.Scripts.Engine.Game.statTracker.playerStatsList = new List <PlayerStats>();

            for (int i = 0; i < countOfPlayers; i++)
            {
                Player currentPlayer = null;
                foreach (Player player in Assets.Scripts.Engine.Game.players)
                {
                    if (player.id == playerIDs[i])
                    {
                        currentPlayer = player;
                        break;
                    }
                }

                PlayerStats newStats = new PlayerStats(currentPlayer);
                newStats.minionsKilled = minionsKilled[i];
                newStats.minionsSend   = minionsSend[i];
                newStats.towersBuilt   = towersBuilt[i];
                newStats.missilesFired = missilesFired[i];
                newStats.minionsPassed = minionsPassed[i];
                newStats.moneyEarned   = moneyEarned[i];
                newStats.moneySpend    = moneySpend[i];
                newStats.cash          = cashs[i];
                newStats.income        = incomes[i];

                Assets.Scripts.Engine.Game.statTracker.playerStatsList.Add(newStats);
            }

            Runner.Graphics.displayEndGameStatistics();
        }
		public override void processMessage (RawMessage message)
		{
            FrankenScientistMinion parentMinion = (FrankenScientistMinion) Engine.Game.getMinionById( message.getInt("iid"));
            ScrapGolemMinion minion = parentMinion.createScrapGolem();

		    User user = Assets.Scripts.Engine.Game.getUserById(message.getInt("uid"));
		    if (user != null)   // random minionlarda null gelebilir.
		        minion.ownerPlayer = user.player;

			minion.instanceId = message.getInt("sid");
			minion.position = new MinionPosition();
			minion.position.pathPosition = new PathPosition(0,0);
			minion.position.board = Assets.Scripts.Engine.Game.getBoardById( message.getInt ("bid"));
			minion.position.pathPosition.pointIndex = message.getInt("cid");
			minion.position.pathPosition.ratio = message.getFloat("t");

			minion.position.board.AddMinion(minion);
            Runner.Graphics.minion_frankenScientist_spawn(parentMinion, minion);
		}
Exemplo n.º 22
0
        public override void processMessage(RawMessage message)
        {
            Board board = Engine.Game.getBoardById(message.getInt("bid"));

            if (board != null)
            {
                Tower  ownerTower   = board.towers[message.getInt("iob")];
                Minion targetMinion = Engine.Game.getMinionById(message.getInt("mid"));
                if (ownerTower != null && targetMinion != null)
                {
                    Missile missile = (Missile)Activator.CreateInstance(TypeIdGenerator.getMissileType(message.getInt("tid")),
                                                                        message.getInt("iid"), ownerTower, targetMinion);


                    Engine.Game.AddMissile(missile);
                    Runner.Graphics.createMissile(missile);
                }
            }
        }
        public override void processMessage(RawMessage message)
        {
            FrankenScientistMinion parentMinion = (FrankenScientistMinion)Engine.Game.getMinionById(message.getInt("iid"));
            ScrapGolemMinion       minion       = parentMinion.createScrapGolem();

            User user = Assets.Scripts.Engine.Game.getUserById(message.getInt("uid"));

            if (user != null)           // random minionlarda null gelebilir.
            {
                minion.ownerPlayer = user.player;
            }

            minion.instanceId                       = message.getInt("sid");
            minion.position                         = new MinionPosition();
            minion.position.pathPosition            = new PathPosition(0, 0);
            minion.position.board                   = Assets.Scripts.Engine.Game.getBoardById(message.getInt("bid"));
            minion.position.pathPosition.pointIndex = message.getInt("cid");
            minion.position.pathPosition.ratio      = message.getFloat("t");

            minion.position.board.AddMinion(minion);
            Runner.Graphics.minion_frankenScientist_spawn(parentMinion, minion);
        }
		public override void processMessage (RawMessage message)
		{
            FrankenScientistMinion parentMinion = (FrankenScientistMinion) Engine.Game.getMinionById( message.getInt("iid"));
            int stackCount = message.getInt("c");           		   
            Runner.Graphics.minion_frankenScientist_stackChanged(parentMinion, stackCount);
		}
Exemplo n.º 25
0
        public static void Run()
        {
            Chronos.setInterval(50);      // sunucu dongusunu her 50 milisaniyede tamamlayacak.

            while (true)
            {
                try
                {
                    while (true)
                    {
                        Chronos.waitForTheRightMoment();    // fps yi ayarliyor.
                        frameNumber++;

                        Client client;

                        while (justLeftClients.TryDequeue(out client))
                        {
                            if (clientUserMap.ContainsKey(client))
                            {
                                clientUserMap.Remove(client);
                            }
                            if (clientPlayerMap.ContainsKey(client))
                            {
                                clientPlayerMap.Remove(client);
                            }
                        }

                        //var tmp = arrivedMessages;  // mesajlari alip queue'ya atan koda yeni bir concurrentQueue verelim. o onu doldururken biz bunu bosaltalim.
                        //Interlocked.Exchange<ConcurrentQueue<MessageArrivedEventArgs>>(ref arrivedMessages, tmpArrivedMessages);    // TODO buranin fail olmayacagina emin ol.
                        //tmpArrivedMessages = tmp;
                        tmpArrivedMessages = arrivedMessages;

                        int maxMessagesPerIteration = 50;
                        MessageArrivedEventArgs messageArgs;
                        while (tmpArrivedMessages.TryDequeue(out messageArgs) && maxMessagesPerIteration-- > 0)
                        {
                            RawMessage message = messageArgs.message;
                            if (message.containsField("messageTypeId") == false)
                            {
                                continue;
                            }

                            IIncomingMessage incomingMessage;
                            if (TypeIdGenerator.incomingMessageIds.TryGetValue(message.getInt("messageTypeId"), out incomingMessage))
                            {
                                //Console.WriteLine(incomingMessage.GetType().Name);
                                incomingMessage.processMessage(messageArgs);
                            }
                        }

                        foreach (var arena in arenas)
                        {
                            arena.Update();
                        }
                        arenas.RemoveAll(a => a.awaitsDestruction);

                        queue.Update();
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString() + "\nStack Trace:\n" + e.StackTrace);
                }
            }
        }