Пример #1
0
        public static void Gen(List <PlayerControl> crewmates, List <PlayerControl> impostors)
        {
            //System.Console.WriteLine("LOVER2");
            if (crewmates.Count <= 0)
            {
                return;
            }
            if (crewmates.Count <= 1 && impostors.Count < 1)
            {
                return;
            }

            //System.Console.WriteLine("LOVER3");
            var b = UnityEngine.Random.RandomRangeInt(0, 3);

            if (b == 0 & impostors.Count < 1)
            {
                b = 1;
            }

            if (b != 0 & crewmates.Count <= 1)
            {
                b = 0;
            }

            //System.Console.WriteLine("LOVER4");
            var flag2   = b == 0;
            var num     = UnityEngine.Random.RandomRangeInt(0, crewmates.Count);
            var player1 = crewmates[num];

            crewmates.Remove(player1);
            PlayerControl player2;

            if (flag2)
            {
                var num2 = UnityEngine.Random.RandomRangeInt(0, impostors.Count);
                player2 = impostors[num2];
                impostors.Remove(player2);
            }
            else
            {
                var num2 = UnityEngine.Random.RandomRangeInt(0, crewmates.Count);
                player2 = crewmates[num2];
                crewmates.Remove(player2);
            }

            var writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                    (byte)CustomRPC.SetCouple, SendOption.Reliable, -1);

            writer.Write(player1.PlayerId);
            writer.Write(player2.PlayerId);
            writer.Write(b);
            var lover1 = new Lover(player1, 1, b == 0);
            var lover2 = new Lover(player2, 2, b == 0);

            lover1.OtherLover = lover2;
            lover2.OtherLover = lover1;

            AmongUsClient.Instance.FinishRpcImmediately(writer);
        }
Пример #2
0
        public static void Gen(List <PlayerControl> crewmates, List <PlayerControl> impostors)
        {
            var lovingImpostorEnabled = Random.RandomRangeInt(1, 101) <= CustomGameOptions.LovingImpostorOn;

            var canMakeCrewCrewLovers     = crewmates.Count >= 2;
            var canMakeCrewImpostorLovers = crewmates.Count >= 1 && impostors.Count >= 2 && lovingImpostorEnabled;

            if (!canMakeCrewCrewLovers && !canMakeCrewImpostorLovers)
            {
                return;
            }

            var lovingImpostor = canMakeCrewImpostorLovers;

            var num     = Random.RandomRangeInt(0, crewmates.Count);
            var player1 = crewmates[num];

            crewmates.Remove(player1);
            PlayerControl player2;

            if (lovingImpostor)
            {
                var num2 = Random.RandomRangeInt(0, impostors.Count);
                player2 = impostors[num2];
                impostors.Remove(player2);
            }
            else
            {
                var num2 = Random.RandomRangeInt(0, crewmates.Count);
                player2 = crewmates[num2];
                crewmates.Remove(player2);
            }

            var writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                    (byte)CustomRPC.SetCouple, SendOption.Reliable, -1);

            writer.Write(player1.PlayerId);
            writer.Write(player2.PlayerId);
            writer.Write(lovingImpostor);

            var lover1 = new Lover(player1, false, lovingImpostor);
            var lover2 = new Lover(player2, lovingImpostor, lovingImpostor);

            lover1.OtherLover = lover2;
            lover2.OtherLover = lover1;

            AmongUsClient.Instance.FinishRpcImmediately(writer);
        }