void FixedUpdate() { // Clip needs to be loaded before it can be played. // Only try to apply a valid index range. if (audioClip == null && SoundIndex >= minIndex && SoundIndex < maxIndex) { Apply(); } // Handle player checks if (playerCheck && audioSource && player) { bool playerInRange = (Vector3.Distance(transform.position, player.transform.position) <= audioSource.maxDistance); audioSource.enabled = playerInRange; // Allows volume to be adjusted without reloading game. audioSource.volume = DaggerfallUnity.Settings.SoundVolume; // Handle random play if (audioSource.enabled && playRandomly) { bool classicUpdate = false; if (classicUpdateTimer < Game.Entity.PlayerEntity.ClassicUpdateInterval) { classicUpdateTimer += Time.deltaTime; } else { classicUpdateTimer = 0; classicUpdate = true; } if (classicUpdate && DFRandom.rand() <= 100) { audioSource.Play(); } } } }
public void StockHouseContainer(PlayerGPS.DiscoveredBuilding buildingData) { stockedDate = CreateStockedDate(DaggerfallUnity.Instance.WorldTime.Now); items.Clear(); DFLocation.BuildingTypes buildingType = buildingData.buildingType; uint modelIndex = (uint)TextureRecord; //int buildingQuality = buildingData.quality; byte[] privatePropertyList = null; DaggerfallUnityItem item = null; Game.Entity.PlayerEntity playerEntity = GameManager.Instance.PlayerEntity; if (buildingType < DFLocation.BuildingTypes.House5) { if (modelIndex >= 2) { if (modelIndex >= 4) { if (modelIndex >= 11) { if (modelIndex >= 15) { privatePropertyList = DaggerfallLootDataTables.privatePropertyItemsModels15AndUp[(int)buildingType]; } else { privatePropertyList = DaggerfallLootDataTables.privatePropertyItemsModels11to14[(int)buildingType]; } } else { privatePropertyList = DaggerfallLootDataTables.privatePropertyItemsModels4to10[(int)buildingType]; } } else { privatePropertyList = DaggerfallLootDataTables.privatePropertyItemsModels2to3[(int)buildingType]; } } else { privatePropertyList = DaggerfallLootDataTables.privatePropertyItemsModels0to1[(int)buildingType]; } if (privatePropertyList == null) { return; } int randomChoice = Random.Range(0, privatePropertyList.Length); ItemGroups itemGroup = (ItemGroups)privatePropertyList[randomChoice]; int continueChance = 100; bool keepGoing = true; while (keepGoing) { if (itemGroup != ItemGroups.MensClothing && itemGroup != ItemGroups.WomensClothing) { if (itemGroup == ItemGroups.MagicItems) { item = ItemBuilder.CreateRandomMagicItem(playerEntity.Level, playerEntity.Gender, playerEntity.Race); } else if (itemGroup == ItemGroups.Books) { item = ItemBuilder.CreateRandomBook(); } else { if (itemGroup == ItemGroups.Weapons) { item = ItemBuilder.CreateRandomWeapon(playerEntity.Level); } else if (itemGroup == ItemGroups.Armor) { item = ItemBuilder.CreateRandomArmor(playerEntity.Level, playerEntity.Gender, playerEntity.Race); } else { System.Array enumArray = DaggerfallUnity.Instance.ItemHelper.GetEnumArray(itemGroup); item = new DaggerfallUnityItem(itemGroup, Random.Range(0, enumArray.Length)); } } } else { item = ItemBuilder.CreateRandomClothing(playerEntity.Gender, playerEntity.Race); } continueChance >>= 1; if (DFRandom.rand() % 100 > continueChance) { keepGoing = false; } items.AddItem(item); } } }