Example #1
0
 void Awake()
 {
     playerController = GetComponent<CharacterController>();
     entityBehaviour = GetComponent<DaggerfallEntityBehaviour>();
     entityBehaviour.OnSetEntity += EntityBehaviour_OnSetEntity;
     mainCamera = GameManager.Instance.MainCamera;
 }
Example #2
0
 void Awake()
 {
     dfUnity   = DaggerfallUnity.Instance;
     playerGPS = GetComponent <PlayerGPS>();
     world     = FindObjectOfType <StreamingWorld>();
     player    = GameManager.Instance.PlayerEntityBehaviour;
 }
 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;
 }
        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;
        }
Example #5
0
        public DaggerfallHUD(IUserInterfaceManager uiManager)
            : base(uiManager)
        {
            parentPanel.BackgroundColor = Color.clear;
            ShowPopupText = true;
            ShowCrosshair = true;
            ShowVitals = true;
            ShowCompass = true;

            // Get references
            player = GameObject.FindGameObjectWithTag("Player");
            playerEntity = player.GetComponent<DaggerfallEntityBehaviour>();

            ParentPanel.Components.Add(crosshair);
            ParentPanel.Components.Add(vitals);
            ParentPanel.Components.Add(compass);
        }
 void Awake()
 {
     mobile = GetComponentInChildren<DaggerfallMobileUnit>();
     entityBehaviour = GetComponent<DaggerfallEntityBehaviour>();
     entityBehaviour.OnSetEntity += EntityBehaviour_OnSetEntity;
 }
        void Awake()
        {
            playerEnterExit = GetComponent<PlayerEnterExit>();
            if (!playerEnterExit)
                throw new Exception("PlayerEnterExit not found.");

            playerCamera = GetComponentInChildren<Camera>();
            if (!playerCamera)
                throw new Exception("Player Camera not found.");

            playerMouseLook = playerCamera.GetComponent<PlayerMouseLook>();
            if (!playerMouseLook)
                throw new Exception("PlayerMouseLook not found.");

            playerMotor = GetComponent<PlayerMotor>();
            if (!playerMotor)
                throw new Exception("PlayerMotor not found.");

            playerEntityBehaviour = GetComponent<DaggerfallEntityBehaviour>();
            if (!playerEntityBehaviour)
                throw new Exception("PlayerEntityBehaviour not found.");

            SaveLoadManager.RegisterSerializableGameObject(this);
        }
 void Awake()
 {
     entityBehaviour = GetComponent<DaggerfallEntityBehaviour>();
 }
 void Start()
 {
     motor = GetComponent<EnemyMotor>();
     senses = GetComponent<EnemySenses>();
     sounds = GetComponent<EnemySounds>();
     mobile = GetComponentInChildren<DaggerfallMobileUnit>();
     entityBehaviour = GetComponent<DaggerfallEntityBehaviour>();
 }
Example #10
0
        public override void Update(DaggerfallEntityBehaviour sender)
        {
            if (CurrentHealth <= 0)
            {
                return;
            }

            bool classicUpdate = false;

            if (classicUpdateTimer < ClassicUpdateInterval)
            {
                classicUpdateTimer += Time.deltaTime;
            }
            else
            {
                classicUpdateTimer = 0;
                classicUpdate      = true;
            }

            if (playerMotor == null)
            {
                playerMotor = GameManager.Instance.PlayerMotor;
            }

            uint gameMinutes = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime();

            // Wait until game has started and the game time has been set.
            // If the game time is taken before then "30" is returned, which causes an initial player fatigue loss
            // after loading or starting a game with a non-30 minute.
            if (!gameStarted && !GameManager.Instance.StateManager.GameInProgress)
            {
                return;
            }
            else if (!gameStarted)
            {
                gameStarted = true;
            }
            if (playerMotor != null)
            {
                // Every game minute, apply fatigue loss to the player
                if (lastGameMinutes != gameMinutes)
                {
                    int amount = DefaultFatigueLoss;
                    if (playerMotor.IsRunning)
                    {
                        amount = RunningFatigueLoss;
                    }
                    else if (GameManager.Instance.PlayerEnterExit.IsPlayerSwimming)
                    {
                        if (Race != Races.Argonian && UnityEngine.Random.Range(1, 100 + 1) > Skills.GetLiveSkillValue(DFCareer.Skills.Swimming))
                        {
                            amount = SwimmingFatigueLoss;
                        }
                        TallySkill(DFCareer.Skills.Swimming, 1);
                    }

                    DecreaseFatigue(amount);
                }

                // Handle events that are called by classic's update loop
                if (classicUpdate)
                {
                    // Tally running skill
                    if (playerMotor.IsRunning && !playerMotor.IsRiding)
                    {
                        TallySkill(DFCareer.Skills.Running, 1);
                    }

                    // Handle breath when underwater
                    if (GameManager.Instance.PlayerEnterExit.IsPlayerSubmerged)
                    {
                        if (currentBreath == 0)
                        {
                            currentBreath = MaxBreath;
                        }
                        if (breathUpdateTally > 18)
                        {
                            --currentBreath;
                            if (Race == Races.Argonian && (UnityEngine.Random.Range(0, 2) == 1))
                            {
                                ++currentBreath;
                            }
                            breathUpdateTally = 0;
                        }
                        else
                        {
                            ++breathUpdateTally;
                        }

                        if (currentBreath <= 0)
                        {
                            SetHealth(0);
                        }
                    }
                    else
                    {
                        currentBreath = 0;
                    }
                }

                // Reduce fatigue when jumping and tally jumping skill
                if (!CheckedCurrentJump && playerMotor.IsJumping)
                {
                    DecreaseFatigue(JumpingFatigueLoss);
                    TallySkill(DFCareer.Skills.Jumping, 1);
                    CheckedCurrentJump = true;
                }

                // Reset jump fatigue check when grounded
                if (CheckedCurrentJump && !playerMotor.IsJumping)
                {
                    CheckedCurrentJump = false;
                }
            }

            // Adjust regional prices and update climate weathers whenever the date has changed.
            uint lastDay    = lastGameMinutes / 1440;
            uint currentDay = gameMinutes / 1440;
            int  daysPast   = (int)(currentDay - lastDay);

            if (daysPast > 0)
            {
                FormulaHelper.ModifyPriceAdjustmentByRegion(ref regionData, daysPast);
                GameManager.Instance.WeatherManager.SetClimateWeathers();
                GameManager.Instance.WeatherManager.UpdateWeatherFromClimateArray = true;
            }

            lastGameMinutes = gameMinutes;

            //HandleStartingCrimeGuildQuests(Entity as PlayerEntity);
        }
 protected void CacheReferences()
 {
     entityBehaviour     = GetComponent <DaggerfallEntityBehaviour>();
     entityEffectManager = GetComponent <EntityEffectManager>();
     meshRenderer        = GetComponentInChildren <MeshRenderer>();
 }
        /// <summary>
        /// Handle shared logic when player attacks entity.
        /// </summary>
        public void HandleAttackFromSource(DaggerfallEntityBehaviour sourceEntityBehaviour)
        {
            // Break "normal power" concealment effects on source
            if (sourceEntityBehaviour.Entity.IsMagicallyConcealedNormalPower)
            {
                EntityEffectManager.BreakNormalPowerConcealmentEffects(sourceEntityBehaviour);
            }

            // When source is player
            if (sourceEntityBehaviour == GameManager.Instance.PlayerEntityBehaviour)
            {
                PlayerEntity playerEntity = GameManager.Instance.PlayerEntity;
                // Handle civilian NPC crime reporting
                if (EntityType == EntityTypes.CivilianNPC)
                {
                    MobilePersonNPC mobileNpc = transform.GetComponent <MobilePersonNPC>();
                    if (mobileNpc)
                    {
                        // Handle assault or murder
                        if (Entity.CurrentHealth > 0)
                        {
                            playerEntity.CrimeCommitted = PlayerEntity.Crimes.Assault;
                            playerEntity.SpawnCityGuards(true);
                        }
                        else
                        {
                            if (!mobileNpc.Billboard.IsUsingGuardTexture)
                            {
                                playerEntity.TallyCrimeGuildRequirements(false, 5);
                                playerEntity.CrimeCommitted = PlayerEntity.Crimes.Murder;
                                playerEntity.SpawnCityGuards(true);
                            }
                            else
                            {
                                playerEntity.CrimeCommitted = PlayerEntity.Crimes.Assault;
                                playerEntity.SpawnCityGuard(mobileNpc.transform.position, mobileNpc.transform.forward);
                            }

                            // Disable when dead
                            mobileNpc.Motor.gameObject.SetActive(false);
                        }
                    }
                }

                // Handle mobile enemy aggro
                if (EntityType == EntityTypes.EnemyClass || EntityType == EntityTypes.EnemyMonster)
                {
                    // Make enemy aggressive to player
                    EnemyMotor enemyMotor = transform.GetComponent <EnemyMotor>();
                    if (enemyMotor)
                    {
                        if (!enemyMotor.IsHostile)
                        {
                            GameManager.Instance.MakeEnemiesHostile();
                        }
                        enemyMotor.MakeEnemyHostileToAttacker(GameManager.Instance.PlayerEntityBehaviour);
                    }

                    // Handle killing guards
                    EnemyEntity enemyEntity = entity as EnemyEntity;
                    if (enemyEntity.MobileEnemy.ID == (int)MobileTypes.Knight_CityWatch && entity.CurrentHealth <= 0)
                    {
                        playerEntity.TallyCrimeGuildRequirements(false, 1);
                        playerEntity.CrimeCommitted = PlayerEntity.Crimes.Murder;
                    }
                }
            }
        }
Example #13
0
        /// <summary>
        /// Handle shared logic when player attacks entity.
        /// </summary>
        public void HandleAttackFromSource(DaggerfallEntityBehaviour sourceEntityBehaviour)
        {
            // Break "normal power" concealment effects on source
            if (sourceEntityBehaviour && sourceEntityBehaviour.Entity.IsMagicallyConcealedNormalPower)
            {
                EntityEffectManager.BreakNormalPowerConcealmentEffects(sourceEntityBehaviour);
            }

            // When source is player
            if (sourceEntityBehaviour == GameManager.Instance.PlayerEntityBehaviour)
            {
                PlayerEntity playerEntity = GameManager.Instance.PlayerEntity;
                // Handle civilian NPC crime reporting
                if (EntityType == EntityTypes.CivilianNPC)
                {
                    MobilePersonNPC mobileNpc = transform.GetComponent <MobilePersonNPC>();
                    if (mobileNpc)
                    {
                        // Handle assault or murder
                        if (Entity.CurrentHealth > 0)
                        {
                            playerEntity.CrimeCommitted = PlayerEntity.Crimes.Assault;
                            playerEntity.SpawnCityGuards(true);
                        }
                        else
                        {
                            if (!mobileNpc.IsGuard)
                            {
                                playerEntity.TallyCrimeGuildRequirements(false, 5);
                                playerEntity.CrimeCommitted = PlayerEntity.Crimes.Murder;
                                playerEntity.SpawnCityGuards(true);
                            }
                            else
                            {
                                playerEntity.CrimeCommitted = PlayerEntity.Crimes.Assault;
                                playerEntity.SpawnCityGuard(mobileNpc.transform.position, mobileNpc.transform.forward);
                            }

                            // Disable when dead
                            mobileNpc.Motor.gameObject.SetActive(false);
                        }
                    }
                }

                // Handle equipped Azura's Star trapping slain enemy monsters
                // This is always successful if Azura's Star is empty and equipped
                if (EntityType == EntityTypes.EnemyMonster && playerEntity.IsAzurasStarEquipped && entity.CurrentHealth <= 0)
                {
                    EnemyEntity enemyEntity = entity as EnemyEntity;
                    if (SoulTrap.FillEmptyTrapItem((MobileTypes)enemyEntity.MobileEnemy.ID, true))
                    {
                        DaggerfallUI.AddHUDText(TextManager.Instance.GetText("ClassicEffects", "trapSuccess"), 1.5f);
                    }
                }

                // Handle mobile enemy aggro
                if (EntityType == EntityTypes.EnemyClass || EntityType == EntityTypes.EnemyMonster)
                {
                    // Make enemy aggressive to player
                    EnemyMotor enemyMotor = transform.GetComponent <EnemyMotor>();
                    if (enemyMotor)
                    {
                        if (!enemyMotor.IsHostile)
                        {
                            GameManager.Instance.MakeEnemiesHostile();
                        }
                        enemyMotor.MakeEnemyHostileToAttacker(GameManager.Instance.PlayerEntityBehaviour);
                    }

                    // Handle killing guards
                    EnemyEntity enemyEntity = entity as EnemyEntity;
                    if (enemyEntity.MobileEnemy.ID == (int)MobileTypes.Knight_CityWatch && entity.CurrentHealth <= 0)
                    {
                        playerEntity.TallyCrimeGuildRequirements(false, 1);
                        playerEntity.CrimeCommitted = PlayerEntity.Crimes.Murder;
                    }
                }
            }
        }
Example #14
0
 public CivilianEntity(DaggerfallEntityBehaviour entityBehaviour)
     : base(entityBehaviour)
 {
 }
 /// <summary>
 /// Called by DaggerfallEntityBehaviour each frame.
 /// </summary>
 /// <param name="sender">DaggerfallEntityBehaviour making call.</param>
 public virtual void Update(DaggerfallEntityBehaviour sender)
 {
 }
        void Awake()
        {
            playerController = GetComponent<CharacterController>();
            playerMotor = GetComponent<PlayerMotor>();
            entityBehaviour = GetComponent<DaggerfallEntityBehaviour>();
            entityBehaviour.OnSetEntity += EntityBehaviour_OnSetEntity;
            mainCamera = GameManager.Instance.MainCamera;

            startCameraHeight = mainCamera.transform.localPosition.y;
        }
Example #17
0
 public EnemyEntity(DaggerfallEntityBehaviour entityBehaviour)
     : base(entityBehaviour)
 {
 }
        void Update()
        {
            // Change sound presets
            if (Presets != lastPresets)
            {
                // Clear settings
                lastPresets  = Presets;
                rainLoop     = null;
                cricketsLoop = null;

                // Stop playing any loops
                if (dfAudioSource.AudioSource.isPlaying)
                {
                    dfAudioSource.AudioSource.Stop();
                    dfAudioSource.AudioSource.clip = null;
                    dfAudioSource.AudioSource.loop = false;
                }

                ApplyPresets();
                StartWaiting();
            }

            // Start rain loop if not running
            if ((Presets == AmbientSoundPresets.Rain || Presets == AmbientSoundPresets.Storm) && rainLoop == null)
            {
                rainLoop = dfAudioSource.GetAudioClip((int)SoundClips.AmbientRaining);
                dfAudioSource.AudioSource.clip         = rainLoop;
                dfAudioSource.AudioSource.loop         = true;
                dfAudioSource.AudioSource.spatialBlend = 0;
                dfAudioSource.AudioSource.Play();
            }

            // Start crickets loop if not running
            if ((Presets == AmbientSoundPresets.ClearNight) && cricketsLoop == null)
            {
                cricketsLoop = dfAudioSource.GetAudioClip((int)SoundClips.AmbientCrickets);
                dfAudioSource.AudioSource.clip         = cricketsLoop;
                dfAudioSource.AudioSource.loop         = true;
                dfAudioSource.AudioSource.spatialBlend = 0;
                dfAudioSource.AudioSource.Play();
            }

            // Tick counters
            waitCounter      += Time.deltaTime;
            waterWaitCounter += Time.deltaTime;
            if (waitCounter > waitTime)
            {
                PlayEffects();
                StartWaiting();
            }

            // Play water sound effects. Timing and position based on classic behavior.
            // TODO: Make sound follow player's X and Z movement but play from Y coordinate of dungeon water, for a more dynamically 3d sound.
            // Currently the sound is a volume adjustment based on vertical distance from the water.
            if (waterWaitCounter > waterSoundWaitTime)
            {
                if (playerEnterExit == null)
                {
                    playerEnterExit = GameManager.Instance.PlayerEnterExit;
                }
                if (playerEnterExit)
                {
                    if (playerEnterExit.blockWaterLevel != 10000)
                    {
                        Entity.DaggerfallEntityBehaviour player = GameManager.Instance.PlayerEntityBehaviour;
                        // Chance to play gentle water sound based on vertical distance between player and water surface
                        if (DFRandom.rand() < 50)
                        {
                            float waterHeightInDFUnityUnits = (playerEnterExit.blockWaterLevel * -1 * MeshReader.GlobalScale);
                            float volumeScale = Mathf.Clamp(1 - (Mathf.Abs(player.transform.position.y - waterHeightInDFUnityUnits) / 9), 0, 1);
                            dfAudioSource.PlayOneShot((int)SoundClips.WaterGentle, 0, volumeScale);
                        }

                        // Chance to play underwater bubbling noise if player is underwater
                        if (playerEnterExit.IsPlayerSubmerged)
                        {
                            if (DFRandom.rand() < 100)
                            {
                                dfAudioSource.PlayOneShot((int)SoundClips.AmbientWaterBubbles, 0);
                            }
                        }
                    }
                }
                waterWaitCounter = 0;
            }
        }
 /// <summary>
 /// Called by DaggerfallEntityBehaviour each frame.
 /// </summary>
 /// <param name="sender">DaggerfallEntityBehaviour making call.</param>
 public virtual void Update(DaggerfallEntityBehaviour sender)
 {
 }