Ejemplo n.º 1
0
        void Update()
        {
            // Unable to attack if paralyzed
            if (entityBehaviour.Entity.IsParalyzed)
            {
                return;
            }

            // If a melee attack has reached the damage frame we can run a melee attempt
            if (mobile.DoMeleeDamage)
            {
                MeleeDamage();
                mobile.DoMeleeDamage = false;
            }
            // If a bow attack has reached the shoot frame we can shoot an arrow
            else if (mobile.ShootArrow)
            {
                ShootBow();
                mobile.ShootArrow = false;

                DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>();
                if (dfAudioSource)
                {
                    dfAudioSource.PlayOneShot((int)SoundClips.ArrowShoot, 1, 1.0f);
                }
            }
        }
Ejemplo n.º 2
0
        void Awake()
        {
            // Save references
            dfAudioSource = GetComponent <DaggerfallAudioSource>();
            player        = GameObject.FindGameObjectWithTag("Player");
            mobile        = GetComponentInChildren <DaggerfallMobileUnit>();

            // Setup audio source
            dfAudioSource.AudioSource.maxDistance = AttractRadius;
            if (LinearRolloff)
            {
                dfAudioSource.AudioSource.rolloffMode = AudioRolloffMode.Linear;
            }
            dfAudioSource.AudioSource.spatialBlend = 1;

            // Assign sounds from mobile
            if (SoundsFromMobile && mobile)
            {
                MoveSound   = (SoundClips)mobile.Summary.Enemy.MoveSound;
                BarkSound   = (SoundClips)mobile.Summary.Enemy.BarkSound;
                AttackSound = (SoundClips)mobile.Summary.Enemy.AttackSound;
            }

            RaceForSounds = (Entity.Races)Random.Range(1, 5 + 1);

            // Start attract timer
            StartWaiting();
        }
        void ClickHandler(BaseScreenComponent sender, Vector2 position)
        {
            int offset = (int)position.y * racePickerBitmap.Width + (int)position.x;

            if (offset < 0 || offset >= racePickerBitmap.Data.Length)
            {
                return;
            }

            int id = racePickerBitmap.Data[offset];

            if (raceDict.ContainsKey(id))
            {
                promptLabel.Enabled = false;
                selectedRace        = raceDict[id];

                TextFile.Token[]     textTokens = DaggerfallUnity.Instance.TextProvider.GetRSCTokens(selectedRace.DescriptionID);
                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this);
                messageBox.SetTextTokens(textTokens);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                Button noButton = messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
                noButton.ClickSound       = DaggerfallUI.Instance.GetAudioClip(SoundClips.ButtonClick);
                messageBox.OnButtonClick += ConfirmRacePopup_OnButtonClick;
                messageBox.OnCancel      += ConfirmRacePopup_OnCancel;
                uiManager.PushWindow(messageBox);

                DaggerfallAudioSource source = DaggerfallUI.Instance.GetComponent <DaggerfallAudioSource>();
                source.PlayOneShot((uint)selectedRace.ClipID);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Update is called by owning task once per frame as part of quest machine tick.
        /// Update is only called by task if active conditions are met.
        /// Perform any updates required here.
        /// </summary>
        /// <param name="caller">Task hosting this action.</param>
        public override void Update(Task caller)
        {
            var gameSeconds = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToSeconds();

            // Attempt to reload clip if not available
            // This can happen if player loads a game after action created
            if (clip == null && soundIndex != 0)
            {
                clip = DaggerfallUnity.Instance.SoundReader.GetAudioClip(soundIndex);
            }

            if (lastTimePlayed + interval <= gameSeconds)
            {
                timesPlayed++;
                if (count == 0 || (count > 0 && timesPlayed <= count))
                {
                    DaggerfallAudioSource source = QuestMachine.Instance.GetComponent <DaggerfallAudioSource>();
                    if (source != null && !source.IsPlaying())
                    {
                        source.PlayOneShot(soundIndex, 0, DaggerfallUnity.Settings.SoundVolume);
                        lastTimePlayed = gameSeconds;
                    }
                }
            }
            // Unlike message posts, the play sound command performs until task is cleared
            // The exception are sounds played X times, these will stop and start again on load or action rearming
        }
Ejemplo n.º 5
0
        void Awake()
        {
            dfUnity     = DaggerfallUnity.Instance;
            audioSource = GetComponent <AudioSource>();
            audioSource.spatialBlend = 0;
            dfAudioSource            = GetComponent <DaggerfallAudioSource>();
            dfSongPlayer             = GetComponent <DaggerfallSongPlayer>();

            dfPauseOptionsWindow       = new DaggerfallPauseOptionsWindow(uiManager);
            dfCharacterSheetWindow     = new DaggerfallCharacterSheetWindow(uiManager);
            dfInventoryWindow          = new DaggerfallInventoryWindow(uiManager);
            dfControlsWindow           = new DaggerfallControlsWindow(uiManager);
            dfJoystickControlsWindow   = new DaggerfallJoystickControlsWindow(uiManager);
            dfUnityMouseControlsWindow = new DaggerfallUnityMouseControlsWindow(uiManager);
            dfTravelMapWindow          = new DaggerfallTravelMapWindow(uiManager);
            dfAutomapWindow            = new DaggerfallAutomapWindow(uiManager);
            dfBookReaderWindow         = new DaggerfallBookReaderWindow(uiManager);
            dfQuestJournalWindow       = new DaggerfallQuestJournalWindow(uiManager);
            dfTalkWindow       = new DaggerfallTalkWindow(uiManager);
            dfSpellBookWindow  = new DaggerfallSpellBookWindow(uiManager);
            dfSpellMakerWindow = new DaggerfallSpellMakerWindow(uiManager);
            dfCourtWindow      = new DaggerfallCourtWindow(uiManager);

            dfExteriorAutomapWindow = new DaggerfallExteriorAutomapWindow(uiManager);

            dfQuestInspector = new QuestMachineInspectorWindow(uiManager);

            Questing.Actions.GivePc.OnOfferPending += GivePc_OnOfferPending;

            SetupSingleton();
        }
Ejemplo n.º 6
0
        protected virtual void Start()
        {
            // Store references
            dfUnity          = DaggerfallUnity.Instance;
            dfAudioSource    = GetComponent <DaggerfallAudioSource>();
            playerEnterExit  = GetComponent <PlayerEnterExit>();
            transportManager = GetComponent <TransportManager>();
            entityBehaviour  = GetComponent <DaggerfallEntityBehaviour>();

            GameObject audioSourceObject = new GameObject("Footsteps Source");

            audioSourceObject.transform.SetParent(transform);
            audioSourceObject.transform.localPosition = Vector3.zero;

            customAudioSource              = audioSourceObject.AddComponent <AudioSource>();
            customAudioSource.playOnAwake  = false;
            customAudioSource.loop         = false;
            customAudioSource.dopplerLevel = 0f;
            customAudioSource.spatialBlend = 1;

            // Set start position
            lastPosition = GetHorizontalPosition();

            // Set starting footsteps
            currentFootstepSoundList = FootstepSoundDungeon;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Setup Advanced Settings Panel
        /// </summary>
        protected override void Setup()
        {
            AllowCancel = false;
            ParentPanel.BackgroundColor = Color.clear;

            gameObject      = new GameObject();
            gameObject.name = "DaggerfallAdvancedSettingsWindow";
            gameObject.AddComponent <AudioSource>();
            dfAudioSource = gameObject.AddComponent <DaggerfallAudioSource>();

            // Pages selection top bar
            bar.Outline.Enabled     = true;
            bar.BackgroundColor     = backgroundColor;
            bar.HorizontalAlignment = HorizontalAlignment.Center;
            bar.Position            = new Vector2(0, topY);
            bar.Size = topBarSize;
            NativePanel.Components.Add(bar);

            // Setup pages
            LoadSettings();

            // Add Close button
            Button closeButton = new Button();

            closeButton.Size = new Vector2(25, 9);
            closeButton.HorizontalAlignment = HorizontalAlignment.Center;
            closeButton.VerticalAlignment   = VerticalAlignment.Bottom;
            closeButton.BackgroundColor     = closeButtonColor;
            closeButton.Outline.Enabled     = true;
            closeButton.Label.Text          = closeButtonText;
            closeButton.OnMouseClick       += CloseButton_OnMouseClick;
            closeButton.Hotkey = DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.GameSetupClose);
            NativePanel.Components.Add(closeButton);
        }
Ejemplo n.º 8
0
        void Update()
        {
            // Handle state in progress before hit frame
            if (mobile.IsPlayingOneShot())
            {
                if (mobile.LastFrameAnimated < mobile.Summary.Enemy.HitFrame &&
                    mobile.Summary.EnemyState == MobileStates.PrimaryAttack)
                {
                    // Are we melee attacking?
                    if (mobile.IsAttacking())
                    {
                        isMeleeAttackingPreHitFrame = true;
                    }

                    return;
                }
                else if (mobile.LastFrameAnimated < 2 && // TODO: Animate bow correctly
                         (mobile.Summary.EnemyState == MobileStates.RangedAttack1 ||
                          mobile.Summary.EnemyState == MobileStates.RangedAttack2))
                {
                    // Are we shooting bow?
                    if (mobile.IsAttacking())
                    {
                        isShootingPreHitFrame = true;
                    }

                    return;
                }
            }

            // If a melee attack has reached the hit frame we can apply damage
            if (isMeleeAttackingPreHitFrame && mobile.LastFrameAnimated == mobile.Summary.Enemy.HitFrame)
            {
                MeleeDamage();
                isMeleeAttackingPreHitFrame = false;
            }
            // Same for shooting bow
            else if (isShootingPreHitFrame && mobile.LastFrameAnimated == 2) // TODO: Animate bow correctly
            {
                BowDamage();
                isShootingPreHitFrame = false;

                DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>();
                if (dfAudioSource)
                {
                    dfAudioSource.PlayOneShot((int)SoundClips.ArrowShoot, 1, 1.0f);
                }
            }

            // Countdown to next melee attack
            meleeTimer -= Time.deltaTime;
            if (meleeTimer < 0)
            {
                MeleeAnimation();
                meleeTimer = MeleeAttackSpeed;
                // Randomize
                meleeTimer += Random.Range(-.50f, .50f);
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Adds action audio.
 /// </summary>
 private static void AddActionAudioSource(GameObject go, uint id)
 {
     if (id > 0)
     {
         DaggerfallAudioSource c = go.AddComponent <DaggerfallAudioSource>();
         c.SetSound(id);
     }
 }
 void Start()
 {
     random               = new System.Random(System.DateTime.Now.Millisecond);
     dfAudioSource        = GetComponent <DaggerfallAudioSource>();
     dfAudioSource.Preset = AudioPresets.OnDemand;
     ApplyPresets();
     StartWaiting();
 }
Ejemplo n.º 11
0
        void Update()
        {
            // If a melee attack has reached the damage frame we can run a melee attempt
            if (mobile.DoMeleeDamage)
            {
                MeleeDamage();
                mobile.DoMeleeDamage = false;
            }
            // If a bow attack has reached the shoot frame we can shoot an arrow
            else if (mobile.ShootArrow)
            {
                BowDamage(); // TODO: Shoot 3D projectile instead of doing an instant hit
                mobile.ShootArrow = false;

                DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>();
                if (dfAudioSource)
                {
                    dfAudioSource.PlayOneShot((int)SoundClips.ArrowShoot, 1, 1.0f);
                }
            }

            // Countdown to next melee attack
            meleeTimer -= Time.deltaTime;

            if (meleeTimer < 0)
            {
                meleeTimer = 0;
            }

            EnemyEntity entity = entityBehaviour.Entity as EnemyEntity;
            int         speed  = entity.Stats.LiveSpeed;

            // Note: Speed comparison here is reversed from classic. Classic's way makes fewer attack
            // attempts at higher speeds, so it seems backwards.
            if (classicUpdate && (DFRandom.rand() % speed >= (speed >> 3) + 6 && meleeTimer == 0))
            {
                MeleeAnimation();

                meleeTimer  = Random.Range(1500, 3001);
                meleeTimer -= 50 * (GameManager.Instance.PlayerEntity.Level - 10);

                // Note: In classic, what happens here is
                // meleeTimer += 450 * (enemydata[130] - 2);
                // Apparently this was meant to reference the game reflexes setting,
                // which is stored in playerentitydata[130].
                // Instead enemydata[130] seems to instead always be 0, the equivalent of
                // "very high" reflexes, regardless of what the game reflexes are.
                // Here, we use the reflexes data as was intended.
                meleeTimer += 450 * ((int)GameManager.Instance.PlayerEntity.Reflexes - 2);

                if (meleeTimer > 100000 || meleeTimer < 0)
                {
                    meleeTimer = 1500;
                }

                meleeTimer /= 980; // Approximates classic frame update
            }
        }
Ejemplo n.º 12
0
        private static void AddHorseAudioSource(GameObject go)
        {
            DaggerfallAudioSource c = go.AddComponent <DaggerfallAudioSource>();

            c.AudioSource.dopplerLevel = 0;
            c.AudioSource.rolloffMode  = AudioRolloffMode.Linear;
            c.AudioSource.maxDistance  = 5f;
            c.AudioSource.volume       = 0.7f;
            c.SetSound(SoundClips.AnimalHorse, AudioPresets.PlayRandomlyIfPlayerNear);
        }
Ejemplo n.º 13
0
        private static void AddTorchAudioSource(GameObject go)
        {
            DaggerfallAudioSource c = go.AddComponent <DaggerfallAudioSource>();

            c.AudioSource.dopplerLevel = 0;
            c.AudioSource.rolloffMode  = AudioRolloffMode.Linear;
            c.AudioSource.maxDistance  = 5f;
            c.AudioSource.volume       = 0.7f;
            c.SetSound(SoundClips.Burning, AudioPresets.LoopIfPlayerNear);
        }
 void Start()
 {
     random               = new System.Random(System.DateTime.Now.Millisecond);
     dfAudioSource        = GetComponent <DaggerfallAudioSource>();
     dfAudioSource.Preset = AudioPresets.OnDemand;
     ApplyPresets();
     StartWaiting();
     playerBehaviour = GameManager.Instance.PlayerEntityBehaviour;
     playerEnterExit = GameManager.Instance.PlayerEnterExit;
 }
Ejemplo n.º 15
0
        private void MeleeDamage()
        {
            if (entityBehaviour)
            {
                EnemyEntity entity = entityBehaviour.Entity as EnemyEntity;
                MobileEnemy enemy  = entity.MobileEnemy;

                int damage = 0;

                // Are we still in range and facing player? Then apply melee damage.
                if (senses.DistanceToPlayer < MeleeDistance && senses.PlayerInSight)
                {
                    // Calculate damage
                    damage = Game.Formulas.FormulaHelper.CalculateWeaponDamage(entity, GameManager.Instance.PlayerEntity, null);
                    if (damage > 0)
                    {
                        GameManager.Instance.PlayerObject.SendMessage("RemoveHealth", damage);
                    }

                    // Tally player's dodging skill
                    GameManager.Instance.PlayerEntity.TallySkill(DFCareer.Skills.Dodging, 1);
                }

                if (sounds)
                {
                    Items.DaggerfallUnityItem weapon = entity.ItemEquipTable.GetItem(Items.EquipSlots.RightHand);
                    if (weapon == null)
                    {
                        weapon = entity.ItemEquipTable.GetItem(Items.EquipSlots.LeftHand);
                    }
                    if (damage > 0)
                    {
                        // TODO: Play hit and parry sounds on other AI characters once attacks against other AI are possible
                        DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>();
                        if (dfAudioSource)
                        {
                            if (weapon == null)
                            {
                                dfAudioSource.PlayOneShot((int)SoundClips.Hit1 + UnityEngine.Random.Range(2, 4), 0, 1.1f);
                            }
                            else
                            {
                                dfAudioSource.PlayOneShot((int)SoundClips.Hit1 + UnityEngine.Random.Range(0, 5), 0, 1.1f);
                            }
                        }
                    }
                    else
                    {
                        sounds.PlayMissSound(weapon);
                    }
                }
            }
        }
Ejemplo n.º 16
0
        private static void AddTorchAudioSource(GameObject go)
        {
            // Apply looping burning sound to flaming torches and fires
            // Set to linear rolloff or the burning sound is audible almost everywhere
            DaggerfallAudioSource c = go.AddComponent <DaggerfallAudioSource>();

            c.AudioSource.dopplerLevel = 0;
            c.AudioSource.rolloffMode  = AudioRolloffMode.Linear;
            c.AudioSource.maxDistance  = torchMaxDistance;
            c.AudioSource.volume       = torchVolume;
            c.SetSound(SoundClips.Burning, AudioPresets.LoopIfPlayerNear);
        }
Ejemplo n.º 17
0
 //binds key settings to script strings for input detection in update routine.
 void Start()
 {
     NextOutfitKey   = settings.GetValue <string>("Settings", "NextOutfitKey");
     PrevOutfitKey   = settings.GetValue <string>("Settings", "PrevOutfitKey");
     EquipOutfitKey  = settings.GetValue <string>("Settings", "EquipOutfitKey");
     ToggleGuiKey    = settings.GetValue <string>("Settings", "ToggleGuiKey");
     SaveOutfitKey   = settings.GetValue <string>("Settings", "SaveOutfitKey");
     DeleteOutfitKey = settings.GetValue <string>("Settings", "DeleteOutfitKey");
     UIWindowFactory.RegisterCustomUIWindow(UIWindowType.Inventory, typeof(OutfitManagerInventoryWindow));
     UIWindow          = (OutfitManagerInventoryWindow)UIWindowFactory.GetInstance(UIWindowType.Inventory, uiManager, null);
     dfAudioSource     = GameManager.Instance.PlayerObject.AddComponent <DaggerfallAudioSource>();
     console           = GameObject.Find("Console");
     consoleController = console.GetComponent <ConsoleController>();
 }
Ejemplo n.º 18
0
        void Update()
        {
            if (GameManager.Instance.DisableAI)
            {
                return;
            }

            // If a melee attack has reached the damage frame we can run a melee attempt
            if (mobile.DoMeleeDamage)
            {
                MeleeDamage();
                mobile.DoMeleeDamage = false;
            }
            // If a bow attack has reached the shoot frame we can shoot an arrow
            else if (mobile.ShootArrow)
            {
                ShootBow();
                mobile.ShootArrow = false;

                DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>();
                if (dfAudioSource)
                {
                    dfAudioSource.PlayOneShot((int)SoundClips.ArrowShoot, 1, 1.0f);
                }
            }

            // Countdown to next melee attack
            MeleeTimer -= Time.deltaTime;

            if (MeleeTimer < 0)
            {
                MeleeTimer = 0;
            }

            EnemyEntity entity = entityBehaviour.Entity as EnemyEntity;
            int         speed  = entity.Stats.LiveSpeed;

            // Note: Speed comparison here is reversed from classic. Classic's way makes fewer attack
            // attempts at higher speeds, so it seems backwards.
            if (GameManager.ClassicUpdate && (DFRandom.rand() % speed >= (speed >> 3) + 6 && MeleeTimer == 0))
            {
                if (!MeleeAnimation())
                {
                    return;
                }

                ResetMeleeTimer();
            }
        }
        void Start()
        {
            random             = new System.Random(System.DateTime.Now.Millisecond);
            dfAudioSource      = GetComponent <DaggerfallAudioSource>();
            loopAudioSource    = GetNewAudioSource();
            ambientAudioSource = GetNewAudioSource();

            ApplyPresets();
            StartWaiting();
            playerBehaviour = GameManager.Instance.PlayerEntityBehaviour;
            playerEnterExit = GameManager.Instance.PlayerEnterExit;

            DaggerfallVidPlayerWindow.OnVideoStart += AmbientEffectsPlayer_OnVideoStart;
            DaggerfallVidPlayerWindow.OnVideoEnd   += AmbientEffectsPlayer_OnVideoEnd;
        }
Ejemplo n.º 20
0
        void Start()
        {
            // Store references
            dfAudioSource = GetComponent <DaggerfallAudioSource>();
            playerMotor   = GetComponent <PlayerMotor>();

            // Add our own custom audio source at runtime as we need to change the pitch of footsteps.
            // We don't want that affecting to other sounds on this game object.
            customAudioSource              = gameObject.AddComponent <AudioSource>();
            customAudioSource.playOnAwake  = false;
            customAudioSource.loop         = false;
            customAudioSource.dopplerLevel = 0f;

            // Set start position
            lastPosition = GetHorizontalPosition();
        }
Ejemplo n.º 21
0
        private static void AddAnimalAudioSource(GameObject go)
        {
            DaggerfallAudioSource source = go.AddComponent <DaggerfallAudioSource>();

            source.AudioSource.maxDistance = animalSoundMaxDistance;

            DaggerfallBillboard dfBillboard = go.GetComponent <DaggerfallBillboard>();
            SoundClips          sound       = SoundClips.None;

            switch (dfBillboard.Summary.Record)
            {
            case 0:
            case 1:
                sound = SoundClips.AnimalHorse;
                break;

            case 3:
            case 4:
                sound = SoundClips.AnimalCow;
                break;

            case 5:
            case 6:
                sound = SoundClips.AnimalPig;
                break;

            case 7:
            case 8:
                sound = SoundClips.AnimalCat;
                break;

            case 9:
            case 10:
                sound = SoundClips.AnimalDog;
                break;

            default:
                sound = SoundClips.None;
                break;
            }

            source.SetSound(sound, AudioPresets.PlayRandomlyIfPlayerNear);
        }
        private void PlayerSpellCasting_OnReleaseFrame()
        {
            // TODO: Split missile generation from player spell casting so monsters can also cast spells
            // Using player as sole testing platform for now

            // Must have a ready spell
            if (readySpell == null)
            {
                return;
            }

            // Play cast sound from caster audio source
            if (readySpell.CasterEntityBehaviour)
            {
                int castSoundID = GetCastSoundID(readySpell.Settings.ElementType);
                DaggerfallAudioSource audioSource = readySpell.CasterEntityBehaviour.GetComponent <DaggerfallAudioSource>();
                if (castSoundID != -1 && audioSource)
                {
                    audioSource.PlayOneShot((uint)castSoundID);
                }
            }

            // Assign bundle directly to self if target is caster
            // Otherwise instatiate missile prefab based on element type
            if (readySpell.Settings.TargetType == TargetTypes.CasterOnly)
            {
                AssignBundle(readySpell);
            }
            else
            {
                DaggerfallMissile missile = InstantiateMissile(readySpell.Settings.ElementType);
                if (missile)
                {
                    missile.Payload = readySpell;
                }
            }

            // Clear ready spell and reset casting
            lastSpell      = readySpell;
            readySpell     = null;
            instantCast    = false;
            castInProgress = false;
        }
Ejemplo n.º 23
0
        // Use this for initialization
        void Start()
        {
            dfAudioSource = GetComponent <DaggerfallAudioSource>();
            playerMotor   = GetComponent <PlayerMotor>();

            // Use custom audio source as we don't want to affect other sounds while riding.
            ridingAudioSource              = gameObject.AddComponent <AudioSource>();
            ridingAudioSource.hideFlags    = HideFlags.HideInInspector;
            ridingAudioSource.playOnAwake  = false;
            ridingAudioSource.loop         = false;
            ridingAudioSource.dopplerLevel = 0f;
            ridingAudioSource.spatialBlend = 0f;
            ridingAudioSource.volume       = RidingVolumeScale * DaggerfallUnity.Settings.SoundVolume;

            neighClip = dfAudioSource.GetAudioClip((int)horseSound);

            // Init event listener for transitions.
            PlayerEnterExit.OnPreTransition += new PlayerEnterExit.OnPreTransitionEventHandler(HandleTransition);
        }
Ejemplo n.º 24
0
        // Initialise.
        void Start()
        {
            playerMotor = GetComponent <PlayerMotor>();
            if (!playerMotor)
            {
                throw new Exception("PlayerMotor not found.");
            }

            transportManager = GetComponent <TransportManager>();
            if (!transportManager)
            {
                throw new Exception("TransportManager not found.");
            }
            transportManager.DrawHorse = false;

            playerMouseLook = GameManager.Instance.PlayerMouseLook;
            if (!playerMouseLook)
            {
                throw new Exception("PlayerMouseLook not found.");
            }

            dfAudioSource = GetComponent <DaggerfallAudioSource>();
            if (!dfAudioSource)
            {
                throw new Exception("DaggerfallAudioSource not found.");
            }

            trampleMaleClip   = dfAudioSource.GetAudioClip((int)trampleMale);
            trampleFemaleClip = dfAudioSource.GetAudioClip((int)trampleFemale);

            GameManager.Instance.SpeedChanger.CanRun = CanRunUnlessRidingCart;

            // Setup appropriate neck textures if availiable.
            for (int i = 0; i < 4; i++)
            {
                TextureReplacement.TryImportCifRci(horseNeckTextureName, 0, i, false, out horseNeckTextures[i].texture);
            }
            for (int i = 0; i < 4; i++)
            {
                TextureReplacement.TryImportCifRci(cartNeckTextureName, 0, i, false, out cartNeckTextures[i].texture);
            }
        }
Ejemplo n.º 25
0
        public AudioClip GetRandomClip(DaggerfallAudioSource source)
        {
            int max = soundClips.Count + audioClips.Count;

            if (max == 0)
            {
                return(null);
            }

            int rand = Random.Range(0, soundClips.Count + audioClips.Count);

            if (rand < soundClips.Count)
            {
                return(source.GetAudioClip((int)soundClips[rand]));
            }
            else
            {
                return(audioClips[rand]);
            }
        }
Ejemplo n.º 26
0
        void Awake()
        {
            dfUnity     = DaggerfallUnity.Instance;
            audioSource = GetComponent <AudioSource>();
            audioSource.spatialBlend = 0;
            dfAudioSource            = GetComponent <DaggerfallAudioSource>();
            dfSongPlayer             = GetComponent <DaggerfallSongPlayer>();

            dfPauseOptionsWindow   = new DaggerfallPauseOptionsWindow(uiManager);
            dfCharacterSheetWindow = new DaggerfallCharacterSheetWindow(uiManager);
            dfInventoryWindow      = new DaggerfallInventoryWindow(uiManager);
            dfTravelMapWindow      = new DaggerfallTravelMapWindow(uiManager);
            dfAutomapWindow        = new DaggerfallAutomapWindow(uiManager);

            dfExteriorAutomapWindow = new DaggerfallExteriorAutomapWindow(uiManager);

            dfQuestInspector = new QuestMachineInspectorWindow(uiManager);

            SetupSingleton();
        }
        void Awake()
        {
            dfUnity     = DaggerfallUnity.Instance;
            audioSource = GetComponent <AudioSource>();
            audioSource.spatialBlend = 0;
            dfAudioSource            = GetComponent <DaggerfallAudioSource>();

            dfPauseOptionsWindow          = new DaggerfallPauseOptionsWindow(uiManager);
            dfPauseOptionsWindow.OnClose += PauseOptionsDialog_OnClose;

            dfCharacterSheetWindow          = new DaggerfallCharacterSheetWindow(uiManager);
            dfCharacterSheetWindow.OnClose += CharacterSheetWindow_OnClose;

            dfInventoryWindow          = new DaggerfallInventoryWindow(uiManager);
            dfInventoryWindow.OnClose += InventoryWindow_OnClose;

            dfTravelMapWindow = new DaggerfallTravelMapWindow(uiManager);

            SetupSingleton();
            PostMessage(startupMessage);
        }
        void Start()
        {
            // Store references
            dfUnity         = DaggerfallUnity.Instance;
            dfAudioSource   = GetComponent <DaggerfallAudioSource>();
            playerMotor     = GetComponent <PlayerMotor>();
            playerEnterExit = GetComponent <PlayerEnterExit>();

            // Add our own custom audio source at runtime as we need to change the pitch of footsteps.
            // We don't want that affecting to other sounds on this game object.
            customAudioSource              = gameObject.AddComponent <AudioSource>();
            customAudioSource.hideFlags    = HideFlags.HideInInspector;
            customAudioSource.playOnAwake  = false;
            customAudioSource.loop         = false;
            customAudioSource.dopplerLevel = 0f;

            // Set start position
            lastPosition = GetHorizontalPosition();

            // Set starting footsteps
            currentFootstepSound = FootstepSoundNormal;
        }
Ejemplo n.º 29
0
        void Start()
        {
            // Store references
            dfUnity          = DaggerfallUnity.Instance;
            dfAudioSource    = GetComponent <DaggerfallAudioSource>();
            playerMotor      = GetComponent <PlayerMotor>();
            playerEnterExit  = GetComponent <PlayerEnterExit>();
            transportManager = GetComponent <TransportManager>();

            // CustomAudioSource was here for adjusting pitch. It should be removable now, but doing so makes the swimming sound loud, so leaving it for now.
            customAudioSource              = gameObject.AddComponent <AudioSource>();
            customAudioSource.hideFlags    = HideFlags.HideInInspector;
            customAudioSource.playOnAwake  = false;
            customAudioSource.loop         = false;
            customAudioSource.dopplerLevel = 0f;
            customAudioSource.spatialBlend = 0f;

            // Set start position
            lastPosition = GetHorizontalPosition();

            // Set starting footsteps
            currentFootstepSound1 = FootstepSoundDungeon1;
            currentFootstepSound2 = FootstepSoundDungeon2;
        }
Ejemplo n.º 30
0
        private void Setup()
        {
            currentLocationName = playerEnterExit.Dungeon.Summary.LocationName;

            DaggerfallActionDoor[] actionDoors = FindObjectsOfType <DaggerfallActionDoor>();

            if (actionDoors != null)
            {
                for (int i = 0; i < actionDoors.Length; i++)
                {
                    string meshFilterName = actionDoors[i].GetComponent <MeshFilter>().name;

                    if (meshFilterName.Contains("55000") || meshFilterName.Contains("55001") || meshFilterName.Contains("55002") || meshFilterName.Contains("55003") ||
                        meshFilterName.Contains("55004") || meshFilterName.Contains("55005"))
                    {
                        // Normal door
                        continue;
                    }
                    else
                    {
                        // Secret door
                        GameObject gameObject = new GameObject("SecretDoorAudio");
                        gameObject.transform.position = actionDoors[i].transform.position;
                        gameObject.transform.SetParent(actionDoors[i].transform);

                        gameObject.AddComponent <DaggerfallAudioSource>();
                        DaggerfallAudioSource daggerfallAudioSource = gameObject.GetComponent <DaggerfallAudioSource>();
                        daggerfallAudioSource.SetSound(72, AudioPresets.LoopIfPlayerNear);
                        daggerfallAudioSource.AudioSource.rolloffMode = AudioRolloffMode.Linear;
                        daggerfallAudioSource.AudioSource.minDistance = minDist;
                        daggerfallAudioSource.AudioSource.maxDistance = maxDist;
                        daggerfallAudioSource.AudioSource.volume      = volume;
                    }
                }
            }
        }
Ejemplo n.º 31
0
 void Start()
 {
     dfUnity = DaggerfallUnity.Instance;
     dfAudioSource = GetComponent<DaggerfallAudioSource>();
     StartCoroutine(AnimateWeapon());
 }
Ejemplo n.º 32
0
        void Awake()
        {
            dfUnity = DaggerfallUnity.Instance;
            audioSource = GetComponent<AudioSource>();
            audioSource.spatialBlend = 0;
            dfAudioSource = GetComponent<DaggerfallAudioSource>();

            dfPauseOptionsWindow = new DaggerfallPauseOptionsWindow(uiManager);
            dfPauseOptionsWindow.OnClose += PauseOptionsDialog_OnClose;

            dfCharacterSheetWindow = new DaggerfallCharacterSheetWindow(uiManager);
            dfCharacterSheetWindow.OnClose += CharacterSheetWindow_OnClose;

            dfInventoryWindow = new DaggerfallInventoryWindow(uiManager);
            dfInventoryWindow.OnClose += InventoryWindow_OnClose;

            dfTravelMapWindow = new DaggerfallTravelMapWindow(uiManager);

            SetupSingleton();
            PostMessage(startupMessage);
        }
Ejemplo n.º 33
0
        void Start()
        {
            // Store references
            dfUnity = DaggerfallUnity.Instance;
            dfAudioSource = GetComponent<DaggerfallAudioSource>();
            playerMotor = GetComponent<PlayerMotor>();
            playerEnterExit = GetComponent<PlayerEnterExit>();

            // Add our own custom audio source at runtime as we need to change the pitch of footsteps.
            // We don't want that affecting to other sounds on this game object.
            customAudioSource = gameObject.AddComponent<AudioSource>();
            customAudioSource.hideFlags = HideFlags.HideInInspector;
            customAudioSource.playOnAwake = false;
            customAudioSource.loop = false;
            customAudioSource.dopplerLevel = 0f;
            customAudioSource.spatialBlend = 0f;

            // Set start position
            lastPosition = GetHorizontalPosition();

            // Set starting footsteps
            currentFootstepSound = FootstepSoundNormal;
        }
Ejemplo n.º 34
0
        void Start()
        {
            // Save references
            dfAudioSource = GetComponent<DaggerfallAudioSource>();
            player = GameObject.FindGameObjectWithTag("Player");
            mobile = GetComponentInChildren<DaggerfallMobileUnit>();

            // Setup audio source
            dfAudioSource.AudioSource.maxDistance = AttractRadius;
            if (LinearRolloff)
                dfAudioSource.AudioSource.rolloffMode = AudioRolloffMode.Linear;
            dfAudioSource.AudioSource.spatialBlend = 1;

            // Assign sounds from mobile
            if (SoundsFromMobile && mobile)
            {
                MoveSound = (SoundClips)mobile.Summary.Enemy.MoveSound;
                BarkSound = (SoundClips)mobile.Summary.Enemy.BarkSound;
                AttackSound = (SoundClips)mobile.Summary.Enemy.AttackSound;
            }

            // Start attrack timer
            StartWaiting();
        }
Ejemplo n.º 35
0
 void Start()
 {
     random = new System.Random(System.DateTime.Now.Millisecond);
     dfAudioSource = GetComponent<DaggerfallAudioSource>();
     dfAudioSource.Preset = AudioPresets.OnDemand;
     ApplyPresets();
     StartWaiting();
 }