Exemple #1
0
        public static void MakeButtons(HudManager hm)
        {
            // Sheriff Kill
            sheriffKillButton = new CustomButton(
                () =>
            {
                if (local.numShots <= 0)
                {
                    return;
                }

                MurderAttemptResult murderAttemptResult = Helpers.checkMuderAttempt(PlayerControl.LocalPlayer, local.currentTarget);
                if (murderAttemptResult == MurderAttemptResult.SuppressKill)
                {
                    return;
                }

                if (murderAttemptResult == MurderAttemptResult.PerformKill)
                {
                    bool misfire  = false;
                    byte targetId = local.currentTarget.PlayerId;;
                    if ((local.currentTarget.Data.Role.IsImpostor && (!local.currentTarget.hasModifier(ModifierType.Mini) || Mini.isGrownUp(local.currentTarget))) ||
                        (Sheriff.spyCanDieToSheriff && Spy.spy == local.currentTarget) ||
                        (Sheriff.madmateCanDieToSheriff && local.currentTarget.hasModifier(ModifierType.Madmate)) ||
                        (Sheriff.createdMadmateCanDieToSheriff && local.currentTarget.hasModifier(ModifierType.CreatedMadmate)) ||
                        (Sheriff.canKillNeutrals && local.currentTarget.isNeutral()) ||
                        (Jackal.jackal == local.currentTarget || Sidekick.sidekick == local.currentTarget))
                    {
                        //targetId = Sheriff.currentTarget.PlayerId;
                        misfire = false;
                    }
                    else
                    {
                        //targetId = PlayerControl.LocalPlayer.PlayerId;
                        misfire = true;
                    }

                    // Mad sheriff always misfires.
                    if (local.player.hasModifier(ModifierType.Madmate))
                    {
                        misfire = true;
                    }
                    MessageWriter killWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SheriffKill, Hazel.SendOption.Reliable, -1);
                    killWriter.Write(PlayerControl.LocalPlayer.Data.PlayerId);
                    killWriter.Write(targetId);
                    killWriter.Write(misfire);
                    AmongUsClient.Instance.FinishRpcImmediately(killWriter);
                    RPCProcedure.sheriffKill(PlayerControl.LocalPlayer.Data.PlayerId, targetId, misfire);
                }

                sheriffKillButton.Timer = sheriffKillButton.MaxTimer;
                local.currentTarget     = null;
            },
                () => { return(PlayerControl.LocalPlayer.isRole(RoleType.Sheriff) && local.numShots > 0 && !PlayerControl.LocalPlayer.Data.IsDead && local.canKill); },
                () =>
            {
                if (sheriffNumShotsText != null)
                {
                    if (local.numShots > 0)
                    {
                        sheriffNumShotsText.text = String.Format(ModTranslation.getString("sheriffShots"), local.numShots);
                    }
                    else
                    {
                        sheriffNumShotsText.text = "";
                    }
                }
                return(local.currentTarget && PlayerControl.LocalPlayer.CanMove);
            },
                () => { sheriffKillButton.Timer = sheriffKillButton.MaxTimer; },
                hm.KillButton.graphic.sprite,
                new Vector3(0f, 1f, 0),
                hm,
                hm.KillButton,
                KeyCode.Q
                );

            sheriffNumShotsText      = GameObject.Instantiate(sheriffKillButton.actionButton.cooldownTimerText, sheriffKillButton.actionButton.cooldownTimerText.transform.parent);
            sheriffNumShotsText.text = "";
            sheriffNumShotsText.enableWordWrapping       = false;
            sheriffNumShotsText.transform.localScale     = Vector3.one * 0.5f;
            sheriffNumShotsText.transform.localPosition += new Vector3(-0.05f, 0.7f, 0);
        }