public static void Prefix(IntroCutscene __instance) { // Arsonist generate player icons if (PlayerControl.LocalPlayer != null && PlayerControl.LocalPlayer == Arsonist.arsonist && HudManager.Instance != null) { int playerCounter = 0; Vector3 bottomLeft = new Vector3(-HudManager.Instance.UseButton.transform.localPosition.x, HudManager.Instance.UseButton.transform.localPosition.y, HudManager.Instance.UseButton.transform.localPosition.z); bottomLeft += new Vector3(-0.25f, -0.25f, 0); foreach (PlayerControl player in PlayerControl.AllPlayerControls) { if (player != PlayerControl.LocalPlayer) { GameData.PlayerInfo data = player.Data; PoolablePlayer poolablePlayer = UnityEngine.Object.Instantiate <PoolablePlayer>(__instance.PlayerPrefab, HudManager.Instance.transform); poolablePlayer.transform.localPosition = bottomLeft + Vector3.right * playerCounter * 0.35f; poolablePlayer.transform.localScale = Vector3.one * 0.3f; PlayerControl.SetPlayerMaterialColors(data.ColorId, poolablePlayer.Body); DestroyableSingleton <HatManager> .Instance.SetSkin(poolablePlayer.SkinSlot, data.SkinId); poolablePlayer.HatSlot.SetHat(data.HatId, data.ColorId); PlayerControl.SetPetImage(data.PetId, data.ColorId, poolablePlayer.PetSlot); poolablePlayer.NameText.text = data.PlayerName; poolablePlayer.SetFlipX(true); poolablePlayer.setSemiTransparent(true); Arsonist.dousedIcons[player.PlayerId] = poolablePlayer; playerCounter++; } } } }
public static void BeginImpostor(IntroCutscene introCutscene) { introCutscene.ImpostorText.gameObject.SetActive(false); introCutscene.Title.Text = DestroyableSingleton <TranslationController> .Instance.GetString(StringNames.Impostor, (Il2CppReferenceArray <Object>) Array.Empty <object>()); introCutscene.Title.Color = Palette.ImpostorRed; GameData.PlayerInfo data = PlayerControl.LocalPlayer.Data; if (data != null) { int num = -1; int num2 = 1 / 2; float num3 = 1f - (float)num2 * 0.075f; float num4 = 1f - (float)num2 * 0.035f; float num5 = -8; PoolablePlayer poolablePlayer = UnityEngine.Object.Instantiate <PoolablePlayer>(introCutscene.PlayerPrefab, introCutscene.transform); poolablePlayer.transform.localPosition = new Vector3((float)(num * num2) * num4, introCutscene.BaseY + (float)num2 * 0.15f, num5 + (float)num2 * 0.01f) * 1.5f; Vector3 vector = new Vector3(num3, num3, num3) * 1.5f; poolablePlayer.transform.localScale = vector; poolablePlayer.SetFlipX(false); PlayerControl.SetPlayerMaterialColors((int)data.ColorId, poolablePlayer.Body); //DestroyableSingleton<HatManager>.Instance.SetSkin(poolablePlayer.SkinSlot, data.SkinId); poolablePlayer.HatSlot.SetHat(data.HatId, (int)data.ColorId); PlayerControl.SetPetImage(data.PetId, (int)data.ColorId, poolablePlayer.PetSlot); TextRenderer nameText = poolablePlayer.NameText; nameText.Text = data.PlayerName; nameText.transform.localScale = vector.Inv(); } }
private static bool Prefix(EndGameManager __instance) { if (!TempData.EndReason.IsCustom()) { return(true); } var reason = CustomGameOverReasonManager.EndReason; bool youWon = CustomGameOverReasonManager.Winners.Any(w => w.IsYou); __instance.WinText.text = reason.WinText; __instance.WinText.color = reason.GetWinTextColor(youWon); __instance.BackgroundBar.material.SetColor(Color, reason.GetBackgroundColor(youWon)); AudioClip?sound = reason.Stinger; SoundManager.Instance.PlayDynamicSound( "Stinger", sound == null ? __instance.ImpostorStinger : sound, false, (DynamicSound.GetDynamicsFunction)__instance.GetStingerVol ); for (int i = 0; i < CustomGameOverReasonManager.ShownWinners.Count; i++) { var winner = CustomGameOverReasonManager.ShownWinners[i]; int oddness = (i + 1) / 2; PoolablePlayer player = Object.Instantiate(__instance.PlayerPrefab, __instance.transform); var transform = player.transform; transform.localPosition = new Vector3( 0.8f * (i % 2 == 0 ? -1 : 1) * oddness * 1 - oddness * 0.035f, __instance.BaseY - 0.25f + oddness * 0.1f, (i == 0 ? -8 : -1) + oddness * 0.01f ) * 1.25f; float scale = 1f - oddness * 0.075f; var scaleVec = new Vector3(scale, scale, scale) * 1.25f; transform.localScale = scaleVec; if (winner.IsDead) { player.Body.sprite = __instance.GhostSprite; player.SetDeadFlipX(i % 2 == 1); player.HatSlot.color = GhostColor; } else { player.SetFlipX(i % 2 == 0); DestroyableSingleton <HatManager> .Instance.SetSkin(player.SkinSlot, winner.SkinId); // SetSkin } PlayerControl.SetPlayerMaterialColors(winner.ColorId, player.Body); player.HatSlot.SetHat(winner.HatId, winner.ColorId); PlayerControl.SetPetImage(winner.PetId, winner.ColorId, player.PetSlot); player.NameText.text = winner.Name; player.NameText.transform.localScale = global::Extensions.Inv(scaleVec); } return(false); }
public static void setSemiTransparent(this PoolablePlayer player, bool value) { float alpha = value ? 0.25f : 1f; foreach (SpriteRenderer r in player.gameObject.GetComponentsInChildren <SpriteRenderer>()) { r.color = new Color(r.color.r, r.color.g, r.color.b, alpha); } player.NameText.color = new Color(player.NameText.color.r, player.NameText.color.g, player.NameText.color.b, alpha); }
public static bool Prefix(ref IntroCutscene __instance) { BaseRole?myRole = PlayerControl.LocalPlayer.GetRole(); if (myRole == null || myRole.PatchFilterFlags.HasFlag(PatchFilter.IntroCutScene)) { return(true); } PlayerControl.LocalPlayer.SetKillTimer(10f); HudManager.Instance.KillButton.gameObject.SetActive(myRole.CanKill(null)); List <PlayerControl> myTeam = PlayerControl.AllPlayerControls.ToArray() .Where(p => PlayerControl.LocalPlayer.CanSeeSpecial(p)) .OrderBy(p => !p.AmOwner) .ToList(); __instance.Title.text = myRole.Name; __instance.Title.color = myRole.Color; __instance.BackgroundBar.material.SetColor(Color, myRole.Color); __instance.ImpostorText.text = myRole.Description; for (var i = 0; i < myTeam.Count; i++) { GameData.PlayerInfo data = myTeam[i].Data; int oddness = (i + 1) / 2; PoolablePlayer player = Object.Instantiate(__instance.PlayerPrefab, __instance.transform); player.transform.localPosition = new Vector3( 0.8f * oddness * (i % 2 == 0 ? -1 : 1) * (1 - oddness * 0.08f), __instance.BaseY + oddness * 0.15f, (i == 0 ? -8 : -1) + oddness * 0.01f ) * 1.5f; player.SetFlipX(i % 2 == 0); PlayerControl.SetPlayerMaterialColors(data.ColorId, player.Body); DestroyableSingleton <HatManager> .Instance.SetSkin(player.SkinSlot, data.SkinId); // SetSkin player.HatSlot.SetHat(data.HatId, data.ColorId); PlayerControl.SetPetImage(data.PetId, data.ColorId, player.PetSlot); float scale = 1f - oddness * 0.075f; Vector3 scaleVec = new Vector3(scale, scale, scale) * 1.5f; player.transform.localScale = scaleVec; player.NameText.transform.localScale = global::Extensions.Inv(scaleVec); player.NameText.text = myRole.FormatName(data); if (i > 0 && myRole.Visibility != Visibility.Everyone) { player.NameText.gameObject.SetActive(true); } } return(false); }
public static void Postfix(PoolablePlayer __instance) { if (__instance.VisorSlot?.transform == null || __instance.HatSlot?.transform == null) { return; } // fixes a bug in the original where the visor will show up beneath the hat, // instead of on top where it's supposed to be __instance.VisorSlot.transform.localPosition = new Vector3( __instance.VisorSlot.transform.localPosition.x, __instance.VisorSlot.transform.localPosition.y, __instance.HatSlot.transform.localPosition.z - 1 ); }
public void Initialize(int playerID, Vector3 position, Quaternion rotation) { //spawned[playerID] = true; var playerObject = Instantiate(playerPrefab, position, rotation, pool.parent); playerObject.name = (playerObject.name + playerID); PlayerController controller = playerObject.GetComponentInChildren <PlayerController>(); //if (controller == null) //Debug.LogError("ERROR: Couldn't find PlayerController"); DamageableBehaviour initDamageable = playerObject.GetComponentInChildren <DamageableBehaviour>(); //if (initDamageable == null) //Debug.LogError("ERROR: Couldn't find DamageableBehaviour"); controller.myID = playerID; PoolablePlayer PlayerInit = new PoolablePlayer { movementController = controller, damageableBehaviour = initDamageable }; if (PlayerInit.DamageableConfig != null) { PlayerInit.DamageableConfig.playerID = playerID; PlayerInit.DamageableConfig.AlignmentProvider = teams[playerID].alignment; var meshRenderer = PlayerInit.DamageableConfig.materialObject.GetComponentInChildren <SkinnedMeshRenderer>(); if (meshRenderer != null) { meshRenderer.material = teams[playerID].material; } PlayerInit.DamageableConfig.IsAlive = true; } else { //Debug.LogError("No DamageableBehaviour component on player object"); } PlayerJoined?.Invoke(playerID); players.Add(PlayerInit); }
public static void Prefix(IntroCutscene __instance) { if (PlayerControl.LocalPlayer != null && HudManager.Instance != null) { Vector3 bottomLeft = new Vector3(-HudManager.Instance.UseButton.transform.localPosition.x, HudManager.Instance.UseButton.transform.localPosition.y, HudManager.Instance.UseButton.transform.localPosition.z); foreach (PlayerControl p in PlayerControl.AllPlayerControls) { GameData.PlayerInfo data = p.Data; PoolablePlayer player = UnityEngine.Object.Instantiate <PoolablePlayer>(__instance.PlayerPrefab, HudManager.Instance.transform); player.UpdateFromPlayerOutfit(p.Data.DefaultOutfit, p.Data.IsDead); player.SetFlipX(true); player.PetSlot.gameObject.SetActive(false); player.NameText.text = p.Data.DefaultOutfit.PlayerName; player.gameObject.SetActive(false); playerIcons[p.PlayerId] = player; } } }
public static void MakeButtons(HudManager hm) { lastImpostorButtons = new List <CustomButton>(); Vector3 lastImpostorCalcPos(byte index) { //return new Vector3(-0.25f, -0.25f, 0) + Vector3.right * index * 0.55f; return(new Vector3(-0.25f, -0.15f, 0) + Vector3.right * index * 0.55f); } Action lastImpostorButtonOnClick(byte index) { return(() => { if (selectedFunction == 1) { return; } PlayerControl p = Helpers.playerById(index); LastImpostor.divine(p); }); }; Func <bool> lastImpostorHasButton(byte index) { return(() => { if (selectedFunction == 1) { return false; } var p = PlayerControl.LocalPlayer; if (!p.hasModifier(ModifierType.LastImpostor)) { return false; } if (p.hasModifier(ModifierType.LastImpostor) && p.CanMove && p.isAlive() & p.PlayerId != index && MapOptions.playerIcons.ContainsKey(index) && numUsed < 1 && isCounterMax()) { return true; } else { if (playerIcons.ContainsKey(index)) { playerIcons[index].gameObject.SetActive(false); if (PlayerControl.LocalPlayer.isRole(RoleType.BountyHunter)) { setBountyIconPos(Vector3.zero); } } if (lastImpostorButtons.Count > index) { lastImpostorButtons[index].setActive(false); } return false; } }); } void setButtonPos(byte index) { Vector3 pos = lastImpostorCalcPos(index); Vector3 scale = new Vector3(0.4f, 0.8f, 1.0f); Vector3 iconBase = hm.UseButton.transform.localPosition; iconBase.x *= -1; if (lastImpostorButtons[index].PositionOffset != pos) { lastImpostorButtons[index].PositionOffset = pos; lastImpostorButtons[index].LocalScale = scale; playerIcons[index].transform.localPosition = iconBase + pos; } } void setIconStatus(byte index, bool transparent) { playerIcons[index].transform.localScale = Vector3.one * 0.25f; playerIcons[index].gameObject.SetActive(PlayerControl.LocalPlayer.CanMove); playerIcons[index].setSemiTransparent(transparent); } void setBountyIconPos(Vector3 offset) { Vector3 bottomLeft = new Vector3(-HudManager.Instance.UseButton.transform.localPosition.x, HudManager.Instance.UseButton.transform.localPosition.y, HudManager.Instance.UseButton.transform.localPosition.z); PoolablePlayer icon = MapOptions.playerIcons[BountyHunter.bounty.PlayerId]; icon.transform.localPosition = bottomLeft + new Vector3(-0.25f, 0f, 0) + offset; BountyHunter.cooldownText.transform.localPosition = bottomLeft + new Vector3(-0.25f, 0f, -1f) + offset; } Func <bool> lastImpostorCouldUse(byte index) { return(() => { if (selectedFunction == 1) { return false; } // ラストインポスター以外の場合、リソースがない場合はボタンを表示しない var p = Helpers.playerById(index); if (!playerIcons.ContainsKey(index) || !PlayerControl.LocalPlayer.hasModifier(ModifierType.LastImpostor) || !isCounterMax()) { return false; } // ボタンの位置を変更 setButtonPos(index); // ボタンにテキストを設定 lastImpostorButtons[index].buttonText = PlayerControl.LocalPlayer.isAlive() ? "生存": "死亡"; // アイコンの位置と透明度を変更 setIconStatus(index, false); // Bounty Hunterの場合賞金首の位置をずらして表示する if (PlayerControl.LocalPlayer.isRole(RoleType.BountyHunter)) { Vector3 offset = new Vector3(0f, 1f, 0f); setBountyIconPos(offset); } return PlayerControl.LocalPlayer.CanMove && numUsed < 1; }); } for (byte i = 0; i < 15; i++) { CustomButton lastImpostorButton = new CustomButton( // Action OnClick lastImpostorButtonOnClick(i), // bool HasButton lastImpostorHasButton(i), // bool CouldUse lastImpostorCouldUse(i), // Action OnMeetingEnds () => { }, // sprite null, // position Vector3.zero, // hudmanager hm, // keyboard shortcut null, KeyCode.None, true ); lastImpostorButton.Timer = 0.0f; lastImpostorButton.MaxTimer = 0.0f; lastImpostorButtons.Add(lastImpostorButton); } }
public static void Prefix(IntroCutscene __instance) { // Generate and initialize player icons if (PlayerControl.LocalPlayer != null && HudManager.Instance != null) { Vector3 bottomLeft = new Vector3(-HudManager.Instance.UseButton.transform.localPosition.x, HudManager.Instance.UseButton.transform.localPosition.y, HudManager.Instance.UseButton.transform.localPosition.z); foreach (PlayerControl p in PlayerControl.AllPlayerControls) { GameData.PlayerInfo data = p.Data; PoolablePlayer player = UnityEngine.Object.Instantiate <PoolablePlayer>(__instance.PlayerPrefab, HudManager.Instance.transform); player.UpdateFromPlayerOutfit(p.Data.DefaultOutfit, p.Data.IsDead); player.SetFlipX(true); player.PetSlot.gameObject.SetActive(false); player.NameText.text = p.Data.DefaultOutfit.PlayerName; MapOptions.playerIcons[p.PlayerId] = player; if (PlayerControl.LocalPlayer == BountyHunter.bountyHunter) { player.transform.localPosition = bottomLeft + new Vector3(-0.25f, 0f, 0); player.transform.localScale = Vector3.one * 0.4f; player.gameObject.SetActive(false); } else if (PlayerControl.LocalPlayer == GM.gm) { player.transform.localPosition = Vector3.zero; player.transform.localScale = Vector3.one * 0.3f; player.setSemiTransparent(false); player.gameObject.SetActive(false); } else { player.gameObject.SetActive(false); } } } // Force Bounty Hunter to load a new Bounty when the Intro is over if (BountyHunter.bounty != null && PlayerControl.LocalPlayer == BountyHunter.bountyHunter) { BountyHunter.bountyUpdateTimer = 0f; if (HudManager.Instance != null) { Vector3 bottomLeft = new Vector3(-HudManager.Instance.UseButton.transform.localPosition.x, HudManager.Instance.UseButton.transform.localPosition.y, HudManager.Instance.UseButton.transform.localPosition.z) + new Vector3(-0.25f, 1f, 0); BountyHunter.cooldownText = UnityEngine.Object.Instantiate <TMPro.TextMeshPro>(HudManager.Instance.KillButton.cooldownTimerText, HudManager.Instance.transform); BountyHunter.cooldownText.alignment = TMPro.TextAlignmentOptions.Center; BountyHunter.cooldownText.transform.localPosition = bottomLeft + new Vector3(0f, -1f, -1f); BountyHunter.cooldownText.gameObject.SetActive(true); } } Arsonist.updateIcons(); Morphling.resetMorph(); Camouflager.resetCamouflage(); if (PlayerControl.LocalPlayer == GM.gm && !GM.hasTasks) { PlayerControl.LocalPlayer.clearAllTasks(); } if (PlayerControl.LocalPlayer.isGM()) { HudManager.Instance.ShadowQuad.gameObject.SetActive(false); HudManager.Instance.ReportButton.gameObject.SetActiveRecursively(false); HudManager.Instance.ReportButton.SetActive(false); HudManager.Instance.ReportButton.graphic.enabled = false; HudManager.Instance.ReportButton.enabled = false; HudManager.Instance.ReportButton.graphic.sprite = null; HudManager.Instance.ReportButton.buttonLabelText.enabled = false; HudManager.Instance.ReportButton.buttonLabelText.SetText(""); HudManager.Instance.roomTracker.gameObject.SetActiveRecursively(false); HudManager.Instance.roomTracker.text.enabled = false; HudManager.Instance.roomTracker.text.SetText(""); HudManager.Instance.roomTracker.enabled = false; } // ベントを追加する AdditionalVents.AddAdditionalVents(); // スペシメンにバイタルを移動する SpecimenVital.moveVital(); //タスクバグ修正 if (PlayerControl.GameOptions.MapId == 4 && CustomOptionHolder.airshipEnableWallCheck.getBool()) { var objects = UnityEngine.GameObject.FindObjectsOfType <Console>().ToList(); objects.Find(x => x.name == "task_garbage1").checkWalls = true; objects.Find(x => x.name == "task_garbage2").checkWalls = true; objects.Find(x => x.name == "task_garbage3").checkWalls = true; objects.Find(x => x.name == "task_garbage4").checkWalls = true; objects.Find(x => x.name == "task_garbage5").checkWalls = true; objects.Find(x => x.name == "task_shower").checkWalls = true; objects.Find(x => x.name == "task_developphotos").checkWalls = true; objects.Find(x => x.name == "DivertRecieve" && x.Room == SystemTypes.Armory).checkWalls = true; objects.Find(x => x.name == "DivertRecieve" && x.Room == SystemTypes.MainHall).checkWalls = true; } // 最初から一人の場合はLast Impostorになる if (AmongUsClient.Instance.AmHost) { LastImpostor.promoteToLastImpostor(); } // タスクパネルの表示優先度を上げる var taskPanel = DestroyableSingleton <HudManager> ._instance.TaskStuff; var pos = taskPanel.transform.position; taskPanel.transform.position = new Vector3(pos.x, pos.y, -20); // ダミー人形をスポーンさせておく if (PlayerControl.LocalPlayer.isRole(RoleType.Puppeteer) && SubmergedCompatibility.isSubmerged()) { var playerId = (byte)GameData.Instance.GetAvailableId(); MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SpawnDummy, Hazel.SendOption.Reliable, -1); writer.Write(playerId); writer.Write(PlayerControl.LocalPlayer.transform.position.x); writer.Write(PlayerControl.LocalPlayer.transform.position.y); writer.Write(PlayerControl.LocalPlayer.transform.position.z); AmongUsClient.Instance.FinishRpcImmediately(writer); RPCProcedure.spawnDummy(playerId, PlayerControl.LocalPlayer.transform.position); } }