public override void OnDeath(PlayerControl killer = null) { if (killer != null && infectKiller) { byte targetId = killer.PlayerId; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlagueDoctorSetInfected, Hazel.SendOption.Reliable, -1); writer.Write(targetId); AmongUsClient.Instance.FinishRpcImmediately(writer); RPCProcedure.plagueDoctorInfected(targetId); } }
public static void MakeButtons(HudManager hm) { plagueDoctorButton = new CustomButton( () => { /*ボタンが押されたとき*/ byte targetId = local.currentTarget.PlayerId; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlagueDoctorSetInfected, Hazel.SendOption.Reliable, -1); writer.Write(targetId); AmongUsClient.Instance.FinishRpcImmediately(writer); RPCProcedure.plagueDoctorInfected(targetId); local.numInfections--; plagueDoctorButton.Timer = plagueDoctorButton.MaxTimer; local.currentTarget = null; }, () => { /*ボタンが有効になる条件*/ return(PlayerControl.LocalPlayer.isRole(RoleType.PlagueDoctor) && local.numInfections > 0 && !PlayerControl.LocalPlayer.isDead()); }, () => {/*ボタンが使える条件*/ if (numInfectionsText != null) { if (local.numInfections > 0) { numInfectionsText.text = String.Format(ModTranslation.getString("plagueDoctorInfectionsLeft"), local.numInfections); } else { numInfectionsText.text = ""; } } return(local.currentTarget != null && local.numInfections > 0 && PlayerControl.LocalPlayer.CanMove); }, () => { /*ミーティング終了時*/ plagueDoctorButton.Timer = plagueDoctorButton.MaxTimer; }, getSyringeIcon(), new Vector3(-1.8f, -0.06f, 0), hm, hm.UseButton, KeyCode.F ); plagueDoctorButton.buttonText = ModTranslation.getString("plagueDoctorInfectButton"); numInfectionsText = GameObject.Instantiate(plagueDoctorButton.actionButton.cooldownTimerText, plagueDoctorButton.actionButton.cooldownTimerText.transform.parent); numInfectionsText.text = ""; numInfectionsText.enableWordWrapping = false; numInfectionsText.transform.localScale = Vector3.one * 0.5f; numInfectionsText.transform.localPosition += new Vector3(-0.05f, 0.7f, 0); }
public override void FixedUpdate() { if (player == PlayerControl.LocalPlayer) { if (numInfections > 0 && player.isAlive()) { currentTarget = setTarget(untargetablePlayers: infected.Values.ToList()); setPlayerOutline(currentTarget, PlagueDoctor.color); } if (!meetingFlag && (canWinDead || player.isAlive())) { List <PlayerControl> newInfected = new List <PlayerControl>(); foreach (PlayerControl target in PlayerControl.AllPlayerControls) { // 非感染プレイヤーのループ if (target == player || target.isDead() || infected.ContainsKey(target.PlayerId) || target.inVent) { continue; } // データが無い場合は作成する if (!progress.ContainsKey(target.PlayerId)) { progress[target.PlayerId] = 0f; } foreach (var source in infected.Values.ToList()) { // 感染プレイヤーのループ if (source.isDead()) { continue; } float distance = Vector3.Distance(source.transform.position, target.transform.position); // 障害物判定 bool anythingBetween = PhysicsHelpers.AnythingBetween(source.GetTruePosition(), target.GetTruePosition(), Constants.ShipAndObjectsMask, false); if (distance <= infectDistance && !anythingBetween) { progress[target.PlayerId] += Time.fixedDeltaTime; // 他のクライアントに進行状況を通知する MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlagueDoctorUpdateProgress, Hazel.SendOption.Reliable, -1); writer.Write(target.PlayerId); writer.Write(progress[target.PlayerId]); AmongUsClient.Instance.FinishRpcImmediately(writer); // Only update a player's infection once per FixedUpdate break; } } // 既定値を超えたら感染扱いにする if (progress[target.PlayerId] >= infectDuration) { newInfected.Add(target); } } // 感染者に追加する foreach (PlayerControl p in newInfected) { byte targetId = p.PlayerId; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlagueDoctorSetInfected, Hazel.SendOption.Reliable, -1); writer.Write(targetId); AmongUsClient.Instance.FinishRpcImmediately(writer); RPCProcedure.plagueDoctorInfected(targetId); } // 勝利条件を満たしたか確認する bool winFlag = true; foreach (PlayerControl p in PlayerControl.AllPlayerControls) { if (p.isDead()) { continue; } if (p == player) { continue; } if (!infected.ContainsKey(p.PlayerId)) { winFlag = false; break; } } if (winFlag) { MessageWriter winWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlagueDoctorWin, Hazel.SendOption.Reliable, -1); AmongUsClient.Instance.FinishRpcImmediately(winWriter); RPCProcedure.plagueDoctorWin(); } } } UpdateStatusText(); }