コード例 #1
0
            static void Postfix([HarmonyArgument(0)] byte srcPlayerId, [HarmonyArgument(1)] sbyte suspectPlayerId)
            {
                var source = Helpers.playerById(srcPlayerId);

                if (source != null && source.Data != null && AmongUsClient.Instance.AmHost && TheOtherRolesPlugin.HostSeesVotesLog.Value)
                {
                    string target = null;
                    if (suspectPlayerId == -2)
                    {
                        target = "didn't vote";
                    }
                    else if (suspectPlayerId == -1)
                    {
                        target = "skipped";
                    }
                    else if (suspectPlayerId >= 0)
                    {
                        System.Console.WriteLine(suspectPlayerId);
                        System.Console.WriteLine((byte)suspectPlayerId);
                        var targetPlayer = Helpers.playerById((byte)suspectPlayerId);
                        if (targetPlayer != null && targetPlayer.Data != null)
                        {
                            target = $"voted {targetPlayer.Data.PlayerName}";
                        }
                    }

                    if (target != null)
                    {
                        System.Console.WriteLine($"{source.Data.PlayerName} {target}");
                    }
                }
            }
コード例 #2
0
ファイル: Munou.cs プロジェクト: haoming37/TheOtherRoles
        public static void randomColors()
        {
            // 発生確率
            int random = rnd.Next(100);

            if (random > probability)
            {
                return;
            }

            var         allPlayers   = PlayerControl.AllPlayerControls;
            List <byte> alivePlayers = new List <byte>();
            List <int>  tempList     = new List <int>();

            foreach (var p in allPlayers)
            {
                if (p.PlayerId == PlayerControl.LocalPlayer.PlayerId)
                {
                    continue;
                }
                if (p == Puppeteer.dummy)
                {
                    continue;
                }
                if (p.isAlive())
                {
                    alivePlayers.Add(p.PlayerId);
                }
            }
            alivePlayers.shuffle();
            List <byte> shuffleTargets = alivePlayers.Count > numShufflePlayers?alivePlayers.Take(numShufflePlayers).ToList() : alivePlayers;

            foreach (byte id in shuffleTargets)
            {
                if (id == PlayerControl.LocalPlayer.PlayerId)
                {
                    continue;
                }
                var p = Helpers.playerById(id);
                int rnd;
                int coutner = 0;
                while (true)
                {
                    rnd = TheOtherRoles.rnd.Next(shuffleTargets.Count);
                    if (shuffleTargets[rnd] == PlayerControl.LocalPlayer.PlayerId)
                    {
                        continue;
                    }
                    if (!tempList.Contains(rnd))
                    {
                        tempList.Add(rnd);
                        break;
                    }
                    coutner++;
                }
                var to = Helpers.playerById((byte)shuffleTargets[rnd]);
                MorphHandler.morphToPlayer(p, to);
            }
            randomColorFlag = true;
        }
コード例 #3
0
ファイル: RPC.cs プロジェクト: fantahund/TheOtherRoles
        public static void setUncheckedColor(byte colorId, byte playerId)
        {
            var player = Helpers.playerById(playerId);

            if (player != null)
            {
                player.SetColor(colorId);
            }
        }
コード例 #4
0
        static void resetNameTagsAndColors()
        {
            Dictionary <byte, PlayerControl> playersById = Helpers.allPlayersById();

            foreach (PlayerControl player in PlayerControl.AllPlayerControls)
            {
                player.nameText.text = hidePlayerName(PlayerControl.LocalPlayer, player) ? "" : player.Data.PlayerName;
                if (PlayerControl.LocalPlayer.Data.IsImpostor && player.Data.IsImpostor)
                {
                    player.nameText.color = Palette.ImpostorRed;
                }
                else
                {
                    player.nameText.color = Color.white;
                }
            }
            if (MeetingHud.Instance != null)
            {
                foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates)
                {
                    PlayerControl playerControl = playersById.ContainsKey((byte)player.TargetPlayerId) ? playersById[(byte)player.TargetPlayerId] : null;
                    if (playerControl != null)
                    {
                        player.NameText.text = playerControl.Data.PlayerName;
                        if (PlayerControl.LocalPlayer.Data.IsImpostor && playerControl.Data.IsImpostor)
                        {
                            player.NameText.color = Palette.ImpostorRed;
                        }
                        else
                        {
                            player.NameText.color = Color.white;
                        }
                    }
                }
            }
            if (PlayerControl.LocalPlayer.Data.IsImpostor)
            {
                List <PlayerControl> impostors = PlayerControl.AllPlayerControls.ToArray().ToList();
                impostors.RemoveAll(x => !x.Data.IsImpostor);
                foreach (PlayerControl player in impostors)
                {
                    player.nameText.color = Palette.ImpostorRed;
                }
                if (MeetingHud.Instance != null)
                {
                    foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates)
                    {
                        PlayerControl playerControl = Helpers.playerById((byte)player.TargetPlayerId);
                        if (playerControl != null && playerControl.Data.IsImpostor)
                        {
                            player.NameText.color = Palette.ImpostorRed;
                        }
                    }
                }
            }
        }
コード例 #5
0
        static void resetNameTagsAndColors()
        {
            Dictionary <byte, PlayerControl> playersById = Helpers.allPlayersById();

            foreach (PlayerControl player in PlayerControl.AllPlayerControls)
            {
                player.nameText.Text = player.IDOFAMCIJKE.HGGCLJHCDBM;
                if (PlayerControl.LocalPlayer.IDOFAMCIJKE.CIDDOFDJHJH && player.IDOFAMCIJKE.CIDDOFDJHJH)
                {
                    player.nameText.Color = Palette.LDCHDOFJPGH;
                }
                else
                {
                    player.nameText.Color = Color.white;
                }
            }
            if (MeetingHud.Instance != null)
            {
                foreach (PlayerVoteArea player in MeetingHud.Instance.DHCOPOOJCLN)
                {
                    PlayerControl playerControl = playersById.ContainsKey((byte)player.HMPHKKGPLAG) ? playersById[(byte)player.HMPHKKGPLAG] : null;
                    if (playerControl != null)
                    {
                        player.NameText.Text = playerControl.IDOFAMCIJKE.HGGCLJHCDBM;
                        if (PlayerControl.LocalPlayer.IDOFAMCIJKE.CIDDOFDJHJH && playerControl.IDOFAMCIJKE.CIDDOFDJHJH)
                        {
                            player.NameText.Color = Palette.LDCHDOFJPGH;
                        }
                        else
                        {
                            player.NameText.Color = Color.white;
                        }
                    }
                }
            }
            if (PlayerControl.LocalPlayer.IDOFAMCIJKE.CIDDOFDJHJH)
            {
                List <PlayerControl> impostors = PlayerControl.AllPlayerControls.ToArray().ToList();
                impostors.RemoveAll(x => !x.IDOFAMCIJKE.CIDDOFDJHJH);
                foreach (PlayerControl player in impostors)
                {
                    player.nameText.Color = Palette.LDCHDOFJPGH;
                }
                if (MeetingHud.Instance != null)
                {
                    foreach (PlayerVoteArea player in MeetingHud.Instance.DHCOPOOJCLN)
                    {
                        PlayerControl playerControl = Helpers.playerById((byte)player.HMPHKKGPLAG);
                        if (playerControl != null && playerControl.IDOFAMCIJKE.CIDDOFDJHJH)
                        {
                            player.NameText.Color = Palette.LDCHDOFJPGH;
                        }
                    }
                }
            }
        }
コード例 #6
0
        static void resetNameTagsAndColors()
        {
            Dictionary <byte, PlayerControl> playersById = Helpers.allPlayersById();

            foreach (PlayerControl player in PlayerControl.AllPlayerControls)
            {
                player.nameText.text = player.PPMOEEPBHJO.PCLLABJCIPC;
                if (PlayerControl.LocalPlayer.PPMOEEPBHJO.FDNMBJOAPFL && player.PPMOEEPBHJO.FDNMBJOAPFL)
                {
                    player.nameText.color = Palette.JPCHLLEJNEH;
                }
                else
                {
                    player.nameText.color = Color.white;
                }
            }
            if (MeetingHud.Instance != null)
            {
                foreach (PlayerVoteArea player in MeetingHud.Instance.GBKFCOAKLAH)
                {
                    PlayerControl playerControl = playersById.ContainsKey((byte)player.GEIOMAPOPKA) ? playersById[(byte)player.GEIOMAPOPKA] : null;
                    if (playerControl != null)
                    {
                        player.NameText.text = playerControl.PPMOEEPBHJO.PCLLABJCIPC;
                        if (PlayerControl.LocalPlayer.PPMOEEPBHJO.FDNMBJOAPFL && playerControl.PPMOEEPBHJO.FDNMBJOAPFL)
                        {
                            player.NameText.color = Palette.JPCHLLEJNEH;
                        }
                        else
                        {
                            player.NameText.color = Color.white;
                        }
                    }
                }
            }
            if (PlayerControl.LocalPlayer.PPMOEEPBHJO.FDNMBJOAPFL)
            {
                List <PlayerControl> impostors = PlayerControl.AllPlayerControls.ToArray().ToList();
                impostors.RemoveAll(x => !x.PPMOEEPBHJO.FDNMBJOAPFL);
                foreach (PlayerControl player in impostors)
                {
                    player.nameText.color = Palette.JPCHLLEJNEH;
                }
                if (MeetingHud.Instance != null)
                {
                    foreach (PlayerVoteArea player in MeetingHud.Instance.GBKFCOAKLAH)
                    {
                        PlayerControl playerControl = Helpers.playerById((byte)player.GEIOMAPOPKA);
                        if (playerControl != null && playerControl.PPMOEEPBHJO.FDNMBJOAPFL)
                        {
                            player.NameText.color = Palette.JPCHLLEJNEH;
                        }
                    }
                }
            }
        }
コード例 #7
0
ファイル: RPC.cs プロジェクト: fantahund/TheOtherRoles
        public static void uncheckedMurderPlayer(byte sourceId, byte targetId)
        {
            PlayerControl source = Helpers.playerById(sourceId);
            PlayerControl target = Helpers.playerById(targetId);

            if (source != null && target != null)
            {
                source.MurderPlayer(target);
            }
        }
コード例 #8
0
ファイル: RPC.cs プロジェクト: fantahund/TheOtherRoles
        public static void morphlingMorph(byte playerId)
        {
            PlayerControl target = Helpers.playerById(playerId);

            if (Morphling.morphling == null || target == null)
            {
                return;
            }

            Morphling.morphTimer  = Morphling.duration;
            Morphling.morphTarget = target;
        }
コード例 #9
0
ファイル: RPC.cs プロジェクト: fantahund/TheOtherRoles
        public static void setFutureErased(byte playerId)
        {
            PlayerControl player = Helpers.playerById(playerId);

            if (Eraser.futureErased == null)
            {
                Eraser.futureErased = new List <PlayerControl>();
            }
            if (player != null)
            {
                Eraser.futureErased.Add(player);
            }
        }
コード例 #10
0
        // Role functionality

        public static void jesterBountyHunterWin(byte exiledId)
        {
            PlayerControl exiled = Helpers.playerById(exiledId);

            if (exiled == null)
            {
                return;
            }

            bool jesterWin       = false;
            bool bountyHunterWin = false;

            if (Jester.jester != null && exiled == Jester.jester)
            {
                Jester.jester.Revive();
                Jester.jester.Data.IsDead     = false;
                Jester.jester.Data.IsImpostor = true;
                jesterWin = true;
            }
            if (BountyHunter.bountyHunter != null && !BountyHunter.bountyHunter.Data.IsDead && BountyHunter.target == exiled)
            {
                BountyHunter.bountyHunter.Data.IsImpostor = true;
                bountyHunterWin = true;
            }

            foreach (PlayerControl player in PlayerControl.AllPlayerControls)
            {
                if (player != null && player != Jester.jester && player != BountyHunter.bountyHunter)
                {
                    player.RemoveInfected();
                    player.Die(DeathReason.Exile);
                    player.Data.IsDead     = true;
                    player.Data.IsImpostor = false;
                }
            }
            if (jesterWin && !bountyHunterWin && BountyHunter.bountyHunter != null)
            {
                BountyHunter.bountyHunter.RemoveInfected();
                BountyHunter.bountyHunter.Die(DeathReason.Exile);
                BountyHunter.bountyHunter.Data.IsDead     = true;
                BountyHunter.bountyHunter.Data.IsImpostor = false;
            }
            else if (bountyHunterWin && !jesterWin && Jester.jester != null)
            {
                Jester.jester.RemoveInfected();
                Jester.jester.Die(DeathReason.Exile);
                Jester.jester.Data.IsDead     = true;
                Jester.jester.Data.IsImpostor = false;
            }
        }
コード例 #11
0
        public static void seerReveal(byte targetId, byte targetOrMistakeId)
        {
            if (Seer.seer == null)
            {
                return;
            }

            PlayerControl target          = Helpers.playerById(targetId);
            PlayerControl targetOrMistake = Helpers.playerById(targetOrMistakeId);

            if (target != null && targetOrMistake != null && !Seer.revealedPlayers.Keys.Any(p => p.Data.PlayerId == targetId))
            {
                Seer.revealedPlayers.Add(target, targetOrMistake);

                if (PlayerControl.LocalPlayer == target && HudManager.Instance?.FullScreen != null)
                {
                    RoleInfo si = RoleInfo.getRoleInfoForPlayer(target); // Use RoleInfo of target here, because we need the isGood of the targets role
                    bool     showNotification = false;
                    if (Seer.playersWithNotification == 0)
                    {
                        showNotification = true;
                    }
                    else if (Seer.playersWithNotification == 1 && si.isGood)
                    {
                        showNotification = true;
                    }
                    else if (Seer.playersWithNotification == 2 && !si.isGood)
                    {
                        showNotification = true;
                    }
                    else if (Seer.playersWithNotification == 3)
                    {
                        showNotification = false;
                    }

                    if (showNotification)
                    {
                        HudManager.Instance.FullScreen.enabled = true;
                        Reactor.Coroutines.Start(Helpers.CoFlashAndDisable(
                                                     HudManager.Instance.FullScreen,
                                                     0.5f,
                                                     new Color(42f / 255f, 187f / 255f, 245f / 255f, 0f),
                                                     new Color(42f / 255f, 187f / 255f, 245f / 255f, 0.75f)
                                                     ));
                    }
                }
            }
        }
コード例 #12
0
ファイル: RPC.cs プロジェクト: bkaufman92/TheOtherRoles
        public static void useUncheckedVent(int ventId, byte playerId, byte isEnter)
        {
            PlayerControl player = Helpers.playerById(playerId);

            if (player == null)
            {
                return;
            }
            // Fill dummy MessageReader and call MyPhysics.HandleRpc as the corountines cannot be accessed
            MessageReader reader = new MessageReader();

            byte[] bytes = BitConverter.GetBytes(ventId);
            if (!BitConverter.IsLittleEndian)
            {
                Array.Reverse(bytes);
            }
            reader.Buffer = bytes;
            reader.Length = bytes.Length;
            player.MyPhysics.HandleRpc(isEnter != 0 ? (byte)19 : (byte)20, reader);
        }
コード例 #13
0
        public static void MakeButtons(HudManager hm)
        {
            lastImpostorButtons = new List <CustomButton>();

            Vector3 lastImpostorCalcPos(byte index)
            {
                //return new Vector3(-0.25f, -0.25f, 0) + Vector3.right * index * 0.55f;
                return(new Vector3(-0.25f, -0.15f, 0) + Vector3.right * index * 0.55f);
            }

            Action lastImpostorButtonOnClick(byte index)
            {
                return(() =>
                {
                    if (selectedFunction == 1)
                    {
                        return;
                    }
                    PlayerControl p = Helpers.playerById(index);
                    LastImpostor.divine(p);
                });
            };

            Func <bool> lastImpostorHasButton(byte index)
            {
                return(() =>
                {
                    if (selectedFunction == 1)
                    {
                        return false;
                    }
                    var p = PlayerControl.LocalPlayer;
                    if (!p.hasModifier(ModifierType.LastImpostor))
                    {
                        return false;
                    }
                    if (p.hasModifier(ModifierType.LastImpostor) && p.CanMove && p.isAlive() & p.PlayerId != index &&
                        MapOptions.playerIcons.ContainsKey(index) && numUsed < 1 && isCounterMax())
                    {
                        return true;
                    }
                    else
                    {
                        if (playerIcons.ContainsKey(index))
                        {
                            playerIcons[index].gameObject.SetActive(false);
                            if (PlayerControl.LocalPlayer.isRole(RoleType.BountyHunter))
                            {
                                setBountyIconPos(Vector3.zero);
                            }
                        }
                        if (lastImpostorButtons.Count > index)
                        {
                            lastImpostorButtons[index].setActive(false);
                        }
                        return false;
                    }
                });
            }

            void setButtonPos(byte index)
            {
                Vector3 pos   = lastImpostorCalcPos(index);
                Vector3 scale = new Vector3(0.4f, 0.8f, 1.0f);

                Vector3 iconBase = hm.UseButton.transform.localPosition;

                iconBase.x *= -1;
                if (lastImpostorButtons[index].PositionOffset != pos)
                {
                    lastImpostorButtons[index].PositionOffset  = pos;
                    lastImpostorButtons[index].LocalScale      = scale;
                    playerIcons[index].transform.localPosition = iconBase + pos;
                }
            }

            void setIconStatus(byte index, bool transparent)
            {
                playerIcons[index].transform.localScale = Vector3.one * 0.25f;
                playerIcons[index].gameObject.SetActive(PlayerControl.LocalPlayer.CanMove);
                playerIcons[index].setSemiTransparent(transparent);
            }

            void setBountyIconPos(Vector3 offset)
            {
                Vector3        bottomLeft = new Vector3(-HudManager.Instance.UseButton.transform.localPosition.x, HudManager.Instance.UseButton.transform.localPosition.y, HudManager.Instance.UseButton.transform.localPosition.z);
                PoolablePlayer icon       = MapOptions.playerIcons[BountyHunter.bounty.PlayerId];

                icon.transform.localPosition = bottomLeft + new Vector3(-0.25f, 0f, 0) + offset;
                BountyHunter.cooldownText.transform.localPosition = bottomLeft + new Vector3(-0.25f, 0f, -1f) + offset;
            }

            Func <bool> lastImpostorCouldUse(byte index)
            {
                return(() =>
                {
                    if (selectedFunction == 1)
                    {
                        return false;
                    }

                    // ラストインポスター以外の場合、リソースがない場合はボタンを表示しない
                    var p = Helpers.playerById(index);
                    if (!playerIcons.ContainsKey(index) ||
                        !PlayerControl.LocalPlayer.hasModifier(ModifierType.LastImpostor) ||
                        !isCounterMax())
                    {
                        return false;
                    }

                    // ボタンの位置を変更
                    setButtonPos(index);

                    // ボタンにテキストを設定
                    lastImpostorButtons[index].buttonText = PlayerControl.LocalPlayer.isAlive() ? "生存": "死亡";

                    // アイコンの位置と透明度を変更
                    setIconStatus(index, false);

                    // Bounty Hunterの場合賞金首の位置をずらして表示する
                    if (PlayerControl.LocalPlayer.isRole(RoleType.BountyHunter))
                    {
                        Vector3 offset = new Vector3(0f, 1f, 0f);
                        setBountyIconPos(offset);
                    }

                    return PlayerControl.LocalPlayer.CanMove && numUsed < 1;
                });
            }

            for (byte i = 0; i < 15; i++)
            {
                CustomButton lastImpostorButton = new CustomButton(
                    // Action OnClick
                    lastImpostorButtonOnClick(i),
                    // bool HasButton
                    lastImpostorHasButton(i),
                    // bool CouldUse
                    lastImpostorCouldUse(i),
                    // Action OnMeetingEnds
                    () => { },
                    // sprite
                    null,
                    // position
                    Vector3.zero,
                    // hudmanager
                    hm,
                    // keyboard shortcut
                    null,
                    KeyCode.None,
                    true
                    );
                lastImpostorButton.Timer    = 0.0f;
                lastImpostorButton.MaxTimer = 0.0f;

                lastImpostorButtons.Add(lastImpostorButton);
            }
        }
コード例 #14
0
ファイル: ButtonsGM.cs プロジェクト: haoming37/TheOtherRoles
        public static void makeButtons(HudManager hm)
        {
            Ninja.MakeButtons(hm);
            Sheriff.MakeButtons(hm);
            PlagueDoctor.MakeButtons(hm);
            Lighter.MakeButtons(hm);
            SerialKiller.MakeButtons(hm);
            Fox.MakeButtons(hm);
            Immoralist.MakeButtons(hm);
            FortuneTeller.MakeButtons(hm);
            LastImpostor.MakeButtons(hm);
            SoulPlayer.MakeButtons(hm);
            SchrodingersCat.MakeButtons(hm);
            Trapper.MakeButtons(hm);
            BomberA.MakeButtons(hm);
            BomberB.MakeButtons(hm);
            EvilTracker.MakeButtons(hm);
            Puppeteer.MakeButtons(hm);
            MimicK.MakeButtons(hm);
            MimicA.MakeButtons(hm);

            gmButtons     = new List <CustomButton>();
            gmKillButtons = new List <CustomButton>();

            Vector3 gmCalcPos(byte index)
            {
                return(new Vector3(-0.25f, -0.25f, 1.0f) + Vector3.right * index * 0.55f);
            }

            Action gmButtonOnClick(byte index)
            {
                return(() =>
                {
                    PlayerControl target = Helpers.playerById(index);
                    if (!MapOptions.playerIcons.ContainsKey(index) || target.Data.Disconnected)
                    {
                        return;
                    }

                    if (GM.gm.transform.position != target.transform.position)
                    {
                        GM.gm.transform.position = target.transform.position;
                    }
                });
            };

            Action gmKillButtonOnClick(byte index)
            {
                return(() =>
                {
                    PlayerControl target = Helpers.playerById(index);
                    if (!MapOptions.playerIcons.ContainsKey(index) || target.Data.Disconnected)
                    {
                        return;
                    }

                    if (!target.Data.IsDead)
                    {
                        MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.GMKill, Hazel.SendOption.Reliable, -1);
                        writer.Write(index);
                        AmongUsClient.Instance.FinishRpcImmediately(writer);
                        RPCProcedure.GMKill(index);
                    }
                    else
                    {
                        MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.GMRevive, Hazel.SendOption.Reliable, -1);
                        writer.Write(index);
                        AmongUsClient.Instance.FinishRpcImmediately(writer);
                        RPCProcedure.GMRevive(index);
                    }
                });
            };

            Func <bool> gmHasButton(byte index)
            {
                return(() =>
                {
                    if ((GM.gm == null || PlayerControl.LocalPlayer != GM.gm) ||
                        (!MapOptions.playerIcons.ContainsKey(index)) ||
                        (!GM.canWarp) ||
                        (Helpers.playerById(index).Data.Disconnected))
                    {
                        return false;
                    }

                    return true;
                });
            }

            Func <bool> gmHasKillButton(byte index)
            {
                return(() =>
                {
                    if ((GM.gm == null || PlayerControl.LocalPlayer != GM.gm) ||
                        (!MapOptions.playerIcons.ContainsKey(index)) ||
                        (!GM.canKill) ||
                        (Helpers.playerById(index).Data.Disconnected))
                    {
                        return false;
                    }

                    return true;
                });
            }

            Func <bool> gmCouldUse(byte index)
            {
                return(() =>
                {
                    if (!MapOptions.playerIcons.ContainsKey(index) || !GM.canWarp)
                    {
                        return false;
                    }

                    Vector3 pos = gmCalcPos(index);
                    Vector3 scale = new Vector3(0.4f, 0.8f, 1.0f);

                    Vector3 iconBase = hm.UseButton.transform.localPosition;
                    iconBase.x *= -1;
                    if (gmButtons[index].PositionOffset != pos)
                    {
                        gmButtons[index].PositionOffset = pos;
                        gmButtons[index].LocalScale = scale;
                        MapOptions.playerIcons[index].transform.localPosition = iconBase + pos;
                        //TheOtherRolesPlugin.Instance.Log.LogInfo($"Updated {index}: {pos.x}, {pos.y}, {pos.z}");
                    }

                    //MapOptions.playerIcons[index].gameObject.SetActive(PlayerControl.LocalPlayer.CanMove);
                    return PlayerControl.LocalPlayer.CanMove;
                });
            }

            Func <bool> gmCouldKill(byte index)
            {
                return(() =>
                {
                    if (!MapOptions.playerIcons.ContainsKey(index) || !GM.canKill)
                    {
                        return false;
                    }

                    Vector3 pos = gmCalcPos(index) + Vector3.up * 0.55f;
                    Vector3 scale = new Vector3(0.4f, 0.25f, 1.0f);
                    if (gmKillButtons[index].PositionOffset != pos)
                    {
                        gmKillButtons[index].PositionOffset = pos;
                        gmKillButtons[index].LocalScale = scale;
                    }

                    PlayerControl target = Helpers.playerById(index);
                    if (target.Data.IsDead)
                    {
                        gmKillButtons[index].buttonText = ModTranslation.getString("gmRevive");
                    }
                    else
                    {
                        gmKillButtons[index].buttonText = ModTranslation.getString("gmKill");
                    }

                    //MapOptions.playerIcons[index].gameObject.SetActive(PlayerControl.LocalPlayer.CanMove);
                    return true;
                });
            }

            for (byte i = 0; i < 15; i++)
            {
                //TheOtherRolesPlugin.Instance.Log.LogInfo($"Added {i}");

                CustomButton gmButton = new CustomButton(
                    // Action OnClick
                    gmButtonOnClick(i),
                    // bool HasButton
                    gmHasButton(i),
                    // bool CouldUse
                    gmCouldUse(i),
                    // Action OnMeetingEnds
                    () => { },
                    // sprite
                    null,
                    // position
                    Vector3.zero,
                    // hudmanager
                    hm,
                    hm.UseButton,
                    // keyboard shortcut
                    null,
                    true
                    );
                gmButton.Timer          = 0.0f;
                gmButton.MaxTimer       = 0.0f;
                gmButton.showButtonText = false;
                gmButtons.Add(gmButton);

                CustomButton gmKillButton = new CustomButton(
                    // Action OnClick
                    gmKillButtonOnClick(i),
                    // bool HasButton
                    gmHasKillButton(i),
                    // bool CouldUse
                    gmCouldKill(i),
                    // Action OnMeetingEnds
                    () => { },
                    // sprite
                    null,
                    // position
                    Vector3.zero,
                    // hudmanager
                    hm,
                    hm.KillButton,
                    // keyboard shortcut
                    null,
                    true
                    );
                gmKillButton.Timer          = 0.0f;
                gmKillButton.MaxTimer       = 0.0f;
                gmKillButton.showButtonText = true;

                var buttonPos = gmKillButton.actionButton.buttonLabelText.transform.localPosition;
                gmKillButton.actionButton.buttonLabelText.transform.localPosition = new Vector3(buttonPos.x, buttonPos.y + 0.6f, -500f);
                gmKillButton.actionButton.buttonLabelText.transform.localScale    = new Vector3(1.5f, 1.8f, 1.0f);

                gmKillButtons.Add(gmKillButton);
            }

            gmZoomOut = new CustomButton(
                () => {
                if (Camera.main.orthographicSize < 18.0f)
                {
                    Camera.main.orthographicSize *= 1.5f;
                    hm.UICamera.orthographicSize *= 1.5f;
                }

                if (hm.transform.localScale.x < 6.0f)
                {
                    hm.transform.localScale *= 1.5f;
                }

                /*TheOtherRolesPlugin.Instance.Log.LogInfo($"Camera zoom {Camera.main.orthographicSize} / {TaskPanelBehaviour.Instance.transform.localPosition.x}");*/
            },
                () => { return(!(GM.gm == null || PlayerControl.LocalPlayer != GM.gm)); },
                () => { return(true); },
                () => { },
                GM.getZoomOutSprite(),
                // position
                Vector3.zero + Vector3.up * 3.75f + Vector3.right * 0.55f,
                // hudmanager
                hm,
                hm.UseButton,
                // keyboard shortcut
                KeyCode.PageDown,
                false
                );
            gmZoomOut.Timer          = 0.0f;
            gmZoomOut.MaxTimer       = 0.0f;
            gmZoomOut.showButtonText = false;
            gmZoomOut.LocalScale     = Vector3.one * 0.275f;

            gmZoomIn = new CustomButton(
                () => {
                if (Camera.main.orthographicSize > 3.0f)
                {
                    Camera.main.orthographicSize /= 1.5f;
                    hm.UICamera.orthographicSize /= 1.5f;
                }

                if (hm.transform.localScale.x > 1.0f)
                {
                    hm.transform.localScale /= 1.5f;
                }

                /*TheOtherRolesPlugin.Instance.Log.LogInfo($"Camera zoom {Camera.main.orthographicSize} / {TaskPanelBehaviour.Instance.transform.localPosition.x}");*/
            },
                () => { return(!(GM.gm == null || PlayerControl.LocalPlayer != GM.gm)); },
                () => { return(true); },
                () => { },
                GM.getZoomInSprite(),
                // position
                Vector3.zero + Vector3.up * 3.75f + Vector3.right * 0.2f,
                // hudmanager
                hm,
                hm.UseButton,
                // keyboard shortcut
                KeyCode.PageUp,
                false
                );
            gmZoomIn.Timer          = 0.0f;
            gmZoomIn.MaxTimer       = 0.0f;
            gmZoomIn.showButtonText = false;
            gmZoomIn.LocalScale     = Vector3.one * 0.275f;
        }
コード例 #15
0
ファイル: RPC.cs プロジェクト: fantahund/TheOtherRoles
        public static void shifterShift(byte targetId)
        {
            PlayerControl oldShifter = Shifter.shifter;
            PlayerControl player     = Helpers.playerById(targetId);

            if (player == null || oldShifter == null)
            {
                return;
            }

            Shifter.futureShift = null;
            Shifter.clearAndReload();

            // Suicide (exile) when impostor or impostor variants
            if (player.Data.IsImpostor || player == Jackal.jackal || player == Sidekick.sidekick)
            {
                oldShifter.Exiled();
                return;
            }

            // Switch shield
            if (Medic.shielded != null && Medic.shielded == player)
            {
                Medic.shielded = oldShifter;
            }
            else if (Medic.shielded != null && Medic.shielded == oldShifter)
            {
                Medic.shielded = player;
            }

            // Shift role
            if (Jester.jester != null && Jester.jester == player)
            {
                Jester.jester = oldShifter;
            }
            else if (Mayor.mayor != null && Mayor.mayor == player)
            {
                Mayor.mayor = oldShifter;
            }
            else if (Engineer.engineer != null && Engineer.engineer == player)
            {
                Engineer.engineer = oldShifter;
            }
            else if (Sheriff.sheriff != null && Sheriff.sheriff == player)
            {
                Sheriff.sheriff = oldShifter;
            }
            else if (Lighter.lighter != null && Lighter.lighter == player)
            {
                Lighter.lighter = oldShifter;
            }
            else if (Detective.detective != null && Detective.detective == player)
            {
                Detective.detective = oldShifter;
            }
            else if (TimeMaster.timeMaster != null && TimeMaster.timeMaster == player)
            {
                TimeMaster.timeMaster = oldShifter;
            }
            else if (Medic.medic != null && Medic.medic == player)
            {
                Medic.medic = oldShifter;
            }
            else if (Swapper.swapper != null && Swapper.swapper == player)
            {
                Swapper.swapper = oldShifter;
            }
            else if (Lovers.lover1 != null && Lovers.lover1 == player)
            {
                Lovers.lover1 = oldShifter;
            }
            else if (Lovers.lover2 != null && Lovers.lover2 == player)
            {
                Lovers.lover2 = oldShifter;
            }
            else if (Seer.seer != null && Seer.seer == player)
            {
                Seer.seer = oldShifter;
            }
            else if (Hacker.hacker != null && Hacker.hacker == player)
            {
                Hacker.hacker = oldShifter;
            }
            else if (Child.child != null && Child.child == player)
            {
                Child.child = oldShifter;
            }
            else if (Tracker.tracker != null && Tracker.tracker == player)
            {
                Tracker.tracker = oldShifter;
            }
            else if (Snitch.snitch != null && Snitch.snitch == player)
            {
                Snitch.snitch = oldShifter;
            }
            else if (Spy.spy != null && Spy.spy == player)
            {
                Spy.spy = oldShifter;
            }
            else     // Crewmate
            {
            }

            // Set cooldowns to max for both players
            if (PlayerControl.LocalPlayer == oldShifter || PlayerControl.LocalPlayer == player)
            {
                CustomButton.ResetAllCooldowns();
            }
        }
コード例 #16
0
ファイル: RPC.cs プロジェクト: fantahund/TheOtherRoles
        public static void erasePlayerRole(byte playerId)
        {
            PlayerControl player = Helpers.playerById(playerId);

            if (player == null)
            {
                return;
            }

            // Crewmate roles
            if (player == Mayor.mayor)
            {
                Mayor.clearAndReload();
            }
            if (player == Engineer.engineer)
            {
                Engineer.clearAndReload();
            }
            if (player == Sheriff.sheriff)
            {
                Sheriff.clearAndReload();
            }
            if (player == Lighter.lighter)
            {
                Lighter.clearAndReload();
            }
            if (player == Detective.detective)
            {
                Detective.clearAndReload();
            }
            if (player == TimeMaster.timeMaster)
            {
                TimeMaster.clearAndReload();
            }
            if (player == Medic.medic)
            {
                Medic.clearAndReload();
            }
            if (player == Shifter.shifter)
            {
                Shifter.clearAndReload();
            }
            if (player == Seer.seer)
            {
                Seer.clearAndReload();
            }
            if (player == Hacker.hacker)
            {
                Hacker.clearAndReload();
            }
            if (player == Child.child)
            {
                Child.clearAndReload();
            }
            if (player == Tracker.tracker)
            {
                Tracker.clearAndReload();
            }
            if (player == Snitch.snitch)
            {
                Snitch.clearAndReload();
            }
            if (player == Swapper.swapper)
            {
                Swapper.clearAndReload();
            }
            if (player == Spy.spy)
            {
                Spy.clearAndReload();
            }

            // Impostor roles
            if (player == Morphling.morphling)
            {
                Morphling.clearAndReload();
            }
            if (player == Camouflager.camouflager)
            {
                Camouflager.clearAndReload();
            }
            if (player == Godfather.godfather)
            {
                Godfather.clearAndReload();
            }
            if (player == Mafioso.mafioso)
            {
                Mafioso.clearAndReload();
            }
            if (player == Janitor.janitor)
            {
                Janitor.clearAndReload();
            }
            if (player == Vampire.vampire)
            {
                Vampire.clearAndReload();
            }
            if (player == Eraser.eraser)
            {
                Eraser.clearAndReload();
            }
            if (player == Trickster.trickster)
            {
                Trickster.clearAndReload();
            }
            if (player == Cleaner.cleaner)
            {
                Cleaner.clearAndReload();
            }
            if (player == Warlock.warlock)
            {
                Warlock.clearAndReload();
            }

            // Other roles
            if (player == Jester.jester)
            {
                Jester.clearAndReload();
            }
            if (player == Lovers.lover1 || player == Lovers.lover2)   // The whole Lover couple is being erased
            {
                Lovers.clearAndReload();
            }
            if (player == Jackal.jackal)   // Promote Sidekick and hence override the the Jackal or erase Jackal
            {
                if (Sidekick.promotesToJackal && Sidekick.sidekick != null && !Sidekick.sidekick.Data.IsDead)
                {
                    RPCProcedure.sidekickPromotes();
                }
                else
                {
                    Jackal.clearAndReload();
                }
            }
            if (player == Sidekick.sidekick)
            {
                Sidekick.clearAndReload();
            }
        }
コード例 #17
0
ファイル: RPC.cs プロジェクト: fantahund/TheOtherRoles
 public static void setFutureShifted(byte playerId)
 {
     Shifter.futureShift = Helpers.playerById(playerId);
 }
コード例 #18
0
        public static void MakeButtons(HudManager hm)
        {
            fortuneTellerButtons = new List <CustomButton>();

            Vector3 fortuneTellerCalcPos(byte index)
            {
                int adjIndex = index < PlayerControl.LocalPlayer.PlayerId ? index : index - 1;

                return(new Vector3(-0.25f, -0.15f, 0) + Vector3.right * adjIndex * 0.55f);
            }

            Action fortuneTellerButtonOnClick(byte index)
            {
                return(() =>
                {
                    if (PlayerControl.LocalPlayer.CanMove && local.numUsed < 1 && local.canDivine(index))
                    {
                        PlayerControl p = Helpers.playerById(index);
                        local.divine(p);
                    }
                });
            };

            Func <bool> fortuneTellerHasButton(byte index)
            {
                return(() =>
                {
                    return PlayerControl.LocalPlayer.isRole(RoleType.FortuneTeller);
                    //var p = PlayerControl.LocalPlayer;
                    //if (!p.isRole(RoleType.FortuneTeller)) return false;
                });
            }

            void setButtonPos(byte index)
            {
                Vector3 pos   = fortuneTellerCalcPos(index);
                Vector3 scale = new Vector3(0.4f, 0.5f, 1.0f);

                Vector3 iconBase = hm.UseButton.transform.localPosition;

                iconBase.x *= -1;
                if (fortuneTellerButtons[index].PositionOffset != pos)
                {
                    fortuneTellerButtons[index].PositionOffset            = pos;
                    fortuneTellerButtons[index].LocalScale                = scale;
                    MapOptions.playerIcons[index].transform.localPosition = iconBase + pos;
                }
            }

            void setIconPos(byte index, bool transparent)
            {
                MapOptions.playerIcons[index].transform.localScale = Vector3.one * 0.25f;
                MapOptions.playerIcons[index].gameObject.SetActive(PlayerControl.LocalPlayer.CanMove);
                MapOptions.playerIcons[index].setSemiTransparent(transparent);
            }

            Func <bool> fortuneTellerCouldUse(byte index)
            {
                return(() =>
                {
                    // 占い師以外の場合、リソースがない場合はボタンを表示しない
                    if (!MapOptions.playerIcons.ContainsKey(index) ||
                        !PlayerControl.LocalPlayer.isRole(RoleType.FortuneTeller) ||
                        PlayerControl.LocalPlayer.isDead() ||
                        PlayerControl.LocalPlayer.PlayerId == index ||
                        !isCompletedNumTasks(PlayerControl.LocalPlayer) ||
                        local.numUsed >= 1)
                    {
                        if (MapOptions.playerIcons.ContainsKey(index))
                        {
                            MapOptions.playerIcons[index].gameObject.SetActive(false);
                        }
                        if (fortuneTellerButtons.Count > index)
                        {
                            fortuneTellerButtons[index].setActive(false);
                        }

                        return false;
                    }

                    // ボタンの位置を変更
                    setButtonPos(index);

                    // ボタンにテキストを設定
                    bool status = true;
                    if (local.playerStatus.ContainsKey(index))
                    {
                        status = local.playerStatus[index];
                    }

                    if (status)
                    {
                        var progress = local.progress.ContainsKey(index) ? local.progress[index] : 0f;
                        fortuneTellerButtons[index].buttonText = $"{progress:0.0}/{duration:0.0}";
                    }
                    else
                    {
                        fortuneTellerButtons[index].buttonText = ModTranslation.getString("fortuneTellerDead");
                    }

                    // アイコンの位置と透明度を変更
                    setIconPos(index, !local.canDivine(index));

                    MapOptions.playerIcons[index].gameObject.SetActive(Helpers.ShowButtons && PlayerControl.LocalPlayer.CanMove);
                    fortuneTellerButtons[index].setActive(Helpers.ShowButtons && PlayerControl.LocalPlayer.CanMove);

                    return PlayerControl.LocalPlayer.CanMove && local.numUsed < 1 && local.canDivine(index);
                });
            }

            for (byte i = 0; i < 15; i++)
            {
                CustomButton fortuneTellerButton = new CustomButton(
                    // Action OnClick
                    fortuneTellerButtonOnClick(i),
                    // bool HasButton
                    fortuneTellerHasButton(i),
                    // bool CouldUse
                    fortuneTellerCouldUse(i),
                    // Action OnMeetingEnds
                    () => { },
                    // sprite
                    null,
                    // position
                    Vector3.zero,
                    // hudmanager
                    hm,
                    hm.AbilityButton,
                    // keyboard shortcut
                    KeyCode.None,
                    true
                    );
                fortuneTellerButton.Timer    = 0.0f;
                fortuneTellerButton.MaxTimer = 0.0f;

                fortuneTellerButtons.Add(fortuneTellerButton);
            }
        }