Ejemplo n.º 1
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;
     }
 }
Ejemplo n.º 2
0
        // Creates a GameState Message 
        public string create(BattleMode bm, BattleModeUI bmUI, bool whitesTurn)
        {
            BMPlayer leftPlayer= (BMPlayer)leftPlayerField.GetValue(bm);
            string leftPlayerName = leftPlayer.name;
            //string blackPlayerName = ((string)typeof(BattleMode).GetField("rightPlayerName", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(bm));
            //TileColor activeColor = ((TileColor)typeof(BattleMode).GetField("activeColor", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(bm));
            //int turnNumber = ((int)typeof(BattleMode).GetField("currentTurn", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(bm));
            GameType gameType = (GameType)gameTypeField.GetValue(bm);
            int secondsleft = -1;
            if (gameType == GameType.MP_RANKED) secondsleft = 90;
            if (gameType == GameType.MP_QUICKMATCH) secondsleft = 60;
            if (gameType == GameType.MP_LIMITED) secondsleft = 90;

            TileColor activeColor = TileColor.white;
            if (!whitesTurn) activeColor = TileColor.black;

            PlayerAssets whiteplayer = bmUI.GetResources(true);
            PlayerAssets blackplayer = bmUI.GetResources(false);
            if (leftPlayerName == blackPlayerName) 
            {
                whiteplayer = bmUI.GetResources(false);
                blackplayer = bmUI.GetResources(true);
            }

            //ResourceGroup whiteRessisAvail = ((ResourceGroup)typeof(BattleModeUI).GetField("leftAvailable", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(bmUI));
            //ResourceGroup blackRessisAvail = ((ResourceGroup)typeof(BattleModeUI).GetField("rightAvailable", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(bmUI));
            //ResourceGroup whiteRessisMax = ((ResourceGroup)typeof(BattleModeUI).GetField("leftMax", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(bmUI));
            //ResourceGroup blackRessisMax = ((ResourceGroup)typeof(BattleModeUI).GetField("rightMax", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(bmUI));

            string retval = "";
            //{"whiteGameState":{"playerName":"Easy AI","board":{"color":"white","tiles":[{"card":{"id":7837,"typeId":127,"tradable":true,"isToken":false,"level":0},"ap":4,"ac":2,"hp":3,"position":"1,0","buffs":[{"name":"Crown of Strength","description":"Enchanted unit gains +1 Attack and +2 Health.","type":"ENCHANTMENT"}]},{"card":{"id":7834,"typeId":126,"tradable":true,"isToken":false,"level":0},"ap":1,"ac":2,"hp":2,"position":"1,1"},{"card":{"id":7838,"typeId":127,"tradable":true,"isToken":false,"level":0},"ap":3,"ac":2,"hp":3,"position":"1,2"}],"idols":[10,10,0,10,9]},"assets":{"availableResources":{"DECAY":0,"ORDER":4,"ENERGY":0,"GROWTH":0},"outputResources":{"DECAY":0,"ORDER":5,"ENERGY":0,"GROWTH":0},"handSize":4,"librarySize":30,"graveyardSize":12}},"blackGameState":{"playerName":"fuj1n","board":{"color":"black","tiles":[{"card":{"id":6151538,"typeId":68,"tradable":false,"isToken":false,"level":0},"ap":5,"ac":1,"hp":4,"position":"2,1"},{"card":{"id":6151539,"typeId":68,"tradable":false,"isToken":false,"level":0},"ap":5,"ac":1,"hp":4,"position":"2,2"}],"idols":[10,6,10,10,10]},"assets":{"availableResources":{"DECAY":0,"ORDER":0,"ENERGY":6,"GROWTH":0},"outputResources":{"DECAY":0,"ORDER":0,"ENERGY":6,"GROWTH":0},"handSize":3,"librarySize":26,"graveyardSize":19}},"activeColor":"black","phase":"Main","turn":26,"hasSacrificed":false,"secondsLeft":-1,"msg":"GameState"}

            retval = "{\"whiteGameState\":{\"playerName\":\"" + whitePlayerName + "\",\"board\":{\"color\":\"white\",\"tiles\":[";
            //get cards:
            retval = retval + this.getTiles(bm, true);
            //],"idols":[10,10,0,10,9]},
            //get white idols
            retval = retval + "],\"idols\":[" + this.whiteIdols[0] + "," + this.whiteIdols[1] + "," + this.whiteIdols[2] + "," + this.whiteIdols[3] + "," + this.whiteIdols[4] + "]},";
            //board finished
            //"assets":{"availableResources":{"DECAY":0,"ORDER":4,"ENERGY":0,"GROWTH":0},"outputResources":{"DECAY":0,"ORDER":5,"ENERGY":0,"GROWTH":0},
            retval = retval + "\"assets\":{\"availableResources\":{\"DECAY\":" + whiteplayer.availableResources.DECAY + ",\"ORDER\":" + whiteplayer.availableResources.ORDER + ",\"ENERGY\":" + whiteplayer.availableResources.ENERGY + ",\"GROWTH\":" + whiteplayer.availableResources.GROWTH + ",\"SPECIAL\":" + whiteplayer.availableResources.SPECIAL + "},";
            retval = retval + "\"outputResources\":{\"DECAY\":" + whiteplayer.outputResources.DECAY + ",\"ORDER\":" + whiteplayer.outputResources.ORDER + ",\"ENERGY\":" + whiteplayer.outputResources.ENERGY + ",\"GROWTH\":" + whiteplayer.outputResources.GROWTH + ",\"SPECIAL\":" + whiteplayer.outputResources.SPECIAL + "},";
            //"handSize":4,"librarySize":30,"graveyardSize":12}},
            retval = retval + "\"handSize\":" + whiteplayer.handSize + ",\"librarySize\":" + whiteplayer.librarySize +",\"graveyardSize\":" + whiteplayer.graveyardSize +"}},";
            
            //black
            //"blackGameState":{"playerName":"Easy AI","board":{"color":"black","tiles":[{"card":{"id":6151538,"typeId":68,"tradable":false,"isToken":false,"level":0},"ap":5,"ac":1,"hp":4,"position":"2,1"},{"card":{"id":6151539,"typeId":68,"tradable":false,"isToken":false,"level":0},"ap":5,"ac":1,"hp":4,"position":"2,2"}
            retval = retval + "\"blackGameState\":{\"playerName\":\"" + blackPlayerName + "\",\"board\":{\"color\":\"black\",\"tiles\":[";

            retval = retval + this.getTiles(bm, false);
            // ],"idols":[10,6,10,10,10]},
            retval = retval + "],\"idols\":[" + this.blackIdols[0] + "," + this.blackIdols[1] + "," + this.blackIdols[2] + "," + this.blackIdols[3]  +"," + this.blackIdols[4] + "]},";
            //board finished
            //"assets":{"availableResources":{"DECAY":0,"ORDER":0,"ENERGY":6,"GROWTH":0},"outputResources":{"DECAY":0,"ORDER":0,"ENERGY":6,"GROWTH":0},
            retval = retval + "\"assets\":{\"availableResources\":{\"DECAY\":" + blackplayer.availableResources.DECAY + ",\"ORDER\":" + blackplayer.availableResources.ORDER + ",\"ENERGY\":" + blackplayer.availableResources.ENERGY + ",\"GROWTH\":" + blackplayer.availableResources.GROWTH + ",\"SPECIAL\":" + whiteplayer.availableResources.SPECIAL + "},";
            retval = retval + "\"outputResources\":{\"DECAY\":" + blackplayer.outputResources.DECAY + ",\"ORDER\":" + blackplayer.outputResources.ORDER + ",\"ENERGY\":" + blackplayer.outputResources.ENERGY + ",\"GROWTH\":" + blackplayer.outputResources.GROWTH + ",\"SPECIAL\":" + whiteplayer.outputResources.SPECIAL + "},";
            //"handSize":3,"librarySize":26,"graveyardSize":19}},
            retval = retval + "\"handSize\":" + blackplayer.handSize + ",\"librarySize\":" + blackplayer.librarySize + ",\"graveyardSize\":" + blackplayer.graveyardSize + "}},";
            //"activeColor":"black","phase":"Main","turn":26,"hasSacrificed":false,"secondsLeft":-1,"msg":"GameState"}

            retval = retval + "\"activeColor\":\"" + activeColor.ToString() +"\",\"phase\":\"Main\",\"turn\":"+ this.turnnumber + ",\"hasSacrificed\":false,\"secondsLeft\":" + secondsleft + ",\"msg\":\"GameState\"}";
            
            return retval;
        }
Ejemplo n.º 3
0
 public void setBmUI(BattleModeUI bui)
 {
     this.bttlmdUI = bui;
 }