Ejemplo n.º 1
0
        public override void UpdateBeforeMove(UpdateEventArgs e)
        {
            this.locked = true;

            // Execute all commands
            while (this.gameCommands.Count > 0)
            {
                string msgcmd = this.gameCommands.Dequeue();

                // Swap two players
                if (PacManClient.IsMsgCmd(msgcmd, "swap"))
                {
                    string[] data = PacManClient.TrimMsg(msgcmd).Split(new char[] { ',' });
                    this.multiplayerInfo.DoSwapUsers(int.Parse(data[0]), int.Parse(data[1]), this.Level.Ais);
                    this.Level.ResetPositions();
                }
            }

            // Update the level's information
            if (this.gameData != "")
            {
                this.Level.FromGameData(PacManClient.TrimMsg(this.gameData));
                this.gameData = "";
            }

            this.locked = false;
        }
Ejemplo n.º 2
0
 public void OnMessageReceived(string msg)
 {
     while (this.locked)
     {
         Thread.Sleep(1);
     }
     this.locked = true;
     if (PacManClient.IsMsgCmd(msg))
     {
         this.gameData = msg;
     }
     else
     {
         this.gameCommands.Enqueue(msg);
     }
     this.locked = false;
 }
Ejemplo n.º 3
0
        protected override void onMessage(string msg)
        {
            if (msg == null || msg == "")
            {
                return;
            }

            // The game is started, so delegate to the AI
            if (this.GameStarted() && msg[0] == '#')
            {
                this.ai.OnMessageReceived(msg);
                return;
            }

            // Some obvious cases
            if (msg == Server.Nickname || msg == Server.NicknameRetry)
            {
                this.SendMessage(this.MultiPlayerInfo.Me.Name);
                return;
            }

            // Manage lobby stuff
            if (PacManClient.IsMsgCmd(msg))
            {
                this.MultiPlayerInfo.FromGameData(msg.Substring(3));
                return;
            }
            if (PacManClient.IsMsgCmd(msg, "start"))
            {
                this.MultiPlayerInfo.StartGame();
                return;
            }

            // Some unexpected cases
            base.onMessage(msg);
        }