public static void clearAndReloadRoles()
        {
            Morphling.clearAndReload();
            Camouflager.clearAndReload();
            Shifter.clearAndReload();
            Swapper.clearAndReload();
            GM.clearAndReload();

            Lovers.Clear();
            Opportunist.Clear();
            Ninja.Clear();
            Madmate.Clear();
            CreatedMadmate.Clear();
            PlagueDoctor.Clear();
            Lighter.Clear();
            SerialKiller.Clear();
            Fox.Clear();
            Immoralist.Clear();
            FortuneTeller.Clear();
            LastImpostor.Clear();
            SoulPlayer.Clear();
            Munou.Clear();
            SchrodingersCat.Clear();
            Trapper.Clear();
            BomberA.Clear();
            BomberB.Clear();
            EvilTracker.Clear();
            Puppeteer.Clear();
            MimicK.Clear();
            MimicA.Clear();
            Mini.Clear();
            AntiTeleport.Clear();
            Role.ClearAll();
        }
        public static void divine(PlayerControl p)
        {
            // FortuneTeller.divine(p, resultIsCrewOrNot);
            string msgBase = "";
            string msgInfo = "";
            Color  color   = Color.white;

            if (divineResult == DivineResults.BlackWhite)
            {
                if (p.isCrew())
                {
                    msgBase = "divineMessageIsCrew";
                    color   = Color.white;
                }
                else
                {
                    msgBase = "divineMessageIsntCrew";
                    color   = Palette.ImpostorRed;
                }
            }

            else if (divineResult == DivineResults.Team)
            {
                msgBase = "divineMessageTeam";
                if (p.isCrew())
                {
                    msgInfo = ModTranslation.getString("divineCrew");
                    color   = Color.white;
                }
                else if (p.isNeutral())
                {
                    msgInfo = ModTranslation.getString("divineNeutral");
                    color   = Color.yellow;
                }
                else
                {
                    msgInfo = ModTranslation.getString("divineImpostor");
                    color   = Palette.ImpostorRed;
                }
            }

            else if (divineResult == DivineResults.Role)
            {
                msgBase = "divineMessageRole";
                msgInfo = String.Join(" ", RoleInfo.getRoleInfoForPlayer(p).Select(x => Helpers.cs(x.color, x.name)).ToArray());
            }

            string msg = string.Format(ModTranslation.getString(msgBase), p.name, msgInfo);

            if (!string.IsNullOrWhiteSpace(msg))
            {
                FortuneTeller.fortuneTellerMessage(msg, 5f, color);
            }

            if (Constants.ShouldPlaySfx())
            {
                SoundManager.Instance.PlaySound(DestroyableSingleton <HudManager> .Instance.TaskCompleteSound, false, 0.8f);
            }
            numUsed += 1;

            // 占いを実行したことで発火される処理を他クライアントに通知
            MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.FortuneTellerUsedDivine, Hazel.SendOption.Reliable, -1);

            writer.Write(PlayerControl.LocalPlayer.PlayerId);
            writer.Write(p.PlayerId);
            AmongUsClient.Instance.FinishRpcImmediately(writer);
            RPCProcedure.fortuneTellerUsedDivine(PlayerControl.LocalPlayer.PlayerId, p.PlayerId);
            numUsed += 1;
        }
Beispiel #3
0
        public static List<RoleInfo> getRoleInfoForPlayer(PlayerControl p, RoleType[] excludeRoles = null, bool includeHidden = false) {
            List<RoleInfo> infos = new List<RoleInfo>();
            if (p == null) return infos;

            // Special roles
            if (p.isRole(RoleType.Jester)) infos.Add(jester);
            if (p.isRole(RoleType.Mayor)) infos.Add(mayor);
            if (p.isRole(RoleType.Engineer)) infos.Add(engineer);
            if (p.isRole(RoleType.Sheriff)) infos.Add(sheriff);
            if (p.isRole(RoleType.Lighter)) infos.Add(lighter);
            if (p.isRole(RoleType.Godfather)) infos.Add(godfather);
            if (p.isRole(RoleType.Mafioso)) infos.Add(mafioso);
            if (p.isRole(RoleType.Janitor)) infos.Add(janitor);
            if (p.isRole(RoleType.Morphling)) infos.Add(morphling);
            if (p.isRole(RoleType.Camouflager)) infos.Add(camouflager);
            if (p.isRole(RoleType.EvilHacker)) infos.Add(evilHacker);
            if (p.isRole(RoleType.Vampire)) infos.Add(vampire);
            if (p.isRole(RoleType.Eraser)) infos.Add(eraser);
            if (p.isRole(RoleType.Trickster)) infos.Add(trickster);
            if (p.isRole(RoleType.Cleaner)) infos.Add(cleaner);
            if (p.isRole(RoleType.Warlock)) infos.Add(warlock);
            if (p.isRole(RoleType.Witch)) infos.Add(witch);
            if (p.isRole(RoleType.Assassin)) infos.Add(assassin);
            if (p.isRole(RoleType.Detective)) infos.Add(detective);
            if (p.isRole(RoleType.TimeMaster)) infos.Add(timeMaster);
            if (p.isRole(RoleType.Medic)) infos.Add(medic);
            if (p.isRole(RoleType.Shifter)) infos.Add(Shifter.isNeutral ? corruptedShifter : niceShifter);
            if (p.isRole(RoleType.Swapper)) infos.Add(p.Data.Role.IsImpostor ? evilSwapper : niceSwapper);
            if (p.isRole(RoleType.Seer)) infos.Add(seer);
            if (p.isRole(RoleType.Hacker)) infos.Add(hacker);
            if (p.isRole(RoleType.Tracker)) infos.Add(tracker);
            if (p.isRole(RoleType.Snitch)) infos.Add(snitch);
            if (p.isRole(RoleType.Jackal) || (Jackal.formerJackals != null && Jackal.formerJackals.Any(x => x.PlayerId == p.PlayerId))) infos.Add(jackal);
            if (p.isRole(RoleType.Sidekick)) infos.Add(sidekick);
            if (p.isRole(RoleType.Spy)) infos.Add(spy);
            if (p.isRole(RoleType.SecurityGuard)) infos.Add(securityGuard);
            if (p.isRole(RoleType.Arsonist)) infos.Add(arsonist);
            if (p.isRole(RoleType.NiceGuesser)) infos.Add(niceGuesser);
            if (p.isRole(RoleType.EvilGuesser)) infos.Add(evilGuesser);
            if (p.isRole(RoleType.BountyHunter)) infos.Add(bountyHunter);
            if (p.isRole(RoleType.Bait)) infos.Add(bait);
            if (p.isRole(RoleType.GM)) infos.Add(gm);
            if (p.isRole(RoleType.Opportunist)) infos.Add(opportunist);
            if (p.isRole(RoleType.Vulture)) infos.Add(vulture);
            if (p.isRole(RoleType.Medium)) infos.Add(medium);
            if (p.isRole(RoleType.Lawyer)) infos.Add(lawyer);
            if (p.isRole(RoleType.Pursuer)) infos.Add(pursuer);
            if (p.isRole(RoleType.Ninja)) infos.Add(ninja);
            if (p.isRole(RoleType.PlagueDoctor)) infos.Add(plagueDoctor);
            if (p.isRole(RoleType.SerialKiller)) infos.Add(serialKiller);
            if (p.isRole(RoleType.NekoKabocha)) infos.Add(nekoKabocha);
            if (p.isRole(RoleType.Watcher))
            {
                if (p.isImpostor()) infos.Add(evilWatcher);
                else infos.Add(niceWatcher);
            }
            if (p.isRole(RoleType.Fox)) infos.Add(fox);
            if (p.isRole(RoleType.Immoralist)) infos.Add(immoralist);
            if (p.isRole(RoleType.FortuneTeller))
            {
                if (includeHidden || PlayerControl.LocalPlayer.Data.IsDead)
                {
                    infos.Add(fortuneTeller);
                }
                else
                {
                    var info = FortuneTeller.isCompletedNumTasks(p) ? fortuneTeller: crewmate;
                    infos.Add(info);
                }
            }

            // はおみんオリジナル
            if(p.isRole(RoleType.SchrodingersCat)) infos.Add(schrodingersCat);
            if(p.isRole(RoleType.Trapper)) infos.Add(trapper);
            if(p.isRole(RoleType.BomberA)) infos.Add(bomberA);
            if(p.isRole(RoleType.BomberB)) infos.Add(bomberB);
            if(p.isRole(RoleType.EvilTracker)) infos.Add(evilTracker);
            if(p.isRole(RoleType.Puppeteer)) infos.Add(puppeteer);
            if(p.isRole(RoleType.MimicK)) infos.Add(mimicK);
            if(p.isRole(RoleType.MimicA)) infos.Add(mimicA);


            // Default roles
            if (infos.Count == 0 && p.Data.Role.IsImpostor) infos.Add(impostor); // Just Impostor
            if (infos.Count == 0 && !p.Data.Role.IsImpostor) infos.Add(crewmate); // Just Crewmate

            // Modifier
            if (p.isLovers()) infos.Add(lovers);

            if (excludeRoles != null)
                infos.RemoveAll(x => excludeRoles.Contains(x.roleType));

            return infos;
        }
Beispiel #4
0
        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;
        }