void Update()
        {
            if (!dfUnity.IsReady || !playerEnterExit || !PlayerTorch || playerEntity == null)
            {
                return;
            }

            bool enableTorch = false;

            if (DaggerfallUnity.Settings.PlayerTorchFromItems)
            {
                DaggerfallUnityItem lightSource = playerEntity.LightSource;
                if (lightSource != null)
                {
                    enableTorch      = true;
                    torchLight.range = lightSource.ItemTemplate.capacityOrTarget;
                    // Consume durability / fuel
                    if (Time.realtimeSinceStartup > lastTickTime + tickTimeInterval && !GameManager.IsGamePaused)
                    {
                        lastTickTime = Time.realtimeSinceStartup;
                        if (lightSource.currentCondition > 0)
                        {
                            lightSource.currentCondition--;
                        }

                        if (lightSource.currentCondition == 0 && DaggerfallUnityItem.CompareItems(playerEntity.LightSource, lightSource))
                        {
                            DaggerfallUI.MessageBox(TextManager.Instance.GetText(textDatabase, "lightDies"), false, lightSource);
                            enableTorch = false;
                            playerEntity.LightSource = null;
                            if (!lightSource.IsOfTemplate(ItemGroups.UselessItems2, (int)UselessItems2.Lantern))
                            {
                                playerEntity.Items.RemoveItem(lightSource);
                            }
                        }
                    }
                    // Give warning signs if running out of fuel
                    intensityMod = 1f;
                    if (lightSource.currentCondition < 2)
                    {
                        intensityMod = Random.Range(0.45f, 0.75f);
                    }
                }
            }
            else
            {
                enableTorch = (!playerEnterExit.IsPlayerInside && dfUnity.WorldTime.Now.IsCityLightsOn) || playerEnterExit.IsPlayerInsideDungeon;
            }
            if (torchLight)
            {
                torchLight.intensity = torchIntensity * DaggerfallUnity.Settings.PlayerTorchLightScale * intensityMod;
            }

            PlayerTorch.SetActive(enableTorch);
        }
Esempio n. 2
0
        void UpdateHands()
        {
            // Get current items
            DaggerfallUnityItem rightHandItem = playerEntity.ItemEquipTable.GetItem(EquipSlots.RightHand);
            DaggerfallUnityItem leftHandItem  = playerEntity.ItemEquipTable.GetItem(EquipSlots.LeftHand);

            // Handle shields
            holdingShield = false;
            if (leftHandItem != null && leftHandItem.IsShield)
            {
                usingRightHand = true;
                holdingShield  = true;
                leftHandItem   = null;
            }

            // Right-hand item changed
            if (!DaggerfallUnityItem.CompareItems(currentRightHandWeapon, rightHandItem))
            {
                currentRightHandWeapon = rightHandItem;
            }

            // Left-hand item changed
            if (!DaggerfallUnityItem.CompareItems(currentLeftHandWeapon, leftHandItem))
            {
                currentLeftHandWeapon = leftHandItem;
            }

            if (EquipCountdownRightHand > 0)
            {
                EquipCountdownRightHand -= Time.deltaTime * 980; // Approximating classic update time based off measuring video
                if (EquipCountdownRightHand <= 0)
                {
                    EquipCountdownRightHand = 0;
                    string message = HardStrings.rightHandEquipped;
                    DaggerfallUI.Instance.PopupMessage(message);
                }
            }
            if (EquipCountdownLeftHand > 0)
            {
                EquipCountdownLeftHand -= Time.deltaTime * 980; // Approximating classic update time based off measuring video
                if (EquipCountdownLeftHand <= 0)
                {
                    EquipCountdownLeftHand = 0;
                    string message = HardStrings.leftHandEquipped;
                    DaggerfallUI.Instance.PopupMessage(message);
                }
            }

            // Apply weapon settings
            ApplyWeapon();
        }
        void UpdateHands()
        {
            // Get current items
            DaggerfallUnityItem rightHandItem = playerEntity.ItemEquipTable.GetItem(EquipSlots.RightHand);
            DaggerfallUnityItem leftHandItem = playerEntity.ItemEquipTable.GetItem(EquipSlots.LeftHand);

            // Handle shields
            holdingShield = false;
            if (leftHandItem != null && leftHandItem.IsShield)
            {
                usingRightHand = true;
                holdingShield = true;
                leftHandItem = null;
            }

            // Right-hand item changed
            if (!DaggerfallUnityItem.CompareItems(currentRightHandWeapon, rightHandItem))
            {
                if (rightHandItem != null)
                {
                    //string message = HardStrings.equippingWeapon;
                    //message = message.Replace("%s", rightHandItem.ItemTemplate.name);
                    //DaggerfallUI.Instance.PopupMessage(message);
                }
                //DaggerfallUI.Instance.PopupMessage(HardStrings.rightHandEquipped);
                currentRightHandWeapon = rightHandItem;
            }

            // Left-hand item changed
            if (!DaggerfallUnityItem.CompareItems(currentLeftHandWeapon, leftHandItem))
            {
                if (leftHandItem != null)
                {
                    //string message = HardStrings.equippingWeapon;
                    //message = message.Replace("%s", leftHandItem.ItemTemplate.name);
                    //DaggerfallUI.Instance.PopupMessage(message);
                }
                //DaggerfallUI.Instance.PopupMessage(HardStrings.leftHandEquipped);
                currentLeftHandWeapon = leftHandItem;
            }

            // Apply weapon settings
            ApplyWeapon();
        }
        void Update()
        {
            if (!dfUnity.IsReady || !playerEnterExit || !PlayerTorch || playerEntity == null || GameManager.IsGamePaused)
            {
                return;
            }

            bool enableTorch = false;

            if (DaggerfallUnity.Settings.PlayerTorchFromItems)
            {
                DaggerfallUnityItem lightSource = playerEntity.LightSource;
                if (lightSource != null)
                {
                    enableTorch      = true;
                    torchLight.range = lightSource.ItemTemplate.capacityOrTarget;
                    // Consume durability / fuel
                    if (Time.realtimeSinceStartup > lastTickTime + tickTimeInterval)
                    {
                        lastTickTime = Time.realtimeSinceStartup;
                        if (lightSource.currentCondition > 0)
                        {
                            lightSource.currentCondition--;
                        }

                        if (lightSource.currentCondition == 0 && DaggerfallUnityItem.CompareItems(playerEntity.LightSource, lightSource))
                        {
                            DaggerfallUI.AddHUDText(TextManager.Instance.GetLocalizedText("lightDies").Replace("%it", lightSource.ItemName));
                            enableTorch = false;
                            playerEntity.LightSource = null;
                            if (!lightSource.IsOfTemplate(ItemGroups.UselessItems2, (int)UselessItems2.Lantern))
                            {
                                playerEntity.Items.RemoveItem(lightSource);
                            }
                        }
                    }

                    if (lightSource.currentCondition < 3)
                    {
                        // Give warning signs if running low of fuel
                        intensityMod = 0.6f + (Mathf.Cos(guttering) * 0.2f);
                        guttering   += Random.Range(-0.02f, 0.06f);
                    }
                    else
                    {
                        intensityMod = 1;
                        guttering    = 0;
                    }
                }
            }
            else
            {
                enableTorch = (!playerEnterExit.IsPlayerInside && dfUnity.WorldTime.Now.IsCityLightsOn) || playerEnterExit.IsPlayerInsideDungeon;
            }
            if (torchLight)
            {
                torchLight.intensity = torchIntensity * DaggerfallUnity.Settings.PlayerTorchLightScale * intensityMod;
            }

            PlayerTorch.SetActive(enableTorch);
        }