Beispiel #1
0
        public override void FixedUpdate()
        {
            if (player == PlayerControl.LocalPlayer)
            {
                currentTarget = setTarget();
                setPlayerOutline(currentTarget, BomberA.color);
                arrowUpdate();

                foreach (PoolablePlayer pp in MapOptions.playerIcons.Values)
                {
                    pp.gameObject.SetActive(false);
                }
                foreach (PoolablePlayer pp in playerIcons.Values)
                {
                    pp.gameObject.SetActive(false);
                }
                if (player.isAlive() && BomberA.isAlive())
                {
                    if (bombTarget != null && MapOptions.playerIcons.ContainsKey(bombTarget.PlayerId) && MapOptions.playerIcons[bombTarget.PlayerId].gameObject != null)
                    {
                        var     icon       = MapOptions.playerIcons[bombTarget.PlayerId];
                        Vector3 bottomLeft = new Vector3(-HudManager.Instance.UseButton.transform.localPosition.x, HudManager.Instance.UseButton.transform.localPosition.y, HudManager.Instance.UseButton.transform.localPosition.z);
                        icon.gameObject.SetActive(true);
                        icon.transform.localPosition = bottomLeft + new Vector3(-0.25f, 0f, 0);
                        icon.transform.localScale    = Vector3.one * 0.4f;
                        if (targetText == null)
                        {
                            targetText = GameObject.Instantiate(icon.NameText, icon.NameText.transform.parent);
                            targetText.enableWordWrapping       = false;
                            targetText.transform.localScale     = Vector3.one * 1.5f;
                            targetText.transform.localPosition += new Vector3(0f, 1.7f, 0);
                        }
                        targetText.text = ModTranslation.getString("bomberTarget");
                        targetText.gameObject.SetActive(true);
                        targetText.transform.parent = icon.gameObject.transform;
                    }
                    // 相方の設置したターゲットを表示する
                    if (BomberA.bombTarget != null && playerIcons.ContainsKey(BomberA.bombTarget.PlayerId) && playerIcons[BomberA.bombTarget.PlayerId].gameObject != null)
                    {
                        var     icon       = playerIcons[BomberA.bombTarget.PlayerId];
                        Vector3 bottomLeft = new Vector3(-HudManager.Instance.UseButton.transform.localPosition.x, HudManager.Instance.UseButton.transform.localPosition.y, HudManager.Instance.UseButton.transform.localPosition.z);
                        icon.gameObject.SetActive(true);
                        icon.transform.localPosition = bottomLeft + new Vector3(1.0f, 0f, 0);
                        icon.transform.localScale    = Vector3.one * 0.4f;
                        if (partnerTargetText == null)
                        {
                            partnerTargetText = GameObject.Instantiate(icon.NameText, icon.NameText.transform.parent);
                            partnerTargetText.enableWordWrapping       = false;
                            partnerTargetText.transform.localScale     = Vector3.one * 1.5f;
                            partnerTargetText.transform.localPosition += new Vector3(0f, 1.7f, 0);
                        }
                        partnerTargetText.text = ModTranslation.getString("bomberPartnerTarget");
                        partnerTargetText.gameObject.SetActive(true);
                        partnerTargetText.transform.parent = icon.gameObject.transform;
                    }
                }
            }
        }
Beispiel #2
0
        public static void MakeButtons(HudManager hm)
        {
            // Bomber button
            bomberButton = new CustomButton(
                // OnClick
                () =>
            {
                if (currentTarget != null)
                {
                    tmpTarget = currentTarget;
                    bomberButton.HasEffect = true;
                }
            },
                // HasButton
                () => { return(PlayerControl.LocalPlayer.isRole(RoleType.BomberB) && PlayerControl.LocalPlayer.isAlive() && BomberA.isAlive()); },
                // CouldUse
                () =>
            {
                if (bomberButton.isEffectActive && tmpTarget != currentTarget)
                {
                    tmpTarget                   = null;
                    bomberButton.Timer          = 0f;
                    bomberButton.isEffectActive = false;
                }

                return(PlayerControl.LocalPlayer.CanMove && currentTarget != null);
            },
                // OnMeetingEnds
                () =>
            {
                bomberButton.Timer          = bomberButton.MaxTimer;
                bomberButton.isEffectActive = false;
                tmpTarget = null;
            },
                getBomberButtonSprite(),
                new Vector3(-1.8f, -0.06f, 0),
                hm,
                hm.KillButton,
                KeyCode.F,
                true,
                duration,
                // OnEffectsEnd
                () =>
            {
                if (tmpTarget != null)
                {
                    MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlantBomb, Hazel.SendOption.Reliable, -1);
                    writer.Write(tmpTarget.PlayerId);
                    AmongUsClient.Instance.FinishRpcImmediately(writer);
                    BomberB.bombTarget = tmpTarget;
                }

                tmpTarget          = null;
                bomberButton.Timer = bomberButton.MaxTimer;
            }
                );
            bomberButton.buttonText = ModTranslation.getString("bomberPlantBomb");
            // Bomber button
            releaseButton = new CustomButton(
                // OnClick
                () =>
            {
                var bomberA    = BomberA.allPlayers.FirstOrDefault();
                float distance = Vector2.Distance(PlayerControl.LocalPlayer.transform.localPosition, bomberA.transform.localPosition);

                if (PlayerControl.LocalPlayer.CanMove && BomberA.bombTarget != null && BomberB.bombTarget != null && bomberA.isAlive() && distance < 1)
                {
                    var target           = BomberB.bombTarget;
                    MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ReleaseBomb, Hazel.SendOption.Reliable, -1);
                    writer.Write(PlayerControl.LocalPlayer.PlayerId);
                    writer.Write(target.PlayerId);
                    AmongUsClient.Instance.FinishRpcImmediately(writer);
                    RPCProcedure.releaseBomb(PlayerControl.LocalPlayer.PlayerId, target.PlayerId);
                }
            },
                // HasButton
                () => { return(PlayerControl.LocalPlayer.isRole(RoleType.BomberB) && PlayerControl.LocalPlayer.isAlive() && BomberA.isAlive()); },
                // CouldUse
                () =>
            {
                var bomberA    = BomberA.allPlayers.FirstOrDefault();
                float distance = Vector2.Distance(PlayerControl.LocalPlayer.transform.localPosition, bomberA.transform.localPosition);

                return(PlayerControl.LocalPlayer.CanMove && BomberA.bombTarget != null && BomberB.bombTarget != null && bomberA.isAlive() && distance < 1);
            },
                // OnMeetingEnds
                () =>
            {
                releaseButton.Timer = releaseButton.MaxTimer;
            },
                getReleaseButtonSprite(),
                new Vector3(-2.7f, -0.06f, 0),
                hm,
                hm.KillButton,
                KeyCode.F,
                false
                );
            releaseButton.buttonText = ModTranslation.getString("bomberDetonate");
        }