Exemplo n.º 1
0
    public override bool BeforeInvoke(InvocationInfo info, out object returnValue)
    {
        if (info.TargetMethod().Equals("sendBattleRequest")) {
            GameLog.WriteLine (info.Arguments()[0]);
        }

        Log.WriteLine ("Client: "+info.Arguments()[0]);
        returnValue = null;
        return false;
    }
Exemplo n.º 2
0
 public void AfterInvoke(InvocationInfo info, ref object returnValue)
 {
     switch (info.TargetMethod ()) {
     case "Start":
         {
             if (playing) {
                 battleModeUI = (BattleModeUI)info.Target ();
                 endGameButton = ((GameObject)typeof(BattleModeUI).GetField ("endTurnButton", BindingFlags.NonPublic | BindingFlags.Instance).GetValue (info.Target()));
                 endGameButton.renderer.material.mainTexture = pauseButton;
                 battleModeUI.StartCoroutine ("FadeInEndTurn");
             }
         }
         break;
     case "Init":
         {
             if (playing) {
                 typeof(BattleModeUI).GetField("callback", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(info.Target(), this);
                 App.ChatUI.SetEnabled (true);
                 App.ChatUI.SetLocked (false);
                 App.ChatUI.Show (false);
                 App.ChatUI.SetCanOpenContextMenu (false);
                 //activate chat on replays but disable profile or trading menus (wired bugs)
             }
         }
         break;
     case "Raycast":
         {
             if (playing && endGameButton.renderer.material.mainTexture != pauseButton && endGameButton.renderer.material.mainTexture != playButton) {
                 //Console.WriteLine(endGameButton.renderer.material.mainTexture.height+" "+endGameButton.renderer.material.mainTexture.width);
                 if (paused) {
                     endGameButton.renderer.material.mainTexture = playButton;
                 } else {
                     endGameButton.renderer.material.mainTexture = pauseButton;
                 }
             }
         }
         break;
     }
 }
Exemplo n.º 3
0
        public override bool BeforeInvoke(InvocationInfo info, out object returnValue)
        {
            if (info.TargetMethod ().Equals ("getButtonRect")) {
                foreach (StackFrame frame in info.StackTrace().GetFrames()) {
                    if (frame.GetMethod ().Name.Contains ("BeforeInvoke"))
                        break;
                    if (frame.GetMethod ().Name.Contains ("drawEditButton")) {
                        returnValue = typeof(ProfileMenu).GetMethod ("getButtonRect", BindingFlags.NonPublic | BindingFlags.Instance).Invoke (info.Target(), new object[] { 2 });
                        return true;
                    }
                }
                returnValue = null;
                return false;
            }
            if (info.Target () is ProfileMenu && info.TargetMethod().Equals("Start") && App.SceneValues.profilePage.isMe()) {

                //list them
                recordList.Clear ();
                foreach (String file in Directory.GetFiles(this.OwnFolder()+Path.DirectorySeparatorChar+"Records")) {
                    if (file.EndsWith("sgr")) {

                        JsonMessageSplitter jsonms = new JsonMessageSplitter ();
                        String log = File.ReadAllText (file);
                        jsonms.feed(log);
                        jsonms.runParsing();
                        String line = jsonms.getNextMessage ();
                        bool searching = true;
                        String enemyName = null;
                        //String enemyId = null;
                        String deckName = null;
                        ResourceType type = ResourceType.NONE;

                        while (line != null && searching) {
                            try {
                                Message msg = Message.createMessage (Message.getMessageName(line), line);
                                if (msg is GameInfoMessage) {
                                    if ((msg as GameInfoMessage).white.Equals(App.Communicator.getUserScreenName())) {
                                        enemyName = (msg as GameInfoMessage).black;
                                        //enemyId = (msg as GameInfoMessage).getPlayerProfileId(TileColor.black);
                                    } else {
                                        enemyName = (msg as GameInfoMessage).white;
                                        //enemyId = (msg as GameInfoMessage).getPlayerProfileId(TileColor.white);
                                    }
                                    deckName = (msg as GameInfoMessage).deck;
                                }
                                if (msg is ActiveResourcesMessage) {
                                    type = (msg as ActiveResourcesMessage).types[0];
                                }
                                if (enemyName != null && type != ResourceType.NONE)
                                    searching = false;
                            } catch {}
                            jsonms.runParsing();
                            line = jsonms.getNextMessage ();
                        }

                        recordList.Add (new Record(File.GetCreationTime(file).ToLongDateString()+" - "+File.GetCreationTime(file).ToLongTimeString(), "VS "+enemyName+" - "+deckName, /*enemyId,*/ file, type));
                    }
                }

                recordListPopup = new GameObject ("Record List").AddComponent<UIListPopup> ();
                recordListPopup.transform.parent = ((ProfileMenu)info.Target()).transform;
                Rect frame = (Rect)typeof(ProfileMenu).GetField ("frameRect", BindingFlags.Instance | BindingFlags.NonPublic).GetValue (info.Target());
                recordListPopup.Init (new Rect(frame.center.x-frame.width/2.0f, frame.center.y-frame.height/2.0f+32.0f, frame.width, frame.height-(float)Screen.height*0.055f*3.0f), false, true, recordList, this, null, null, false, true, false, true, null, true, false);
                recordListPopup.enabled = true;
                recordListPopup.SetOpacity(1f);
            }
            if (info.TargetMethod().Equals("drawEditButton")) {
                Rect rect = (Rect)typeof(ProfileMenu).GetField ("frameRect", BindingFlags.Instance | BindingFlags.NonPublic).GetValue (info.Target());
                //LobbyMenu.drawShadowText (new Rect(rect.center.x-(float)Screen.width/8.0f/2.0f, rect.center.y-rect.height/2.0f-(float)Screen.height*0.055f*3.0f-40.0f, (float)Screen.width/8.0f, 35.0f), "Match History", Color.white);

                if ((bool)typeof(ProfileMenu).GetField ("showEdit", BindingFlags.Instance | BindingFlags.NonPublic).GetValue (info.Target())) {
                    recordListPopup.enabled = false;
                    recordListPopup.SetOpacity(0f);
                } else {
                    new ScrollsFrame (new Rect(rect.center.x-rect.width/2.0f-20.0f, rect.center.y-rect.height/2.0f, rect.width+40.0f, rect.height-(float)Screen.height*0.055f-20.0f)).AddNinePatch (ScrollsFrame.Border.DARK_CURVED, NinePatch.Patches.CENTER).Draw ();
                    recordListPopup.enabled = true;
                    recordListPopup.SetOpacity(1f);
                    GUIStyle labelSkin = (GUIStyle)typeof(ProfileMenu).GetField ("usernameStyle", BindingFlags.Instance | BindingFlags.NonPublic).GetValue (info.Target());
                    labelSkin.fontSize = 32;
                    GUI.Label (new Rect(rect.center.x-(float)Screen.width/6.0f/2.0f, rect.center.y-rect.height/2.0f-40.0f, (float)Screen.width/6.0f, 35.0f), "Match History", labelSkin);
                    if (LobbyMenu.drawButton((Rect)typeof(ProfileMenu).GetMethod ("getButtonRect", BindingFlags.NonPublic | BindingFlags.Instance).Invoke (info.Target(), new object[] { 0 }), "Load Replay", (GUISkin)typeof(ProfileMenu).GetField ("guiSkin", BindingFlags.Instance | BindingFlags.NonPublic).GetValue (info.Target()))) {
                        LoadReplay ();
                    }
                }
            }
            return player.BeforeInvoke (info, out returnValue);
        }
Exemplo n.º 4
0
        public bool BeforeInvoke(InvocationInfo info, out object returnValue)
        {
            switch ((String)info.TargetMethod ()) {
            case "OnGUI":
                {
                    if (playing) {
                        typeof(BattleMode).GetMethod ("deselectAllTiles", BindingFlags.Instance | BindingFlags.NonPublic).Invoke (info.Target(), null);
                    }
                    returnValue = null;
                    return false;

                }
            case "readNextMessage":
                {
                    if (playing) {
                        if (paused) {
                            returnValue = true;
                            return true;
                        }
                        if (readNextMsg == false) {
                            returnValue = true;
                            return true;
                        } else {
                            readNextMsg = false;
                        }
                    }
                }
                break;
            case "toggleMenu":
                {
                    if (playing) { //quit on Esc/Back Arrow
                        playing = false;
                        App.Communicator.setData ("");
                        //App.SceneValues.battleMode = new SceneValues.SV_BattleMode (false);
                        //App.Communicator.isActive = true;
                        SceneLoader.loadScene("_Lobby");
                        returnValue = null;
                        return true;
                    }
                }
                break;
            case "ShowEndTurn":
            //case "ShowReconnectPopup":
                {
                    if (playing) {
                        returnValue = null;
                        return true;
                    }
                }
                break;
            }

            returnValue = null;
            return false;
        }