示例#1
0
        private static IEnumerator IDoRematch(GM_ArmsRace __instance)
        {
            if (!PhotonNetwork.OfflineMode)
            {
                __instance.GetComponent <PhotonView>().RPC("RPCA_PlayAgain", RpcTarget.All, new object[] { });
                UIHandler.instance.DisplayScreenTextLoop("WAITING");
                float c = 0f;
                while (waitingForOtherPlayers < PlayerAssigner.instance.maxPlayers)
                {
                    c += Time.unscaledDeltaTime;
                    if (c > 10f)
                    {
                        DoRestart();
                        yield break;
                    }
                    yield return(null);
                }
                for (int i = 0; i < PlayerManager.instance.players.Count; i++)
                {
                    PlayerManager.instance.players[i].data.currentCards.Clear();
                }
                if (PlayerManager.instance.players.Count >= 3)
                {
                    var children = GameObject.Find("P3").GetComponentsInChildren <ProceduralImage>();
                    foreach (var child in children)
                    {
                        child.GetComponent <ProceduralImage>().color = new Color(0.3387f, 0.3696f, 0.4057f);
                        child.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f);
                    }
                }
                if (PlayerManager.instance.players.Count == 4)
                {
                    var children2 = GameObject.Find("P4").GetComponentsInChildren <ProceduralImage>();
                    foreach (var child in children2)
                    {
                        child.GetComponent <ProceduralImage>().color = new Color(0.3387f, 0.3696f, 0.4057f);
                        child.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f);
                    }
                }
            }
            yield return(null);

            UIHandler.instance.StopScreenTextLoop();
            AccessTools.Method(typeof(PlayerManager), "ResetCharacters").Invoke(PlayerManager.instance, null);
            ResetMatch(__instance);
            var doStartGame = AccessTools.Method(typeof(GM_ArmsRace), "DoStartGame").Invoke(__instance, null);

            __instance.StartCoroutine((IEnumerator)doStartGame);
            waitingForOtherPlayers = 0;
            yield break;
        }
示例#2
0
 private static void ResetMatch(GM_ArmsRace __instance)
 {
     __instance.p1Points = 0;
     __instance.p1Rounds = 0;
     __instance.p2Points = 0;
     __instance.p2Rounds = 0;
     p3Points            = 0;
     p4Points            = 0;
     p3Rounds            = 0;
     p4Rounds            = 0;
     //this.isTransitioning = false;
     AccessTools.Field(typeof(GM_ArmsRace), "isTransitioning").SetValue(__instance, false);
     waitingForOtherPlayers = 0;
     UIHandler.instance.ShowRoundCounterSmall(__instance.p1Rounds, __instance.p2Rounds, __instance.p1Points, __instance.p2Points);
     CardBarHandler.instance.ResetCardBards();
     PointVisualizer.instance.ResetPoints();
 }
示例#3
0
 private static bool Prefix(ref IEnumerator __result, GM_ArmsRace __instance)
 {
     __result = IDoRematch(__instance);
     return(false);
 }
示例#4
0
        private static bool Prefix(GM_ArmsRace ___gm, ref int ___currentCrownHolder, GameCrownHandler __instance)
        {
            previousCrownHolder = 0;
            int[] rounds = new int[4]
            {
                ___gm.p1Rounds,
                ___gm.p2Rounds,
                GM_ArmsRacePatch.p3Rounds,
                GM_ArmsRacePatch.p4Rounds
            };
            int[] points = new int[4]
            {
                ___gm.p1Points,
                ___gm.p2Points,
                GM_ArmsRacePatch.p3Points,
                GM_ArmsRacePatch.p4Points
            };
            int maxRounds   = rounds.Max();
            int atMaxRounds = rounds.Count(x => x == maxRounds);
            int num         = -1;
            int num2        = -1;

            if (atMaxRounds == 1)
            {
                if (rounds[0] == maxRounds)
                {
                    num2 = 0;
                }
                if (rounds[1] == maxRounds)
                {
                    num2 = 1;
                }
                if (rounds[2] == maxRounds)
                {
                    num2 = 2;
                }
                if (rounds[3] == maxRounds)
                {
                    num2 = 3;
                }
            }
            if (num2 == -1)
            {
                int num3 = -1;
                if (atMaxRounds > 1)
                {
                    int winner         = -1;
                    int withMostPoints = 0;
                    for (int i = 0; i < PlayerManager.instance.players.Count; i++)
                    {
                        if (rounds[i] == maxRounds)
                        {
                            if (points[i] == 1)
                            {
                                winner          = i;
                                withMostPoints += 1;
                            }
                            if (withMostPoints == 2)
                            {
                                winner = -1;
                                break;
                            }
                        }
                    }
                    if (winner == 0)
                    {
                        num3 = 0;
                    }
                    if (winner == 1)
                    {
                        num3 = 1;
                    }
                    if (winner == 2)
                    {
                        num3 = 2;
                    }
                    if (winner == 3)
                    {
                        num3 = 3;
                    }
                    if (num3 != -1)
                    {
                        num = num3;
                    }
                }
            }
            else
            {
                num = num2;
            }
            if (num != -1 && num != ___currentCrownHolder)
            {
                if (___currentCrownHolder == -1)
                {
                    ___currentCrownHolder = num;
                    __instance.GetComponent <CurveAnimation>().PlayIn();
                    return(false);
                }
                previousCrownHolder = ___currentCrownHolder;
                // this.GiveCrownToPlayer(num);
                AccessTools.Method(typeof(GameCrownHandler), "GiveCrownToPlayer").Invoke(__instance, new object[] { num });
            }
            return(false);
        }