public override void OnKill(PlayerControl target) { // キルクールダウン設定 if (PlayerControl.LocalPlayer.isRole(RoleType.Trapper)) { if (Trap.isTrapped(target) && !isTrapKill) // トラップにかかっている対象をキルした場合のボーナス { Helpers.log("トラップにかかっている対象をキルした場合のボーナス"); player.killTimer = PlayerControl.GameOptions.KillCooldown - bonusTime; trapperSetTrapButton.Timer = cooldown - bonusTime; } else if (Trap.isTrapped(target) && isTrapKill) // トラップキルした場合のペナルティ { Helpers.log("トラップキルした場合のクールダウン"); player.killTimer = PlayerControl.GameOptions.KillCooldown; trapperSetTrapButton.Timer = cooldown; } else // トラップにかかっていない対象を通常キルした場合はペナルティーを受ける { Helpers.log("通常キル時のペナルティ"); player.killTimer = PlayerControl.GameOptions.KillCooldown + penaltyTime; trapperSetTrapButton.Timer = cooldown + penaltyTime; } if (!isTrapKill) { MessageWriter writer; writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ClearTrap, Hazel.SendOption.Reliable, -1); AmongUsClient.Instance.FinishRpcImmediately(writer); RPCProcedure.clearTrap(); } isTrapKill = false; } }
public static void eraseModifier(this PlayerControl player, ModifierType mod) { if (hasModifier(player, mod)) { foreach (var t in ModifierData.allModTypes) { if (mod == t.Key) { t.Value.GetMethod("eraseModifier", BindingFlags.Public | BindingFlags.Static)?.Invoke(null, new object[] { player }); return; } } Helpers.log($"eraseRole: no method found for role type {mod}"); } }
public static void eraseRole(this PlayerControl player, RoleType role) { if (isRole(player, role)) { foreach (var t in RoleData.allRoleTypes) { if (role == t.Key) { t.Value.GetMethod("eraseRole", BindingFlags.Public | BindingFlags.Static)?.Invoke(null, new object[] { player }); return; } } Helpers.log($"eraseRole: no method found for role type {role}"); } }
public override void FixedUpdate() { // 処理に自信がないので念の為tryで囲っておく try{ if (PlayerControl.LocalPlayer.isRole(RoleType.Trapper) && Trap.traps.Count != 0 && !Trap.hasTrappedPlayer() && !meetingFlag) { // トラップを踏んだプレイヤーを動けなくする foreach (var p in PlayerControl.AllPlayerControls) { foreach (var trap in Trap.traps) { if (DateTime.UtcNow.Subtract(trap.Value.placedTime).TotalSeconds < extensionTime) { continue; } if (trap.Value.isActive || p.isDead() || p.inVent || meetingFlag) { continue; } var p1 = p.transform.localPosition; Dictionary <GameObject, byte> listActivate = new Dictionary <GameObject, byte>(); var p2 = trap.Value.trap.transform.localPosition; var distance = Vector3.Distance(p1, p2); if (distance < trapRange) { TMPro.TMP_Text text; RoomTracker roomTracker = HudManager.Instance?.roomTracker; GameObject gameObject = UnityEngine.Object.Instantiate(roomTracker.gameObject); UnityEngine.Object.DestroyImmediate(gameObject.GetComponent <RoomTracker>()); gameObject.transform.SetParent(HudManager.Instance.transform); gameObject.transform.localPosition = new Vector3(0, -1.8f, gameObject.transform.localPosition.z); gameObject.transform.localScale = Vector3.one * 2f; text = gameObject.GetComponent <TMPro.TMP_Text>(); text.text = String.Format(ModTranslation.getString("trapperGetTrapped"), p.name); HudManager.Instance.StartCoroutine(Effects.Lerp(3f, new Action <float>((p) => { if (p == 1f && text != null && text.gameObject != null) { UnityEngine.Object.Destroy(text.gameObject); } }))); MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ActivateTrap, Hazel.SendOption.Reliable, -1); writer.Write(trap.Key); writer.Write(PlayerControl.LocalPlayer.PlayerId); writer.Write(p.PlayerId); AmongUsClient.Instance.FinishRpcImmediately(writer); RPCProcedure.activateTrap(trap.Key, PlayerControl.LocalPlayer.PlayerId, p.PlayerId); break; } } } } if (PlayerControl.LocalPlayer.isRole(RoleType.Trapper) && Trap.hasTrappedPlayer() && !meetingFlag) { // トラップにかかっているプレイヤーを救出する foreach (var trap in Trap.traps) { if (trap.Value.trap == null || !trap.Value.isActive) { return; } Vector3 p1 = trap.Value.trap.transform.position; foreach (var player in PlayerControl.AllPlayerControls) { if (player.PlayerId == trap.Value.target.PlayerId || player.isDead() || player.inVent || player.isRole(RoleType.Trapper)) { continue; } Vector3 p2 = player.transform.position; float distance = Vector3.Distance(p1, p2); if (distance < 0.5) { MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.DisableTrap, Hazel.SendOption.Reliable, -1); writer.Write(trap.Key); AmongUsClient.Instance.FinishRpcImmediately(writer); RPCProcedure.disableTrap(trap.Key); } } } } } catch (NullReferenceException e) { Helpers.log(e.Message); } }
public static void setRole(this PlayerControl player, RoleType role) { foreach (var t in RoleData.allRoleTypes) { if (role == t.Key) { t.Value.GetMethod("setRole", BindingFlags.Public | BindingFlags.Static)?.Invoke(null, new object[] { player }); return; } } switch (role) { case RoleType.Jester: Jester.jester = player; break; case RoleType.Mayor: Mayor.mayor = player; break; case RoleType.Engineer: Engineer.engineer = player; break; case RoleType.Godfather: Godfather.godfather = player; break; case RoleType.Mafioso: Mafioso.mafioso = player; break; case RoleType.Janitor: Janitor.janitor = player; break; case RoleType.Detective: Detective.detective = player; break; case RoleType.TimeMaster: TimeMaster.timeMaster = player; break; case RoleType.Medic: Medic.medic = player; break; case RoleType.Shifter: Shifter.shifter = player; break; case RoleType.Swapper: Swapper.swapper = player; break; case RoleType.Seer: Seer.seer = player; break; case RoleType.Morphling: Morphling.morphling = player; break; case RoleType.Camouflager: Camouflager.camouflager = player; break; case RoleType.EvilHacker: EvilHacker.evilHacker = player; break; case RoleType.Hacker: Hacker.hacker = player; break; case RoleType.Tracker: Tracker.tracker = player; break; case RoleType.Vampire: Vampire.vampire = player; break; case RoleType.Snitch: Snitch.snitch = player; break; case RoleType.Jackal: Jackal.jackal = player; break; case RoleType.Sidekick: Sidekick.sidekick = player; break; case RoleType.Eraser: Eraser.eraser = player; break; case RoleType.Spy: Spy.spy = player; break; case RoleType.Trickster: Trickster.trickster = player; break; case RoleType.Cleaner: Cleaner.cleaner = player; break; case RoleType.Warlock: Warlock.warlock = player; break; case RoleType.SecurityGuard: SecurityGuard.securityGuard = player; break; case RoleType.Arsonist: Arsonist.arsonist = player; break; case RoleType.EvilGuesser: Guesser.evilGuesser = player; break; case RoleType.NiceGuesser: Guesser.niceGuesser = player; break; case RoleType.BountyHunter: BountyHunter.bountyHunter = player; break; case RoleType.Bait: Bait.bait = player; break; case RoleType.GM: GM.gm = player; break; case RoleType.Vulture: Vulture.vulture = player; break; case RoleType.Medium: Medium.medium = player; break; case RoleType.Witch: Witch.witch = player; break; case RoleType.Assassin: Assassin.assassin = player; break; case RoleType.Lawyer: Lawyer.lawyer = player; break; case RoleType.Pursuer: Pursuer.pursuer = player; break; default: Helpers.log($"setRole: no method found for role type {role}"); return; } }
public static bool isRole(this PlayerControl player, RoleType role) { foreach (var t in RoleData.allRoleTypes) { if (role == t.Key) { return((bool)t.Value.GetMethod("isRole", BindingFlags.Public | BindingFlags.Static)?.Invoke(null, new object[] { player })); } } switch (role) { case RoleType.Jester: return(Jester.jester == player); case RoleType.Mayor: return(Mayor.mayor == player); case RoleType.Engineer: return(Engineer.engineer == player); case RoleType.Godfather: return(Godfather.godfather == player); case RoleType.Mafioso: return(Mafioso.mafioso == player); case RoleType.Janitor: return(Janitor.janitor == player); case RoleType.Detective: return(Detective.detective == player); case RoleType.TimeMaster: return(TimeMaster.timeMaster == player); case RoleType.Medic: return(Medic.medic == player); case RoleType.Shifter: return(Shifter.shifter == player); case RoleType.Swapper: return(Swapper.swapper == player); case RoleType.Seer: return(Seer.seer == player); case RoleType.Morphling: return(Morphling.morphling == player); case RoleType.Camouflager: return(Camouflager.camouflager == player); case RoleType.EvilHacker: return(EvilHacker.evilHacker == player); case RoleType.Hacker: return(Hacker.hacker == player); case RoleType.Tracker: return(Tracker.tracker == player); case RoleType.Vampire: return(Vampire.vampire == player); case RoleType.Snitch: return(Snitch.snitch == player); case RoleType.Jackal: return(Jackal.jackal == player); case RoleType.Sidekick: return(Sidekick.sidekick == player); case RoleType.Eraser: return(Eraser.eraser == player); case RoleType.Spy: return(Spy.spy == player); case RoleType.Trickster: return(Trickster.trickster == player); case RoleType.Cleaner: return(Cleaner.cleaner == player); case RoleType.Warlock: return(Warlock.warlock == player); case RoleType.SecurityGuard: return(SecurityGuard.securityGuard == player); case RoleType.Arsonist: return(Arsonist.arsonist == player); case RoleType.EvilGuesser: return(Guesser.evilGuesser == player); case RoleType.NiceGuesser: return(Guesser.niceGuesser == player); case RoleType.BountyHunter: return(BountyHunter.bountyHunter == player); case RoleType.Bait: return(Bait.bait == player); case RoleType.GM: return(GM.gm == player); case RoleType.Vulture: return(Vulture.vulture == player); case RoleType.Medium: return(Medium.medium == player); case RoleType.Witch: return(Witch.witch == player); case RoleType.Assassin: return(Assassin.assassin == player); case RoleType.Lawyer: return(Lawyer.lawyer == player); case RoleType.Pursuer: return(Pursuer.pursuer == player); default: Helpers.log($"isRole: no method found for role type {role}"); break; } return(false); }