コード例 #1
0
        private void Update()
        {
            if (killButtonManager.transform.localPosition.x > 0f)
            {
                killButtonManager.transform.localPosition = new Vector3((killButtonManager.transform.localPosition.x + 1.3f) * -1, killButtonManager.transform.localPosition.y, killButtonManager.transform.localPosition.z) + new Vector3(PositionOffset.x, PositionOffset.y);
            }
            if (Timer < 0f)
            {
                killButtonManager.renderer.color = new Color(1f, 1f, 1f, 1f);
                if (isEffectActive)
                {
                    killButtonManager.TimerText.Color = startColorText;
                    Timer          = MaxTimer;
                    isEffectActive = false;
                    OnEffectEnd();
                }
            }
            else
            {
                if (canUse && (isEffectActive || PlayerControl.LocalPlayer.CanMove))
                {
                    Timer -= Time.deltaTime;
                }

                killButtonManager.renderer.color = new Color(1f, 1f, 1f, 0.3f);
            }
            killButtonManager.gameObject.SetActive(canUse);
            killButtonManager.renderer.enabled = canUse;
            if (canUse)
            {
                killButtonManager.renderer.material.SetFloat("_Desat", 0f);
                killButtonManager.SetCoolDown(Timer, MaxTimer);
            }
        }
コード例 #2
0
ファイル: HUDKill.cs プロジェクト: Anusien/Town-Of-Us
        private static void UpdateKillButton(HudManager __instance)
        {
            KillButton = __instance.KillButton;
            if (PlayerControl.AllPlayerControls.Count <= 1)
            {
                return;
            }
            if (PlayerControl.LocalPlayer == null)
            {
                return;
            }
            if (PlayerControl.LocalPlayer.Data == null)
            {
                return;
            }
            var flag8 = PlayerControl.LocalPlayer.Is(RoleEnum.Sheriff);

            if (flag8)
            {
                var role   = Role.GetRole <Sheriff>(PlayerControl.LocalPlayer);
                var isDead = PlayerControl.LocalPlayer.Data.IsDead;
                if (isDead)
                {
                    KillButton.gameObject.SetActive(false);
                    KillButton.isActive = false;
                }
                else
                {
                    KillButton.gameObject.SetActive(!MeetingHud.Instance);
                    KillButton.isActive = !MeetingHud.Instance;
                    KillButton.SetCoolDown(role.CooldownTimer(), CustomGameOptions.SheriffKillCd);

                    Utils.SetTarget(ref role.ClosestPlayer, KillButton);
                }
            }
            // TODO: Remove this?
            else
            {
                var isImpostor = PlayerControl.LocalPlayer.Data.IsImpostor;
                if (!isImpostor)
                {
                    return;
                }
                var isDead2 = PlayerControl.LocalPlayer.Data.IsDead;
                if (isDead2)
                {
                    KillButton.gameObject.SetActive(false);
                    KillButton.isActive = false;
                }
                else
                {
                    __instance.KillButton.gameObject.SetActive(!MeetingHud.Instance);
                    __instance.KillButton.isActive = !MeetingHud.Instance;
                }
            }
        }
コード例 #3
0
    private void Update()
    {
        if (PlayerControl.LocalPlayer.Data == null || MeetingHud.Instance || ExileController.Instance || !HasButton())
        {
            setActive(false);
            return;
        }
        setActive(hudManager.UseButton.isActiveAndEnabled);

        killButtonManager.renderer.sprite = Sprite;
        if (hudManager.UseButton != null)
        {
            Vector3 pos = hudManager.UseButton.transform.localPosition;
            if (mirror)
            {
                pos = new Vector3(-pos.x, pos.y, pos.z);
            }
            killButtonManager.transform.localPosition = pos + PositionOffset;
            if (hudManager.KillButton != null)
            {
                hudManager.KillButton.transform.localPosition = hudManager.UseButton.transform.localPosition - new Vector3(1.3f, 0, 0);                                // Align the kill button (because it's on another position depending on the screen resolution)
            }
        }
        if (CouldUse())
        {
            killButtonManager.renderer.color = Palette.EnabledColor;
            killButtonManager.renderer.material.SetFloat("_Desat", 0f);
        }
        else
        {
            killButtonManager.renderer.color = Palette.DisabledClear;
            killButtonManager.renderer.material.SetFloat("_Desat", 1f);
        }

        if (Timer >= 0)
        {
            if (HasEffect && isEffectActive)
            {
                Timer -= Time.deltaTime;
            }
            else if (!PlayerControl.LocalPlayer.inVent)
            {
                Timer -= Time.deltaTime;
            }
        }

        if (Timer <= 0 && HasEffect && isEffectActive)
        {
            isEffectActive = false;
            killButtonManager.TimerText.color = Palette.EnabledColor;
            OnEffectEnds();
        }

        killButtonManager.SetCoolDown(Timer, (HasEffect && isEffectActive) ? EffectDuration : MaxTimer);
    }
コード例 #4
0
        void OnStart()
        {
            buttonManager = GameObject.Instantiate(_hudManager.KillButton, _hudManager.transform);
            //buttonManager.gameObject.SetActive(true);
            // Set Sprite
            buttonManager.renderer.sprite = SpriteHelper.LoadSpriteFromEmbeddedResources(_embeddedResourcesImage, 600);
            buttonManager.SetCoolDown(timer, MaxTimer);
            Rest();

            buttonManager.transform.localPosition = new Vector3((buttonManager.transform.localPosition.x + 1.3f) * -1, buttonManager.transform.localPosition.y, buttonManager.transform.localPosition.z);
        }
コード例 #5
0
        private void Update()
        {
            if (!GameData.Instance || PlayerControl.LocalPlayer.Data == null)
            {
                return;
            }

            if (KillButtonManager.transform.localPosition.x > 0F)
            {
                Vector3 vector = KillButtonManager.transform.localPosition;
                vector.x = (vector.x + 1.3F) * -1;

                vector += new Vector3(PositionOffset.x, PositionOffset.y);

                KillButtonManager.transform.localPosition = vector;
            }

            if (Timer < 0F)
            {
                KillButtonManager.renderer.color = new Color(1f, 1f, 1f, 1f);

                if (IsEffectActive)
                {
                    KillButtonManager.TimerText.Color = StartColorText;

                    Timer = MaxTimer;

                    IsEffectActive = false;

                    OnEffectEnd();
                }
            }
            else
            {
                if (CanUse)
                {
                    Timer -= Time.deltaTime;
                }

                KillButtonManager.renderer.color = new Color(1f, 1f, 1f, 0.3f);
            }

            KillButtonManager.gameObject.SetActive(CanUse);
            KillButtonManager.renderer.enabled = CanUse;

            if (CanUse)
            {
                KillButtonManager.renderer.material.SetFloat("_Desat", 0f);

                KillButtonManager.SetCoolDown(Timer, MaxTimer);
            }
        }
コード例 #6
0
        private void Update()
        {
            KillButtonManager.transform.localPosition = _positionOffset;
            PassiveButton button = KillButtonManager.GetComponent <PassiveButton>();

            button.OnClick.RemoveAllListeners();
            button.OnClick.AddListener((UnityEngine.Events.UnityAction)listener);
            void listener()
            {
                if (Timer < 0f && _canUse && _enabled && HasTarget() && PlayerControl.LocalPlayer.CanMove)
                {
                    KillButtonManager.renderer.color = new Color(1f, 1f, 1f, 0.3f);
                    Timer = MaxTimer;
                    OnClick();
                }
            }

            KillButtonManager.renderer.sprite = Sprite;
            if (Timer < 0f)
            {
                if (_enabled && HasTarget() && PlayerControl.LocalPlayer.CanMove)
                {
                    KillButtonManager.renderer.color = new Color(1f, 1f, 1f, 1f);
                }
                else
                {
                    KillButtonManager.renderer.color = new Color(1f, 1f, 1f, .3f);
                }
            }
            else
            {
                if (_canUse && PlayerControl.LocalPlayer.CanMove)
                {
                    Timer -= Time.deltaTime;
                }
                KillButtonManager.renderer.color = new Color(1f, 1f, 1f, 0.3f);
                KillButtonManager.renderer.material.SetFloat("_Desat", 0f);
            }
            KillButtonManager.gameObject.SetActive(_canUse && MeetingHud.Instance == null);
            KillButtonManager.renderer.enabled = _canUse && MeetingHud.Instance == null;
            if (_canUse)
            {
                KillButtonManager.renderer.material.SetFloat("_Desat", 0f);
                KillButtonManager.SetCoolDown(Timer, MaxTimer);
            }
        }
コード例 #7
0
        public void CheckRepairButton(HudManager instance)
        {
            if (player == null || player.PlayerId != PlayerControl.LocalPlayer.PlayerId ||
                !instance.UseButton.isActiveAndEnabled || player.Data.IsDead)
            {
                return;
            }

            KillButtonManager killButton = instance.KillButton;

            killButton.gameObject.SetActive(true);
            killButton.isActive         = true;
            killButton.renderer.enabled = true;
            killButton.SetCoolDown(0f, 1f);
            killButton.renderer.sprite = _specialButton;
            killButton.renderer.color  = Palette.EnabledColor;
            killButton.renderer.material.SetFloat("_Desat", 0f);
        }
コード例 #8
0
    private void Update()
    {
        if (PlayerControl.LocalPlayer.Data == null || !HasButton())
        {
            setActive(false);
            return;
        }
        setActive(true);

        killButtonManager.renderer.sprite = Sprite;

        if (killButtonManager.transform.position == hudManager.KillButton.transform.position)
        {
            Vector3 vector = killButtonManager.transform.localPosition;
            vector += new Vector3(PositionOffset.x, PositionOffset.y);
            killButtonManager.transform.localPosition = vector;
        }


        if (CouldUse())
        {
            killButtonManager.renderer.color = Palette.EnabledColor;
            killButtonManager.renderer.material.SetFloat("_Desat", 0f);
        }
        else
        {
            killButtonManager.renderer.color = Palette.DisabledColor;
            killButtonManager.renderer.material.SetFloat("_Desat", 1f);
        }

        if (Timer >= 0)
        {
            Timer -= Time.deltaTime;
        }

        if (Timer <= 0 && HasEffect && isEffectActive)
        {
            isEffectActive = false;
            killButtonManager.TimerText.Color = Palette.EnabledColor;
            OnEffectEnds();
        }

        killButtonManager.SetCoolDown(Timer, (HasEffect && isEffectActive) ? EffectDuration : MaxTimer);
    }
コード例 #9
0
ファイル: HUDKill.cs プロジェクト: vaio2005/Town-Of-Us
        private static void UpdateKillButton(HudManager __instance)
        {
            KillButton = __instance.KillButton;
            if (PlayerControl.AllPlayerControls.Count <= 1)
            {
                return;
            }
            if (PlayerControl.LocalPlayer == null)
            {
                return;
            }
            if (PlayerControl.LocalPlayer.Data == null)
            {
                return;
            }
            var flag7 = PlayerControl.AllPlayerControls.Count > 1 & Utils.Sheriff != null;

            if (!flag7)
            {
                return;
            }
            var flag8 = PlayerControl.LocalPlayer.isSheriff();

            if (flag8)
            {
                var isDead = PlayerControl.LocalPlayer.Data.IsDead;
                if (isDead)
                {
                    KillButton.gameObject.SetActive(false);
                    KillButton.isActive = false;
                }
                else
                {
                    KillButton.gameObject.SetActive(true);
                    KillButton.isActive = true;
                    KillButton.SetCoolDown(Methods.SheriffKillTimer(), PlayerControl.GameOptions.KillCooldown + 15f);
                    Methods.ClosestPlayer = Methods.getClosestPlayer(PlayerControl.LocalPlayer);
                    var distBetweenPlayers = Methods.getDistBetweenPlayers(PlayerControl.LocalPlayer, Methods.ClosestPlayer);
                    var flag9 = distBetweenPlayers < GameOptionsData.KillDistances[PlayerControl.GameOptions.KillDistance];
                    if (flag9)
                    {
                        KillButton.SetTarget(Methods.ClosestPlayer);
                    }
                }
            }
            else
            {
                var isImpostor = PlayerControl.LocalPlayer.Data.IsImpostor;
                if (!isImpostor)
                {
                    return;
                }
                var isDead2 = PlayerControl.LocalPlayer.Data.IsDead;
                if (isDead2)
                {
                    KillButton.gameObject.SetActive(false);
                    KillButton.isActive = false;
                }
                else
                {
                    __instance.KillButton.gameObject.SetActive(true);
                    __instance.KillButton.isActive = true;
                }
            }
        }
コード例 #10
0
        private void Update()
        {
            if (KillButtonManager.transform.localPosition.x > 0f)
            {
                KillButtonManager.transform.localPosition = new Vector3((KillButtonManager.transform.localPosition.x + 1.3f) * -1, KillButtonManager.transform.localPosition.y, KillButtonManager.transform.localPosition.z) + new Vector3(PositionOffset.x, PositionOffset.y);
            }
            PassiveButton button = KillButtonManager.GetComponent <PassiveButton>();

            button.OnClick.RemoveAllListeners();
            button.OnClick.AddListener((UnityEngine.Events.UnityAction)listener);
            void listener()
            {
                if (Timer < 0f && CanUse_ && Enabled)
                {
                    KillButtonManager.renderer.color = new Color(1f, 1f, 1f, 0.3f);
                    if (HasEffectDuration)
                    {
                        IsEffectActive = true;
                        Timer          = EffectDuration;
                        KillButtonManager.TimerText.color = new Color(0, 255, 0);
                    }
                    else
                    {
                        Timer = MaxTimer;
                    }
                    OnClick();
                }
            }

            KillButtonManager.renderer.sprite = this.Sprite_;
            if (Timer < 0f)
            {
                if (Enabled)
                {
                    KillButtonManager.renderer.color = new Color(1f, 1f, 1f, 1f);
                }
                else
                {
                    KillButtonManager.renderer.color = new Color(1f, 1f, 1f, .3f);
                }
                if (IsEffectActive)
                {
                    KillButtonManager.TimerText.color = new Color(255, 255, 255);
                    Timer          = MaxTimer;
                    IsEffectActive = false;
                    OnEffectEnd();
                }
            }
            else
            {
                if (CanUse_ && (PlayerControl.LocalPlayer.CanMove || IsEffectActive))
                {
                    Timer -= Time.deltaTime;
                }
                KillButtonManager.renderer.color = new Color(1f, 1f, 1f, 0.3f);
            }
            KillButtonManager.gameObject.SetActive(CanUse_);
            KillButtonManager.renderer.enabled = CanUse_;
            if (CanUse_)
            {
                KillButtonManager.renderer.material.SetFloat("_Desat", 0f);
                KillButtonManager.SetCoolDown(Timer, MaxTimer);
            }
        }
コード例 #11
0
        private static void UpdateKillButton(HudManager __instance)
        {
            KillButton = __instance.KillButton;
            if (PlayerControl.AllPlayerControls.Count <= 1)
            {
                return;
            }
            if (PlayerControl.LocalPlayer == null)
            {
                return;
            }
            if (PlayerControl.LocalPlayer.Data == null)
            {
                return;
            }
            var flag7 = PlayerControl.AllPlayerControls.Count > 1;

            if (!flag7)
            {
                return;
            }
            var flag8 = PlayerControl.LocalPlayer.Is(RoleEnum.Sheriff);

            if (flag8)
            {
                var role   = Roles.Role.GetRole <Roles.Sheriff>(PlayerControl.LocalPlayer);
                var isDead = PlayerControl.LocalPlayer.Data.IsDead;
                if (isDead)
                {
                    KillButton.gameObject.SetActive(false);
                    KillButton.isActive = false;
                }
                else
                {
                    KillButton.gameObject.SetActive(!MeetingHud.Instance);
                    KillButton.isActive = !MeetingHud.Instance;
                    KillButton.SetCoolDown(role.SheriffKillTimer(), PlayerControl.GameOptions.KillCooldown + 15f);
                    role.ClosestPlayer = Utils.getClosestPlayer(PlayerControl.LocalPlayer);
                    var distBetweenPlayers = Utils.getDistBetweenPlayers(PlayerControl.LocalPlayer, role.ClosestPlayer);
                    var flag9 = distBetweenPlayers < GameOptionsData.KillDistances[PlayerControl.GameOptions.KillDistance];
                    if (flag9 && KillButton.enabled)
                    {
                        KillButton.SetTarget(role.ClosestPlayer);
                    }
                }
            }
            else
            {
                var isImpostor = PlayerControl.LocalPlayer.Data.IsImpostor;
                if (!isImpostor)
                {
                    return;
                }
                var isDead2 = PlayerControl.LocalPlayer.Data.IsDead;
                if (isDead2)
                {
                    KillButton.gameObject.SetActive(false);
                    KillButton.isActive = false;
                }
                else
                {
                    __instance.KillButton.gameObject.SetActive(!MeetingHud.Instance);
                    __instance.KillButton.isActive = !MeetingHud.Instance;
                }
            }
        }