예제 #1
0
        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();
        }
예제 #2
0
        public static void setCustomButtonCooldowns()
        {
            Ninja.SetButtonCooldowns();
            Sheriff.SetButtonCooldowns();
            PlagueDoctor.SetButtonCooldowns();
            Lighter.SetButtonCooldowns();
            SerialKiller.SetButtonCooldowns();
            Immoralist.SetButtonCooldowns();
            SchrodingersCat.SetButtonCooldowns();
            Trapper.SetButtonCooldowns();
            BomberA.SetButtonCooldowns();
            BomberB.SetButtonCooldowns();
            EvilTracker.SetButtonCooldowns();
            Puppeteer.SetButtonCooldowns();
            MimicK.SetButtonCooldowns();
            MimicA.SetButtonCooldowns();
            SoulPlayer.SetButtonCooldowns();
            foreach (CustomButton gmButton in gmButtons)
            {
                gmButton.MaxTimer = 0.0f;
            }
            foreach (CustomButton gmButton in gmKillButtons)
            {
                gmButton.MaxTimer = 0.0f;
            }

            gmZoomIn.MaxTimer  = 0.0f;
            gmZoomOut.MaxTimer = 0.0f;
        }
예제 #3
0
        public override void FixedUpdate()
        {
            if (player == PlayerControl.LocalPlayer)
            {
                currentTarget = setTarget();
                setPlayerOutline(currentTarget, BomberA.color);
                arrowUpdate();

                foreach (PoolablePlayer pp in MapOptions.playerIcons.Values)
                {
                    pp.gameObject.SetActive(false);
                }
                foreach (PoolablePlayer pp in playerIcons.Values)
                {
                    pp.gameObject.SetActive(false);
                }
                if (player.isAlive() && BomberA.isAlive())
                {
                    if (bombTarget != null && MapOptions.playerIcons.ContainsKey(bombTarget.PlayerId) && MapOptions.playerIcons[bombTarget.PlayerId].gameObject != null)
                    {
                        var     icon       = MapOptions.playerIcons[bombTarget.PlayerId];
                        Vector3 bottomLeft = new Vector3(-HudManager.Instance.UseButton.transform.localPosition.x, HudManager.Instance.UseButton.transform.localPosition.y, HudManager.Instance.UseButton.transform.localPosition.z);
                        icon.gameObject.SetActive(true);
                        icon.transform.localPosition = bottomLeft + new Vector3(-0.25f, 0f, 0);
                        icon.transform.localScale    = Vector3.one * 0.4f;
                        if (targetText == null)
                        {
                            targetText = GameObject.Instantiate(icon.NameText, icon.NameText.transform.parent);
                            targetText.enableWordWrapping       = false;
                            targetText.transform.localScale     = Vector3.one * 1.5f;
                            targetText.transform.localPosition += new Vector3(0f, 1.7f, 0);
                        }
                        targetText.text = ModTranslation.getString("bomberTarget");
                        targetText.gameObject.SetActive(true);
                        targetText.transform.parent = icon.gameObject.transform;
                    }
                    // 相方の設置したターゲットを表示する
                    if (BomberA.bombTarget != null && playerIcons.ContainsKey(BomberA.bombTarget.PlayerId) && playerIcons[BomberA.bombTarget.PlayerId].gameObject != null)
                    {
                        var     icon       = playerIcons[BomberA.bombTarget.PlayerId];
                        Vector3 bottomLeft = new Vector3(-HudManager.Instance.UseButton.transform.localPosition.x, HudManager.Instance.UseButton.transform.localPosition.y, HudManager.Instance.UseButton.transform.localPosition.z);
                        icon.gameObject.SetActive(true);
                        icon.transform.localPosition = bottomLeft + new Vector3(1.0f, 0f, 0);
                        icon.transform.localScale    = Vector3.one * 0.4f;
                        if (partnerTargetText == null)
                        {
                            partnerTargetText = GameObject.Instantiate(icon.NameText, icon.NameText.transform.parent);
                            partnerTargetText.enableWordWrapping       = false;
                            partnerTargetText.transform.localScale     = Vector3.one * 1.5f;
                            partnerTargetText.transform.localPosition += new Vector3(0f, 1.7f, 0);
                        }
                        partnerTargetText.text = ModTranslation.getString("bomberPartnerTarget");
                        partnerTargetText.gameObject.SetActive(true);
                        partnerTargetText.transform.parent = icon.gameObject.transform;
                    }
                }
            }
        }
예제 #4
0
        public static void MakeButtons(HudManager hm)
        {
            // Bomber button
            bomberButton = new CustomButton(
                // OnClick
                () =>
            {
                if (currentTarget != null)
                {
                    tmpTarget = currentTarget;
                    bomberButton.HasEffect = true;
                }
            },
                // HasButton
                () => { return(PlayerControl.LocalPlayer.isRole(RoleType.BomberB) && PlayerControl.LocalPlayer.isAlive() && BomberA.isAlive()); },
                // CouldUse
                () =>
            {
                if (bomberButton.isEffectActive && tmpTarget != currentTarget)
                {
                    tmpTarget                   = null;
                    bomberButton.Timer          = 0f;
                    bomberButton.isEffectActive = false;
                }

                return(PlayerControl.LocalPlayer.CanMove && currentTarget != null);
            },
                // OnMeetingEnds
                () =>
            {
                bomberButton.Timer          = bomberButton.MaxTimer;
                bomberButton.isEffectActive = false;
                tmpTarget = null;
            },
                getBomberButtonSprite(),
                new Vector3(-1.8f, -0.06f, 0),
                hm,
                hm.KillButton,
                KeyCode.F,
                true,
                duration,
                // OnEffectsEnd
                () =>
            {
                if (tmpTarget != null)
                {
                    MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlantBomb, Hazel.SendOption.Reliable, -1);
                    writer.Write(tmpTarget.PlayerId);
                    AmongUsClient.Instance.FinishRpcImmediately(writer);
                    BomberB.bombTarget = tmpTarget;
                }

                tmpTarget          = null;
                bomberButton.Timer = bomberButton.MaxTimer;
            }
                );
            bomberButton.buttonText = ModTranslation.getString("bomberPlantBomb");
            // Bomber button
            releaseButton = new CustomButton(
                // OnClick
                () =>
            {
                var bomberA    = BomberA.allPlayers.FirstOrDefault();
                float distance = Vector2.Distance(PlayerControl.LocalPlayer.transform.localPosition, bomberA.transform.localPosition);

                if (PlayerControl.LocalPlayer.CanMove && BomberA.bombTarget != null && BomberB.bombTarget != null && bomberA.isAlive() && distance < 1)
                {
                    var target           = BomberB.bombTarget;
                    MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ReleaseBomb, Hazel.SendOption.Reliable, -1);
                    writer.Write(PlayerControl.LocalPlayer.PlayerId);
                    writer.Write(target.PlayerId);
                    AmongUsClient.Instance.FinishRpcImmediately(writer);
                    RPCProcedure.releaseBomb(PlayerControl.LocalPlayer.PlayerId, target.PlayerId);
                }
            },
                // HasButton
                () => { return(PlayerControl.LocalPlayer.isRole(RoleType.BomberB) && PlayerControl.LocalPlayer.isAlive() && BomberA.isAlive()); },
                // CouldUse
                () =>
            {
                var bomberA    = BomberA.allPlayers.FirstOrDefault();
                float distance = Vector2.Distance(PlayerControl.LocalPlayer.transform.localPosition, bomberA.transform.localPosition);

                return(PlayerControl.LocalPlayer.CanMove && BomberA.bombTarget != null && BomberB.bombTarget != null && bomberA.isAlive() && distance < 1);
            },
                // OnMeetingEnds
                () =>
            {
                releaseButton.Timer = releaseButton.MaxTimer;
            },
                getReleaseButtonSprite(),
                new Vector3(-2.7f, -0.06f, 0),
                hm,
                hm.KillButton,
                KeyCode.F,
                false
                );
            releaseButton.buttonText = ModTranslation.getString("bomberDetonate");
        }
예제 #5
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;
        }