Beispiel #1
0
        public override bool BeforeInvoke(InvocationInfo info, out object returnValue)
        {
            // we can obtain the BattleMode instance from this call
            if (info.targetMethod.Equals("handleMessage"))
            {
                if (bm == null)
                {
                    bm = (BattleMode)info.target;
                }
                Message m = (Message)info.arguments[0];

                if (m is GameInfoMessage)
                {
                    GameInfoMessage gm = (GameInfoMessage)m;

                    if (new GameType(gm.gameType).isMultiplayer())                     // just multiplayer matches
                    {
                        try
                        {
                            String opponentName = getOpponentName(gm);

                            // now use the api to get the player's data
                            WebClientTimeOut wc = new WebClientTimeOut();
                            wc.TimeOut = 3000;
                            wc.DownloadStringCompleted += (sender, e) =>
                            {
                                parseJSONResult(e.Result, opponentName);
                            };
                            wc.DownloadStringAsync(new Uri("http://a.scrollsguide.com/player?fields=all&name=" + opponentName));
                        }
                        catch                         // could not get information
                        {
                        }
                    }
                }
            }

            returnValue = null;
            return(false);
        }
Beispiel #2
0
        public override bool BeforeInvoke(InvocationInfo info, out object returnValue)
        {
            // we can obtain the BattleMode instance from this call
            if (info.targetMethod.Equals("handleMessage"))
            {
                if (bm == null)
                {
                    bm = (BattleMode)info.target;
                }
                Message m = (Message)info.arguments[0];

                if (m is GameInfoMessage)
                {
                    GameInfoMessage gm = (GameInfoMessage)m;

                    if (new GameType(gm.gameType).isMultiplayer()) // just multiplayer matches
                    {
                        try
                        {
                            String opponentName = getOpponentName(gm);

                            // now use the api to get the player's data
                            WebClientTimeOut wc = new WebClientTimeOut();
                            wc.TimeOut = 3000;
                            wc.DownloadStringCompleted += (sender, e) =>
                                {
                                    parseJSONResult(e.Result, opponentName);
                                };
                            wc.DownloadStringAsync(new Uri("http://a.scrollsguide.com/player?fields=all&name=" + opponentName));
                        }
                        catch // could not get information
                        {

                        }
                    }
                }
            }

            returnValue = null;
            return false;
        }