예제 #1
0
        public void AttemptBash()
        {
            if (!isOpen)
            {
                // Play bash sound if flagged and ready
                if (PlaySounds && BashSound > 0 && audioSource)
                {
                    DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>();
                    dfAudioSource.PlayOneShot(BashSound);
                }

                // Cannot bash magically held doors
                if (!IsMagicallyHeld)
                {
                    // Roll for chance to open
                    Random.seed = Time.frameCount;
                    float roll = Random.Range(0f, 1f);
                    if (roll >= (1f - ChanceToBash))
                    {
                        IsLocked = false;
                        ToggleDoor();
                    }
                }
            }
        }
        public void AttemptBash(bool byPlayer)
        {
            if (!IsOpen)
            {
                // Play bash sound if flagged and ready
                if (PlaySounds && BashSound > 0 && audioSource)
                {
                    DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>();
                    if (dfAudioSource != null)
                    {
                        dfAudioSource.PlayOneShot(BashSound);
                    }
                }

                // Cannot bash magically held doors
                if (!IsMagicallyHeld)
                {
                    // Roll for chance to open
                    int chance = 20 - CurrentLockValue;
                    if (Dice100.SuccessRoll(chance))
                    {
                        CurrentLockValue = 0;
                        ToggleDoor(true);
                    }
                }

                if (byPlayer && Game.GameManager.Instance.PlayerEnterExit.IsPlayerInsideDungeonCastle)
                {
                    Game.GameManager.Instance.MakeEnemiesHostile();
                }
            }
        }
        public void AttemptBash()
        {
            if (!IsOpen)
            {
                // Play bash sound if flagged and ready
                if (PlaySounds && BashSound > 0 && audioSource)
                {
                    DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>();
                    if (dfAudioSource != null)
                    {
                        dfAudioSource.PlayOneShot(BashSound);
                    }
                }

                // Cannot bash magically held doors
                if (!IsMagicallyHeld)
                {
                    // Roll for chance to open
                    UnityEngine.Random.InitState(Time.frameCount);
                    float roll = UnityEngine.Random.Range(0f, 1f);
                    if (roll >= (1f - ChanceToBash))
                    {
                        CurrentLockValue = 0;
                        ToggleDoor();
                    }
                }
            }
        }
예제 #4
0
        public void AttemptBash()
        {
            if (!IsOpen)
            {
                // Play bash sound if flagged and ready
                if (PlaySounds && BashSound > 0 && audioSource)
                {
                    DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>();
                    if (dfAudioSource != null)
                    {
                        dfAudioSource.PlayOneShot(BashSound);
                    }
                }

                // Cannot bash magically held doors
                if (!IsMagicallyHeld)
                {
                    PlayerEntity player = Game.GameManager.Instance.PlayerEntity;
                    player.TallySkill(DFCareer.Skills.Stealth, 1);
                    // Roll for chance to open
                    int chance = 20 - CurrentLockValue;
                    int roll   = UnityEngine.Random.Range(1, 101);
                    if (roll <= chance)
                    {
                        CurrentLockValue = 0;
                        ToggleDoor(true);
                    }
                }

                if (Game.GameManager.Instance.PlayerEnterExit.IsPlayerInsideDungeonCastle)
                {
                    Game.GameManager.Instance.MakeEnemiesHostile();
                }
            }
        }
예제 #5
0
        private void Open(float duration, bool ignoreLocks = false)
        {
            // Do nothing if door cannot be opened right now
            if ((IsLocked && !ignoreLocks) || IsOpen)
            {
                // Play open sound if flagged and ready
                if (PlaySounds && LockedSound > 0 && duration > 0 && audioSource)
                {
                    DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>();
                    if (dfAudioSource != null)
                    {
                        dfAudioSource.PlayOneShot(LockedSound);
                    }
                }

                //Just a temp. setup to provide feedback on locks until lockpicking is added
                if (!IsOpen)
                {
                    string lockedDoorMessage = "This door is locked";
                    if (IsMagicallyHeld)
                    {
                        lockedDoorMessage = "This is a magically held door";
                    }
                    DaggerfallWorkshop.Game.DaggerfallUI.Instance.PopupMessage(lockedDoorMessage);
                }
                return;
            }

            // Tween rotation
            Hashtable rotateParams = __ExternalAssets.iTween.Hash(
                "rotation", startingRotation.eulerAngles + new Vector3(0, OpenAngle, 0),
                "time", duration,
                "easetype", __ExternalAssets.iTween.EaseType.linear,
                "oncomplete", "OnCompleteOpen");

            __ExternalAssets.iTween.RotateTo(gameObject, rotateParams);
            currentState = ActionState.PlayingForward;

            // Set collider to trigger only
            MakeTrigger(true);

            // Play open sound if flagged and ready
            if (PlaySounds && OpenSound > 0 && duration > 0 && audioSource)
            {
                DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>();
                if (dfAudioSource != null)
                {
                    dfAudioSource.PlayOneShot(OpenSound);
                }
            }

            //For Doors that are also action objects, executes action when door opened / closed
            ExecuteActionOnToggle();

            // Set flag
            //IsMagicallyHeld = false;
            CurrentLockValue = 0;
        }
예제 #6
0
        public void AttemptLockpicking()
        {
            if (IsMoving)
            {
                return;
            }

            PlayerEntity player = Game.GameManager.Instance.PlayerEntity;

            // If player fails at their current lockpicking skill level, they can't try again
            if (FailedSkillLevel == player.Skills.GetLiveSkillValue(DFCareer.Skills.Lockpicking))
            {
                return;
            }

            if (!IsMagicallyHeld)
            {
                int chance = 0;
                int lockpickSuccessCheck = 0;
                chance = FormulaHelper.CalculateInteriorLockpickingChance(player.Level, CurrentLockValue, player.Skills.GetLiveSkillValue(DFCareer.Skills.Lockpicking));

                if (Dice100.FailedRoll(chance))
                {
                    player.TallySkill(DFCareer.Skills.Lockpicking, 1, lockpickSuccessCheck);

                    Game.DaggerfallUI.Instance.PopupMessage(TextManager.Instance.GetLocalizedText("lockpickingFailure"));
                    FailedSkillLevel = player.Skills.GetLiveSkillValue(DFCareer.Skills.Lockpicking);
                }
                else
                {
                    lockpickSuccessCheck = 1;
                    player.TallySkill(DFCareer.Skills.Lockpicking, 1, lockpickSuccessCheck, CurrentLockValue);

                    Game.DaggerfallUI.Instance.PopupMessage(TextManager.Instance.GetLocalizedText("lockpickingSuccess"));
                    CurrentLockValue = 0;

                    if (PlaySounds && PickedLockSound > 0 && audioSource)
                    {
                        DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>();
                        if (dfAudioSource != null)
                        {
                            dfAudioSource.PlayOneShot(PickedLockSound);
                        }
                    }
                    ToggleDoor(true);
                }
            }
            else
            {
                Game.DaggerfallUI.Instance.PopupMessage(TextManager.Instance.GetLocalizedText("lockpickingFailure"));
            }
        }
        private void Open(float duration, bool ignoreLocks = false)
        {
            // Do nothing if door cannot be opened right now
            if ((IsLocked && !ignoreLocks) || IsOpen)
            {
                if (!IsOpen)
                {
                    LookAtLock();
                }
                return;
            }

            //// Tween rotation
            //Hashtable rotateParams = __ExternalAssets.iTween.Hash(
            //    "rotation", startingRotation.eulerAngles + new Vector3(0, OpenAngle, 0),
            //    "time", duration,
            //    "easetype", __ExternalAssets.iTween.EaseType.linear,
            //    "oncomplete", "OnCompleteOpen");
            //__ExternalAssets.iTween.RotateTo(gameObject, rotateParams);
            //currentState = ActionState.PlayingForward;

            // Tween rotation
            Hashtable rotateParams = __ExternalAssets.iTween.Hash(
                "amount", new Vector3(0f, OpenAngle / 360f, 0f),
                "space", Space.Self,
                "time", duration,
                "easetype", __ExternalAssets.iTween.EaseType.linear,
                "oncomplete", "OnCompleteOpen");

            __ExternalAssets.iTween.RotateBy(gameObject, rotateParams);
            currentState = ActionState.PlayingForward;

            // Set collider to trigger only
            MakeTrigger(true);

            // Play open sound if flagged and ready
            if (PlaySounds && OpenSound > 0 && duration > 0 && audioSource)
            {
                DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>();
                if (dfAudioSource != null)
                {
                    dfAudioSource.PlayOneShot(OpenSound);
                }
            }

            //For Doors that are also action objects, executes action when door opened / closed
            ExecuteActionOnToggle();

            // Set flag
            //IsMagicallyHeld = false;
            CurrentLockValue = 0;
        }
        private void OnCompleteClose(float duration)
        {
            // Play close sound if flagged and ready
            if (PlaySounds && CloseSound > 0 && duration > 0 && audioSource)
            {
                DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>();
                dfAudioSource.PlayOneShot(CloseSound);
            }

            // Set collider back to a solid object
            MakeTrigger(false);

            currentState = ActionState.Start;
        }
예제 #9
0
        public void AttemptBash(bool byPlayer, PlayerEntity player = null, EnemyEntity enemy = null)
        {
            // Play bash sound if flagged and ready
            if (PlaySounds && BashSound > 0 && audioSource)
            {
                DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>();
                if (dfAudioSource != null)
                {
                    dfAudioSource.PlayOneShot(BashSound);
                }
            }

            if (IsOpen)
            {
                // Bash-close the door
                ToggleDoor(true);
            }
            // Cannot bash magically held doors
            else if (!IsMagicallyHeld)
            {
                int chance = 0;

                if (player != null)
                {
                    chance = Mathf.Clamp(15 + (int)Mathf.Ceil((player.Stats.LiveStrength - 50) / 2.5f) - CurrentLockValue, 1, 100);
                }
                else if (enemy != null)
                {
                    chance = Mathf.Clamp(15 + (int)Mathf.Ceil((enemy.Stats.LiveStrength - 50) / 2.5f) - CurrentLockValue, 1, 100);
                }
                else
                {
                    chance = 20 - CurrentLockValue;
                }

                // Roll for chance to open
                if (Dice100.SuccessRoll(chance))
                {
                    CurrentLockValue = 0;
                    ToggleDoor(true);
                }
            }

            if (byPlayer && Game.GameManager.Instance.PlayerEnterExit.IsPlayerInsideDungeonCastle)
            {
                Game.GameManager.Instance.MakeEnemiesHostile();
            }
        }
예제 #10
0
        private void Open(float duration, bool ignoreLocks = false)
        {
            // Do nothing if door cannot be opened right now
            if (((IsLocked || IsMagicallyHeld) && !ignoreLocks) || isOpen || isMoving)
            {
                // Play open sound if flagged and ready
                if (PlaySounds && LockedSound > 0 && duration > 0 && audioSource)
                {
                    DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>();
                    if (dfAudioSource != null)
                    {
                        dfAudioSource.PlayOneShot(LockedSound);
                    }
                }

                return;
            }

            // Tween rotation
            Hashtable rotateParams = __ExternalAssets.iTween.Hash(
                "amount", new Vector3(0f, OpenAngle / 360f, 0f),
                "space", Space.Self,
                "time", duration,
                "easetype", __ExternalAssets.iTween.EaseType.linear,
                "oncomplete", "OnCompleteOpen");

            __ExternalAssets.iTween.RotateBy(gameObject, rotateParams);
            isMoving = true;

            // Set collider to trigger only
            if (IsTriggerWhenOpen && boxCollider != null)
            {
                boxCollider.isTrigger = true;
            }

            // Play open sound if flagged and ready
            if (PlaySounds && OpenSound > 0 && duration > 0 && audioSource)
            {
                DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>();
                if (dfAudioSource != null)
                {
                    dfAudioSource.PlayOneShot(OpenSound);
                }
            }

            // Set flag
            isOpen = true;
        }
예제 #11
0
        public void AttemptLockpicking()
        {
            if (IsMoving)
            {
                return;
            }

            PlayerEntity player = Game.GameManager.Instance.PlayerEntity;

            // If player fails at their current lockpicking skill level, they can't try again
            if (FailedSkillLevel == player.Skills.Lockpicking)
            {
                return;
            }

            if (!IsMagicallyHeld)
            {
                int chance = 0;
                player.TallySkill(DFCareer.Skills.Lockpicking, 1);
                chance = FormulaHelper.CalculateInteriorLockpickingChance(player.Level, CurrentLockValue, player.Skills.Lockpicking);

                if (Random.Range(0, 101) > chance)
                {
                    Game.DaggerfallUI.Instance.PopupMessage(HardStrings.lockpickingFailure);
                    FailedSkillLevel = player.Skills.Lockpicking;
                }
                else
                {
                    Game.DaggerfallUI.Instance.PopupMessage(HardStrings.lockpickingSuccess);
                    CurrentLockValue = 0;

                    if (PlaySounds && PickedLockSound > 0 && audioSource)
                    {
                        DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>();
                        if (dfAudioSource != null)
                        {
                            dfAudioSource.PlayOneShot(PickedLockSound);
                        }
                    }
                    ToggleDoor(true);
                }
            }
            else
            {
                Game.DaggerfallUI.Instance.PopupMessage(HardStrings.lockpickingFailure);
            }
        }
예제 #12
0
        private void OnCompleteClose(float duration)
        {
            isMoving = false;

            // Play close sound if flagged and ready
            if (PlaySounds && CloseSound > 0 && duration > 0 && audioSource)
            {
                DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>();
                dfAudioSource.PlayOneShot(CloseSound);
            }

            // Set collider back to a solid object
            if (DisableColliderWhenOpen && meshCollider)
            {
                meshCollider.isTrigger = false;
            }
        }
예제 #13
0
        private void Open(float duration, bool ignoreLocks = false)
        {
            // Do nothing if door cannot be opened right now
            if (((IsLocked || IsMagicallyHeld) && !ignoreLocks) || IsOpen)
            {
                // Play open sound if flagged and ready
                if (PlaySounds && LockedSound > 0 && duration > 0 && audioSource)
                {
                    DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>();
                    if (dfAudioSource != null)
                    {
                        dfAudioSource.PlayOneShot(LockedSound);
                    }
                }

                return;
            }

            // Tween rotation
            Hashtable rotateParams = __ExternalAssets.iTween.Hash(
                "rotation", startingRotation.eulerAngles + new Vector3(0, OpenAngle, 0),
                "time", duration,
                "easetype", __ExternalAssets.iTween.EaseType.linear,
                "oncomplete", "OnCompleteOpen");

            __ExternalAssets.iTween.RotateTo(gameObject, rotateParams);
            currentState = ActionState.PlayingForward;

            // Set collider to trigger only
            MakeTrigger(true);

            // Play open sound if flagged and ready
            if (PlaySounds && OpenSound > 0 && duration > 0 && audioSource)
            {
                DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>();
                if (dfAudioSource != null)
                {
                    dfAudioSource.PlayOneShot(OpenSound);
                }
            }

            // Set flag
            IsMagicallyHeld  = false;
            CurrentLockValue = 0;
        }
        public void AttemptLockpicking()
        {
            int chance = 0;

            if (IsMoving)
            {
                return;
            }

            if (!IsOpen && IsLocked)
            {
                if (!IsMagicallyHeld)
                {
                    PlayerEntity player = Game.GameManager.Instance.PlayerEntity;
                    player.TallySkill((short)Skills.Lockpicking, 1);
                    chance = FormulaHelper.CalculateInteriorLockpickingChance(player.Level, CurrentLockValue, player.Skills.Lockpicking);

                    if (Random.Range(0, 101) > chance)
                    {
                        Game.DaggerfallUI.Instance.PopupMessage(HardStrings.lockpickingFailure);
                    }
                    else
                    {
                        Game.DaggerfallUI.Instance.PopupMessage(HardStrings.lockpickingSuccess);
                        CurrentLockValue = 0;

                        if (PlaySounds && PickedLockSound > 0 && audioSource)
                        {
                            DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>();
                            if (dfAudioSource != null)
                            {
                                dfAudioSource.PlayOneShot(PickedLockSound);
                            }
                        }

                        ToggleDoor();
                    }
                    LockPickingAttempted = true;
                }
                else
                {
                    Game.DaggerfallUI.Instance.PopupMessage(HardStrings.lockpickingFailure);
                }
            }
        }
        private void Open(float duration, bool ignoreLocks = false, bool activatedByPlayer = false)
        {
            //// Tween rotation
            //Hashtable rotateParams = __ExternalAssets.iTween.Hash(
            //    "rotation", startingRotation.eulerAngles + new Vector3(0, OpenAngle, 0),
            //    "time", duration,
            //    "easetype", __ExternalAssets.iTween.EaseType.linear,
            //    "oncomplete", "OnCompleteOpen");
            //__ExternalAssets.iTween.RotateTo(gameObject, rotateParams);
            //currentState = ActionState.PlayingForward;

            // Tween rotation
            Hashtable rotateParams = __ExternalAssets.iTween.Hash(
                "amount", new Vector3(0f, OpenAngle / 360f, 0f),
                "space", Space.Self,
                "time", duration,
                "easetype", __ExternalAssets.iTween.EaseType.linear,
                "oncomplete", "OnCompleteOpen");

            __ExternalAssets.iTween.RotateBy(gameObject, rotateParams);
            currentState = ActionState.PlayingForward;

            // Set collider to trigger only
            MakeTrigger(true);

            // Play open sound if flagged and ready
            if (PlaySounds && OpenSound > 0 && duration > 0 && audioSource)
            {
                DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>();
                if (dfAudioSource != null)
                {
                    dfAudioSource.PlayOneShot(OpenSound);
                }
            }

            // For doors that are also action objects, execute action when door opened / closed
            // Only doing so if player was the activator, to keep DoorText actions from running
            // when enemies open doors.
            if (activatedByPlayer)
            {
                ExecuteActionOnToggle();
            }
        }
        private void Open(float duration, bool ignoreLocks = false, bool activatedByPlayer = false, float scale = 1)
        {
            // Handle DoorText actions. On first activation, show the text but don't try to open the door.
            DaggerfallAction action = GetComponent <DaggerfallAction>();

            if (action != null &&
                action.ActionFlag == DFBlock.RdbActionFlags.DoorText &&
                (action.TriggerFlag == DFBlock.RdbTriggerFlags.Door || action.TriggerFlag == DFBlock.RdbTriggerFlags.Direct) && // Door to Mynisera's room has a "Direct" trigger flag
                action.activationCount == 0 &&
                activatedByPlayer)
            {
                ExecuteActionOnToggle();
                if (!action.ActionEnabled) // ActionEnabled will still be false if there was valid text to display. In that case, don't open the door for this first activation.
                {
                    return;
                }
            }

            // Do nothing if door cannot be opened right now
            if ((IsLocked && !ignoreLocks) || IsOpen)
            {
                if (!IsOpen)
                {
                    PlayerActivate.LookAtInteriorLock(CurrentLockValue);
                }
                return;
            }

            if (activatedByPlayer)
            {
                ExecuteActionOnToggle();
            }

            // Tween rotation
            Hashtable rotateParams = __ExternalAssets.iTween.Hash(
                "amount", new Vector3(0f, OpenAngle * scale / 360f, 0f),
                "space", Space.Self,
                "time", duration * scale,
                "easetype", __ExternalAssets.iTween.EaseType.linear,
                "oncomplete", "OnCompleteOpen");

            __ExternalAssets.iTween.RotateBy(gameObject, rotateParams);

            // Set collider to trigger only
            MakeTrigger(true);

            // Play open sound if flagged and ready
            if (PlaySounds && OpenSound > 0 && duration * scale > 0 && audioSource &&
                currentState != ActionState.PlayingForward)
            {
                DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>();
                if (dfAudioSource != null)
                {
                    dfAudioSource.PlayOneShot(OpenSound);
                }
            }

            currentState = ActionState.PlayingForward;

            // Set flag
            //IsMagicallyHeld = false;
            CurrentLockValue = 0;
        }