コード例 #1
0
 public static void clearAllTasks(this PlayerControl player)
 {
     for (int i = 0; i < player.myTasks.Count; i++)
     {
         PlayerTask playerTask = player.myTasks[i];
         playerTask.OnRemove();
         UnityEngine.Object.Destroy(playerTask.gameObject);
     }
     player.myTasks.Clear();
 }
コード例 #2
0
        public static void clearAllTasks(this PlayerControl player)
        {
            if (player == null)
            {
                return;
            }
            for (int i = 0; i < player.myTasks.Count; i++)
            {
                PlayerTask playerTask = player.myTasks[i];
                playerTask.OnRemove();
                UnityEngine.Object.Destroy(playerTask.gameObject);
            }
            player.myTasks.Clear();

            if (player.Data != null && player.Data.Tasks != null)
            {
                player.Data.Tasks.Clear();
            }
        }
コード例 #3
0
        public static void ClearTasksCustom(this PlayerControl playerControl, bool keepSabotageTasks = true)
        {
            for (int i = playerControl.myTasks.Count - 1; i >= 0; i--)
            {
                PlayerTask task = playerControl.myTasks.ToArray()[i];

                if (keepSabotageTasks && (task.TaskType == TaskTypes.FixComms ||
                                          task.TaskType == TaskTypes.ResetReactor ||
                                          task.TaskType == TaskTypes.ResetSeismic ||
                                          task.TaskType == TaskTypes.RestoreOxy))
                {
                    continue;
                }

                task.OnRemove();
                playerControl.RemoveTask(task);
                Object.Destroy(task.gameObject);
            }
        }
コード例 #4
0
        public static void MurderPlayer(PlayerControl killer, PlayerControl target)
        {
            GameData.PlayerInfo data = target.Data;
            if (data != null && !data.IsDead)
            {
                if (killer == PlayerControl.LocalPlayer)
                {
                    SoundManager.Instance.PlaySound(PlayerControl.LocalPlayer.KillSfx, false, 0.8f);
                }

                target.gameObject.layer = LayerMask.NameToLayer("Ghost");
                if (target.AmOwner)
                {
                    try
                    {
                        if (Minigame.Instance)
                        {
                            Minigame.Instance.Close();
                            Minigame.Instance.Close();
                        }

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

                    DestroyableSingleton <HudManager> .Instance.KillOverlay.ShowOne(killer.Data, data);

                    DestroyableSingleton <HudManager> .Instance.ShadowQuad.gameObject.SetActive(false);

                    target.nameText.GetComponent <MeshRenderer>().material.SetInt("_Mask", 0);
                    target.RpcSetScanner(false);
                    ImportantTextTask importantTextTask = new GameObject("_Player").AddComponent <ImportantTextTask>();
                    importantTextTask.transform.SetParent(AmongUsClient.Instance.transform, false);
                    if (!PlayerControl.GameOptions.GhostsDoTasks)
                    {
                        for (int i = 0; i < target.myTasks.Count; i++)
                        {
                            PlayerTask playerTask = target.myTasks.ToArray()[i];
                            playerTask.OnRemove();
                            UnityEngine.Object.Destroy(playerTask.gameObject);
                        }

                        target.myTasks.Clear();
                        importantTextTask.Text = DestroyableSingleton <TranslationController> .Instance.GetString(
                            StringNames.GhostIgnoreTasks,
                            new UnhollowerBaseLib.Il2CppReferenceArray <Il2CppSystem.Object>(0));
                    }
                    else
                    {
                        importantTextTask.Text = DestroyableSingleton <TranslationController> .Instance.GetString(
                            StringNames.GhostDoTasks,
                            new UnhollowerBaseLib.Il2CppReferenceArray <Il2CppSystem.Object>(0));
                    }

                    target.myTasks.Insert(0, importantTextTask);
                }

                killer.MyPhysics.StartCoroutine(killer.KillAnimations.Random <KillAnimation>()
                                                .CoPerformKill(killer, target));
                var deadBody = new DeadPlayer
                {
                    PlayerId = target.PlayerId,
                    KillerId = killer.PlayerId,
                    KillTime = DateTime.UtcNow,
                };

                Murder.KilledPlayers.Add(deadBody);
                if (!killer.Is(RoleEnum.Glitch) && !killer.Is(RoleEnum.Arsonist))
                {
                    ChildMod.Murder.CheckChild(target);
                }

                if (target.Is(ModifierEnum.Diseased) && killer.Is(RoleEnum.Glitch))
                {
                    var glitch = Roles.Role.GetRole <Roles.Glitch>(killer);
                    glitch.LastKill = DateTime.UtcNow.AddSeconds(2 * CustomGameOptions.GlitchKillCooldown);
                    glitch.Player.SetKillTimer(CustomGameOptions.GlitchKillCooldown * 3);
                }
            }
        }
コード例 #5
0
        private static void MurderPlayer(
            PlayerVoteArea voteArea,
            PlayerControl player,
            bool checkLover = true
            )
        {
            var hudManager = DestroyableSingleton <HudManager> .Instance;

            if (checkLover)
            {
                SoundManager.Instance.PlaySound(player.KillSfx, false, 0.8f);
                hudManager.KillOverlay.ShowKillAnimation(player.Data, player.Data);
            }
            var amOwner = player.AmOwner;

            if (amOwner)
            {
                hudManager.ShadowQuad.gameObject.SetActive(false);
                player.nameText.GetComponent <MeshRenderer>().material.SetInt("_Mask", 0);
                player.RpcSetScanner(false);
                ImportantTextTask importantTextTask = new GameObject("_Player").AddComponent <ImportantTextTask>();
                importantTextTask.transform.SetParent(AmongUsClient.Instance.transform, false);
                if (!PlayerControl.GameOptions.GhostsDoTasks)
                {
                    for (int i = 0; i < player.myTasks.Count; i++)
                    {
                        PlayerTask playerTask = player.myTasks.ToArray()[i];
                        playerTask.OnRemove();
                        Object.Destroy(playerTask.gameObject);
                    }

                    player.myTasks.Clear();
                    importantTextTask.Text = DestroyableSingleton <TranslationController> .Instance.GetString(
                        StringNames.GhostIgnoreTasks,
                        new UnhollowerBaseLib.Il2CppReferenceArray <Il2CppSystem.Object>(0)
                        );
                }
                else
                {
                    importantTextTask.Text = DestroyableSingleton <TranslationController> .Instance.GetString(
                        StringNames.GhostDoTasks,
                        new UnhollowerBaseLib.Il2CppReferenceArray <Il2CppSystem.Object>(0));
                }

                player.myTasks.Insert(0, importantTextTask);

                if (player.Is(RoleEnum.Swapper))
                {
                    var buttons = Role.GetRole <Swapper>(player).Buttons;
                    foreach (var button in buttons)
                    {
                        button.SetActive(false);
                        button.GetComponent <PassiveButton>().OnClick = new Button.ButtonClickedEvent();
                    }
                }
            }
            player.Die(DeathReason.Kill);
            if (checkLover && player.isLover() && CustomGameOptions.BothLoversDie)
            {
                MurderPlayer(Role.GetRole <Lover>(player).OtherLover.Player, false);
            }

            var meetingHud = MeetingHud.Instance;

            if (amOwner)
            {
                meetingHud.SetForegroundForDead();
            }
            var deadPlayer = new DeadPlayer
            {
                PlayerId = player.PlayerId,
                KillerId = player.PlayerId,
                KillTime = System.DateTime.UtcNow,
            };

            Murder.KilledPlayers.Add(deadPlayer);
            if (voteArea == null)
            {
                return;
            }
            if (voteArea.DidVote)
            {
                voteArea.UnsetVote();
            }
            voteArea.AmDead = true;
            voteArea.Overlay.gameObject.SetActive(true);
            voteArea.Overlay.color = Color.white;
            voteArea.XMark.gameObject.SetActive(true);
            voteArea.XMark.transform.localScale = Vector3.one;

            voteArea.Buttons.SetActive(false);
            var amHost = AmongUsClient.Instance.AmHost;

            foreach (var playerVoteArea in meetingHud.playerStates)
            {
                if (playerVoteArea.VotedFor != player.PlayerId)
                {
                    continue;
                }
                playerVoteArea.UnsetVote();
                var voteAreaPlayer = Utils.PlayerById(playerVoteArea.TargetPlayerId);
                if (!voteAreaPlayer.AmOwner)
                {
                    continue;
                }
                meetingHud.ClearVote();
            }

            if (!amHost)
            {
                return;
            }
            foreach (var role in Role.GetRoles(RoleEnum.Mayor))
            {
                var mayor = (Mayor)role;
                if (role.Player.PlayerId == player.PlayerId)
                {
                    mayor.ExtraVotes.Clear();
                }
                else
                {
                    var votesRegained = mayor.ExtraVotes.RemoveAll(x => x == player.PlayerId);

                    if (mayor.Player == PlayerControl.LocalPlayer)
                    {
                        mayor.VoteBank += votesRegained;
                    }

                    var writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                            (byte)CustomRPC.AddMayorVoteBank, SendOption.Reliable, -1);
                    writer.Write(mayor.Player.PlayerId);
                    writer.Write(votesRegained);
                    AmongUsClient.Instance.FinishRpcImmediately(writer);
                }
            }
            meetingHud.CheckForEndVoting();
        }
コード例 #6
0
        public static void Murder(PlayerControl killer, PlayerControl victim)
        {
            GameData.PlayerInfo data = victim.Data;
            if (data != null && !data.IsDead)
            {
                if (killer == PlayerControl.LocalPlayer)
                {
                    SoundManager.Instance.PlaySound(PlayerControl.LocalPlayer.KillSfx, false, 0.8f);
                }
                victim.gameObject.layer = LayerMask.NameToLayer("Ghost");
                if (victim.AmOwner)
                {
                    try
                    {
                        if (Minigame.Instance)
                        {
                            Minigame.Instance.Close();
                            Minigame.Instance.Close();
                        }

                        if (MapBehaviour.Instance)
                        {
                            MapBehaviour.Instance.Close();
                            MapBehaviour.Instance.Close();
                        }
                    }catch { }
                    DestroyableSingleton <HudManager> .Instance.KillOverlay.ShowOne(killer.Data, data);

                    DestroyableSingleton <HudManager> .Instance.ShadowQuad.gameObject.SetActive(false);

                    victim.nameText.GetComponent <MeshRenderer>().material.SetInt("_Mask", 0);
                    victim.RpcSetScanner(false);
                    ImportantTextTask importantTextTask = new GameObject("_Player").AddComponent <ImportantTextTask>();
                    importantTextTask.transform.SetParent(AmongUsClient.Instance.transform, false);
                    if (!PlayerControl.GameOptions.GhostsDoTasks)
                    {
                        for (int i = 0; i < victim.myTasks.Count; i++)
                        {
                            PlayerTask playerTask = victim.myTasks.ToArray()[i];
                            playerTask.OnRemove();
                            UnityEngine.Object.Destroy(playerTask.gameObject);
                        }
                        victim.myTasks.Clear();
                        importantTextTask.Text = DestroyableSingleton <TranslationController> .Instance.GetString(StringNames.GhostIgnoreTasks, new UnhollowerBaseLib.Il2CppReferenceArray <Il2CppSystem.Object>(0));
                    }
                    else
                    {
                        importantTextTask.Text = DestroyableSingleton <TranslationController> .Instance.GetString(
                            StringNames.GhostDoTasks,
                            new UnhollowerBaseLib.Il2CppReferenceArray <Il2CppSystem.Object>(0));
                    }
                    victim.myTasks.Insert(0, importantTextTask);
                }
                killer.MyPhysics.StartCoroutine(killer.KillAnimations.Random <KillAnimation>().CoPerformKill(killer, victim));
                var deadBody = new DeadPlayer
                {
                    PlayerId = victim.PlayerId,
                    KillerId = killer.PlayerId,
                    KillTime = DateTime.UtcNow,
                };
            }
        }