コード例 #1
0
 public AIClient(PacManClient client, MultiPlayerInfo mpInfo)
 {
     this.client = client;
     this.client.SetAI(this);
     this.multiplayerInfo = mpInfo;
     this.locked          = false;
     this.gameData        = "";
     this.gameCommands    = new Queue <string>();
 }
コード例 #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;
 }
コード例 #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);
        }