public override void Loop() { base.Loop(); GameModeSettingsAddition = $"\nRandom Start Location: {Functions.ColorPurple}{(RandomStartLocation ? "On" : "Off")}"; if (!IsInGame) { return; } #region ----- Display new task text ----- string ToDisplay = "----- [ff7b00ff]Battle Royale[] -----\n" + "Be the last man standing!\n" + "\n" + $"Players left: { PlayerController.AllPlayerControls.Where(x => !x.PlayerData.IsDead).Count() }/{ MaxPlayerCount }"; PlayerHudManager.TaskText = ToDisplay + "\n--------------------"; // Current text #endregion #region ----- Display Kill Button ----- PlayerHudManager.HudManager.KillButton.gameObject.SetActive(!PlayerController.LocalPlayer.PlayerData.IsDead); // Activate Kill Button PlayerHudManager.HudManager.KillButton.isActive = !PlayerController.LocalPlayer.PlayerData.IsDead; // Activate Kill Button PlayerHudManager.HudManager.KillButton.transform.position = PlayerHudManager.HudManager.UseButton.transform.position; // Move the Kill Button PlayerHudManager.HudManager.ReportButton.enabled = false; // Disable report button PlayerHudManager.HudManager.ReportButton.gameObject.SetActive(false); // Disable report button PlayerHudManager.HudManager.ReportButton.renderer.color = new Color(1, 1, 1, 0); // Hide report button PlayerHudManager.HudManager.UseButton.enabled = false; // Disable use button PlayerHudManager.HudManager.UseButton.gameObject.SetActive(false); // Disable use button PlayerHudManager.HudManager.UseButton.UseButton.color = new Color(1, 1, 1, 0); // Hide use button #region --- Update Cooldown --- if (GameOptions.KillCooldown - (Functions.GetUnixTime() - LastKilled) <= 0) { LastKilled = 0; } if (LastKilled != 0) { PlayerHudManager.HudManager.KillButton.SetCoolDown(GameOptions.KillCooldown - (Functions.GetUnixTime() - LastKilled), GameOptions.KillCooldown); } else { PlayerHudManager.HudManager.KillButton.SetCoolDown(0, GameOptions.KillCooldown); } #endregion #region ----- End Game If Required ----- if (PlayerController.AllPlayerControls.Where(x => !x.PlayerData.IsDead).Count() == 1 && Started) { Started = false; if (!CheepsAmongUsMod.CheepsAmongUsMod.IsDecidingClient) { return; } Task.Run(async() => { await Task.Delay(2500); Patching.PatchFinishEndGame.CanEndGame = true; ShipStatusClass.PLBGOMIEONF(GameEndReason.ImpostorByKill, false); }); var winner = PlayerController.AllPlayerControls.Where(x => !x.PlayerData.IsDead).First(); winner.PlayerData.IsImpostor = true; RolePlayer MyRole = new RolePlayer(PlayerController.LocalPlayer, "Default"); MyRole.RoleOutro.UseRoleOutro = true; MyRole.RoleOutro.UseRoleOutro = true; if (winner.IsLocalPlayer) { MyRole.RoleOutro.WinText = "Victory Royale"; MyRole.RoleOutro.WinTextColor = new Color(255 / 255f, 174 / 255f, 0 / 255f); MyRole.RoleOutro.BackgroundColor = new Color(1f, 0.8f, 0f); } else { MyRole.RoleOutro.WinText = winner.PlayerData.PlayerName; MyRole.RoleOutro.WinTextColor = new Color(255 / 255f, 174 / 255f, 0 / 255f); MyRole.RoleOutro.BackgroundColor = new Color(1f, 0f, 0f); } RpcManager.SendRpc(BattleRoyale.BattleRoyalRpc, new byte[] { (byte)BattleRoyale.CustomRpcCalls.SetWinner, winner.PlayerId }); } #endregion if (!Started) { return; } #region ----- Get Closest Player ----- IEnumerable <PlayerController> AvailablePlayers = PlayerController.AllPlayerControls.Where(x => !x.PlayerData.IsDead && !x.IsLocalPlayer); PlayerController closest = AvailablePlayers.ToList()[0]; foreach (var player in AvailablePlayers) { float DistOld = Vector2.Distance(closest.Position, PlayerController.LocalPlayer.Position); float DistNew = Vector2.Distance(player.Position, PlayerController.LocalPlayer.Position); if (DistNew < DistOld) { closest = player; } } #endregion #region --- Update Target --- if (Vector2.Distance(closest.Position, PlayerController.LocalPlayer.Position) <= KillDistance) { PlayerHudManager.HudManager.KillButton.SetTarget(closest.PlayerControl); PlayerHudManager.HudManager.KillButton.CurrentTarget = closest.PlayerControl; Patching.PatchPerformKill.Target = closest; } else { Patching.PatchPerformKill.Target = null; } #endregion #endregion }
public static void RpcEndGame(EndGameReason reason) { ShipStatusClass.PLBGOMIEONF(reason, false); }