Beispiel #1
0
            public static void HackButtonPress(Glitch __gInstance, KillButtonManager __instance)
            {
                if (__gInstance.HackTarget != null)
                {
                    if (__gInstance.HackTarget.isShielded())
                    {
                        var medic  = __gInstance.HackTarget.getMedic().Player.PlayerId;
                        var writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                                (byte)CustomRPC.AttemptSound, Hazel.SendOption.Reliable, -1);
                        writer.Write(medic);
                        writer.Write(__gInstance.HackTarget.PlayerId);
                        AmongUsClient.Instance.FinishRpcImmediately(writer);
                        if (CustomGameOptions.ShieldBreaks)
                        {
                            __gInstance.LastHack = DateTime.UtcNow;
                        }

                        MedicMod.StopKill.BreakShield(medic, __gInstance.HackTarget.PlayerId,
                                                      CustomGameOptions.ShieldBreaks);

                        return;
                    }

                    __gInstance.LastHack = DateTime.UtcNow;
                    //System.Console.WriteLine("Hacking " + __gInstance.HackTarget.Data.PlayerName + "...");
                    __gInstance.RpcSetHacked(__gInstance.HackTarget);
                }
            }
Beispiel #2
0
            public static void MimicButtonUpdate(Glitch __gInstance, HudManager __instance)
            {
                if (__gInstance.MimicButton == null)
                {
                    __gInstance.MimicButton = KillButtonManager.Instantiate(__instance.KillButton);
                    __gInstance.MimicButton.gameObject.SetActive(true);
                    __gInstance.MimicButton.renderer.enabled = true;
                }

                __gInstance.MimicButton.renderer.sprite = MimicSprite;


                __gInstance.MimicButton.gameObject.SetActive(__instance.UseButton.isActiveAndEnabled &&
                                                             !__gInstance.Player.Data.IsDead);
                __gInstance.MimicButton.transform.position = new Vector3(
                    Camera.main.ScreenToWorldPoint(new Vector3(0, 0)).x + 0.75f,
                    __instance.UseButton.transform.position.y, __instance.UseButton.transform.position.z);
                __gInstance.MimicButton.SetCoolDown(
                    CustomGameOptions.MimicCooldown - (float)(DateTime.UtcNow - __gInstance.LastMimic).TotalSeconds,
                    CustomGameOptions.MimicCooldown);

                if (!__gInstance.MimicButton.isCoolingDown && !__gInstance.IsUsingMimic)
                {
                    __gInstance.MimicButton.isCoolingDown = false;
                    __gInstance.MimicButton.renderer.material.SetFloat("_Desat", 0f);
                    __gInstance.MimicButton.renderer.color = Palette.EnabledColor;
                }
                else
                {
                    __gInstance.MimicButton.isCoolingDown = true;
                    __gInstance.MimicButton.renderer.material.SetFloat("_Desat", 1f);
                    __gInstance.MimicButton.renderer.color = Palette.DisabledClear;
                }
            }
Beispiel #3
0
            public static void HackButtonUpdate(Glitch __gInstance, HudManager __instance)
            {
                if (__gInstance.HackButton == null)
                {
                    __gInstance.HackButton = KillButtonManager.Instantiate(__instance.KillButton);
                    __gInstance.HackButton.gameObject.SetActive(true);
                    __gInstance.HackButton.renderer.enabled = true;
                }

                __gInstance.HackButton.renderer.sprite = HackSprite;


                __gInstance.HackButton.gameObject.SetActive(__instance.UseButton.isActiveAndEnabled &&
                                                            !__gInstance.Player.Data.IsDead);
                __gInstance.HackButton.transform.position = new Vector3(__gInstance.MimicButton.transform.position.x,
                                                                        __instance.ReportButton.transform.position.y, __instance.ReportButton.transform.position.z);
                __gInstance.HackButton.SetCoolDown(
                    CustomGameOptions.HackCooldown - (float)(DateTime.UtcNow - __gInstance.LastHack).TotalSeconds,
                    CustomGameOptions.HackCooldown);

                __gInstance.HackButton.SetTarget(null);
                __gInstance.HackTarget = null;

                if (__gInstance.DistClosest < GameOptionsData.KillDistances[CustomGameOptions.GlitchHackDistance])
                {
                    __gInstance.HackButton.SetTarget(__gInstance.ClosestPlayer);
                    __gInstance.HackTarget = __gInstance.ClosestPlayer;
                }

                if (__gInstance.HackTarget != null)
                {
                    __gInstance.HackTarget.myRend.material.SetColor("_OutlineColor", __gInstance.Color);
                }
            }
Beispiel #4
0
            public static void KillButtonPress(Glitch __gInstance, KillButtonManager __instance)
            {
                if (__gInstance.KillTarget != null)
                {
                    if (__gInstance.KillTarget.isShielded())
                    {
                        var medic  = __gInstance.HackTarget.getMedic().Player.PlayerId;
                        var writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                                (byte)CustomRPC.AttemptSound, Hazel.SendOption.Reliable, -1);
                        writer.Write(medic);
                        writer.Write(__gInstance.KillTarget.PlayerId);
                        AmongUsClient.Instance.FinishRpcImmediately(writer);
                        if (CustomGameOptions.ShieldBreaks)
                        {
                            __gInstance.LastKill = DateTime.UtcNow;
                        }

                        MedicMod.StopKill.BreakShield(medic, __gInstance.KillTarget.PlayerId,
                                                      CustomGameOptions.ShieldBreaks);


                        return;
                    }

                    __gInstance.LastKill = DateTime.UtcNow;
                    __gInstance.Player.SetKillTimer(CustomGameOptions.GlitchKillCooldown);
                    Utils.RpcMurderPlayer(__gInstance.Player, __gInstance.KillTarget);
                }
            }
Beispiel #5
0
            public static void KillButtonUpdate(Glitch __gInstance, HudManager __instance)
            {
                if (!__gInstance.Player.Data.IsImpostor && Input.GetKeyDown(KeyCode.Q))
                {
                    __instance.KillButton.PerformKill();
                }

                __instance.KillButton.gameObject.SetActive(__instance.UseButton.isActiveAndEnabled &&
                                                           !__gInstance.Player.Data.IsDead);
                __instance.KillButton.SetCoolDown(
                    CustomGameOptions.GlitchKillCooldown -
                    (float)(DateTime.UtcNow - __gInstance.LastKill).TotalSeconds,
                    CustomGameOptions.GlitchKillCooldown);

                __instance.KillButton.SetTarget(null);
                __gInstance.KillTarget = null;

                if (__gInstance.DistClosest < GameOptionsData.KillDistances[PlayerControl.GameOptions.KillDistance])
                {
                    __instance.KillButton.SetTarget(__gInstance.ClosestPlayer);
                    __gInstance.KillTarget = __gInstance.ClosestPlayer;
                }

                if (__gInstance.KillTarget != null)
                {
                    __gInstance.KillTarget.myRend.material.SetColor("_OutlineColor", __gInstance.Color);
                }
            }
Beispiel #6
0
            public static IEnumerator Mimic(Glitch __instance, PlayerControl mimicPlayer)
            {
                MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                                  (byte)CustomRPC.SetMimic, Hazel.SendOption.Reliable, -1);

                writer.Write(PlayerControl.LocalPlayer.PlayerId);
                writer.Write(mimicPlayer.PlayerId);
                AmongUsClient.Instance.FinishRpcImmediately(writer);

                Utils.Morph(__instance.Player, mimicPlayer, true);

                DateTime          mimicActivation = DateTime.UtcNow;
                ImportantTextTask mimicText       = new GameObject("_Player").AddComponent <ImportantTextTask>();

                mimicText.transform.SetParent(PlayerControl.LocalPlayer.transform, false);
                mimicText.Text =
                    $"{__instance.ColorString}Mimicking {mimicPlayer.Data.PlayerName} ({CustomGameOptions.MimicDuration}s)\n";
                PlayerControl.LocalPlayer.myTasks.Insert(0, mimicText);

                while (true)
                {
                    __instance.IsUsingMimic = true;
                    __instance.MimicTarget  = mimicPlayer;
                    var totalMimickTime = (DateTime.UtcNow - mimicActivation).TotalMilliseconds / 1000;
                    mimicText.Text =
                        $"{__instance.ColorString}Mimicking {mimicPlayer.Data.PlayerName} ({CustomGameOptions.MimicDuration - Math.Round(totalMimickTime)}s)\n";
                    if (MeetingHud.Instance || totalMimickTime > CustomGameOptions.MimicDuration ||
                        PlayerControl.LocalPlayer.Data.IsDead ||
                        AmongUsClient.Instance.GameState == InnerNetClient.GameStates.Ended)
                    {
                        PlayerControl.LocalPlayer.myTasks.Remove(mimicText);
                        //System.Console.WriteLine("Unsetting mimic");
                        __instance.LastMimic    = DateTime.UtcNow;
                        __instance.IsUsingMimic = false;
                        __instance.MimicTarget  = null;
                        Utils.Unmorph(__instance.Player);

                        MessageWriter writer2 = AmongUsClient.Instance.StartRpcImmediately(
                            PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.RpcResetAnim, Hazel.SendOption.Reliable,
                            -1);
                        writer2.Write(PlayerControl.LocalPlayer.PlayerId);
                        writer2.Write(mimicPlayer.PlayerId);
                        AmongUsClient.Instance.FinishRpcImmediately(writer2);
                        yield break;
                    }
                    else
                    {
                        Utils.Morph(__instance.Player, mimicPlayer);
                    }

                    yield return(null);
                }
            }
Beispiel #7
0
            public static void MimicButtonPress(Glitch __gInstance, KillButtonManager __instance)
            {
                if (__gInstance.MimicList == null)
                {
                    __gInstance.MimicList = ChatController.Instantiate(HudManager.Instance.Chat);

                    __gInstance.MimicList.transform.SetParent(Camera.main.transform);
                    __gInstance.MimicList.SetVisible(true);
                    __gInstance.MimicList.Toggle();

                    __gInstance.MimicList.TextBubble.enabled = false;
                    __gInstance.MimicList.TextBubble.gameObject.SetActive(false);

                    __gInstance.MimicList.TextArea.enabled = false;
                    __gInstance.MimicList.TextArea.gameObject.SetActive(false);

                    __gInstance.MimicList.BanButton.enabled = false;
                    __gInstance.MimicList.BanButton.gameObject.SetActive(false);

                    __gInstance.MimicList.CharCount.enabled = false;
                    __gInstance.MimicList.CharCount.gameObject.SetActive(false);

                    __gInstance.MimicList.gameObject.transform.GetChild(0).gameObject.GetComponent <SpriteRenderer>()
                    .enabled = false;
                    __gInstance.MimicList.gameObject.transform.GetChild(0).gameObject.SetActive(false);

                    __gInstance.MimicList.BackgroundImage.enabled = false;

                    foreach (SpriteRenderer rend in __gInstance.MimicList.Content
                             .GetComponentsInChildren <SpriteRenderer>())
                    {
                        if (rend.name == "SendButton" || rend.name == "QuickChatButton")
                        {
                            rend.enabled = false;
                            rend.gameObject.SetActive(false);
                        }
                    }

                    foreach (var bubble in __gInstance.MimicList.chatBubPool.activeChildren)
                    {
                        bubble.enabled = false;
                        bubble.gameObject.SetActive(false);
                    }

                    __gInstance.MimicList.chatBubPool.activeChildren.Clear();

                    foreach (PlayerControl player in PlayerControl.AllPlayerControls.ToArray()
                             .Where(x => x != PlayerControl.LocalPlayer))
                    {
                        bool oldDead = player.Data.IsDead;
                        player.Data.IsDead = false;
                        //System.Console.WriteLine(player.PlayerId);
                        __gInstance.MimicList.AddChat(player, "Click here");
                        player.Data.IsDead = oldDead;
                    }
                }
                else
                {
                    __gInstance.MimicList.Toggle();
                    __gInstance.MimicList.SetVisible(false);
                    __gInstance.MimicList = null;
                }
            }
Beispiel #8
0
            public static IEnumerator Hack(Glitch __instance, PlayerControl hackPlayer)
            {
                GameObject[]      lockImg = { null, null, null, null };
                ImportantTextTask hackText;

                if (tickDictionary.ContainsKey(hackPlayer.PlayerId))
                {
                    tickDictionary[hackPlayer.PlayerId] = DateTime.UtcNow;
                    yield break;
                }
                else
                {
                    hackText = new GameObject("_Player").AddComponent <ImportantTextTask>();
                    hackText.transform.SetParent(PlayerControl.LocalPlayer.transform, false);
                    hackText.Text =
                        $"{__instance.ColorString}Hacked {hackPlayer.Data.PlayerName} ({CustomGameOptions.HackDuration}s)\n";
                    hackText.Index = hackPlayer.PlayerId;
                    tickDictionary.Add(hackPlayer.PlayerId, DateTime.UtcNow);
                    PlayerControl.LocalPlayer.myTasks.Insert(0, hackText);
                }

                while (true)
                {
                    if (PlayerControl.LocalPlayer == hackPlayer)
                    {
                        if (HudManager.Instance.KillButton != null)
                        {
                            if (lockImg[0] == null)
                            {
                                lockImg[0] = new GameObject();
                                SpriteRenderer lockImgR = lockImg[0].AddComponent <SpriteRenderer>();
                                lockImgR.sprite = LockSprite;
                            }

                            lockImg[0].layer = 5;
                            lockImg[0].transform.position =
                                new Vector3(HudManager.Instance.KillButton.transform.position.x,
                                            HudManager.Instance.KillButton.transform.position.y, -50f);
                            HudManager.Instance.KillButton.enabled        = false;
                            HudManager.Instance.KillButton.renderer.color = Palette.DisabledClear;
                            HudManager.Instance.KillButton.renderer.material.SetFloat("_Desat", 1f);
                        }


                        if (HudManager.Instance.UseButton != null)
                        {
                            if (lockImg[1] == null)
                            {
                                lockImg[1] = new GameObject();
                                SpriteRenderer lockImgR = lockImg[1].AddComponent <SpriteRenderer>();
                                lockImgR.sprite = LockSprite;
                            }

                            lockImg[1].transform.position =
                                new Vector3(HudManager.Instance.UseButton.transform.position.x,
                                            HudManager.Instance.UseButton.transform.position.y, -50f);
                            lockImg[1].layer = 5;
                            HudManager.Instance.UseButton.enabled         = false;
                            HudManager.Instance.UseButton.UseButton.color = Palette.DisabledClear;
                            HudManager.Instance.UseButton.UseButton.material.SetFloat("_Desat", 1f);
                        }

                        if (HudManager.Instance.ReportButton != null)
                        {
                            if (lockImg[2] == null)
                            {
                                lockImg[2] = new GameObject();
                                SpriteRenderer lockImgR = lockImg[2].AddComponent <SpriteRenderer>();
                                lockImgR.sprite = LockSprite;
                            }

                            lockImg[2].transform.position =
                                new Vector3(HudManager.Instance.ReportButton.transform.position.x,
                                            HudManager.Instance.ReportButton.transform.position.y, -50f);
                            lockImg[2].layer = 5;
                            HudManager.Instance.ReportButton.enabled = false;
                            HudManager.Instance.ReportButton.SetActive(false);
                        }

                        var role = Roles.Role.GetRole(PlayerControl.LocalPlayer);
                        if (role != null)
                        {
                            if (role.ExtraButtons.Count > 0)
                            {
                                if (lockImg[3] == null)
                                {
                                    lockImg[3] = new GameObject();
                                    SpriteRenderer lockImgR = lockImg[3].AddComponent <SpriteRenderer>();
                                    lockImgR.sprite = LockSprite;
                                }

                                lockImg[3].transform.position = new Vector3(
                                    role.ExtraButtons[0].transform.position.x,
                                    role.ExtraButtons[0].transform.position.y, -50f);
                                lockImg[3].layer                    = 5;
                                role.ExtraButtons[0].enabled        = false;
                                role.ExtraButtons[0].renderer.color = Palette.DisabledClear;
                                role.ExtraButtons[0].renderer.material.SetFloat("_Desat", 1f);
                            }
                        }

                        if (Minigame.Instance)
                        {
                            Minigame.Instance.Close();
                            Minigame.Instance.Close();
                        }

                        if (MapBehaviour.Instance)
                        {
                            MapBehaviour.Instance.Close();
                            MapBehaviour.Instance.Close();
                        }
                    }

                    var totalHacktime = (DateTime.UtcNow - tickDictionary[hackPlayer.PlayerId]).TotalMilliseconds /
                                        1000;
                    hackText.Text =
                        $"{__instance.ColorString}Hacked {hackPlayer.Data.PlayerName} ({CustomGameOptions.HackDuration - Math.Round(totalHacktime)}s)\n";
                    if (MeetingHud.Instance || totalHacktime > CustomGameOptions.HackDuration || hackPlayer == null ||
                        hackPlayer.Data.IsDead)
                    {
                        foreach (GameObject obj in lockImg)
                        {
                            if (obj != null)
                            {
                                obj.SetActive(false);
                            }
                        }

                        if (PlayerControl.LocalPlayer == hackPlayer)
                        {
                            HudManager.Instance.UseButton.enabled         = true;
                            HudManager.Instance.ReportButton.enabled      = true;
                            HudManager.Instance.KillButton.enabled        = true;
                            HudManager.Instance.UseButton.UseButton.color = Palette.EnabledColor;
                            HudManager.Instance.UseButton.UseButton.material.SetFloat("_Desat", 0f);
                            var role = Roles.Role.GetRole(PlayerControl.LocalPlayer);
                            if (role != null)
                            {
                                if (role.ExtraButtons.Count > 0)
                                {
                                    role.ExtraButtons[0].enabled        = true;
                                    role.ExtraButtons[0].renderer.color = Palette.EnabledColor;
                                    role.ExtraButtons[0].renderer.material.SetFloat("_Desat", 0f);
                                }
                            }
                        }

                        tickDictionary.Remove(hackPlayer.PlayerId);
                        PlayerControl.LocalPlayer.myTasks.Remove(hackText);
                        yield break;
                    }

                    yield return(null);
                }
            }