private void InitMacronutrientsData() { WatchMacronutrientsData watchMacronutrientsData = new WatchMacronutrientsData(); watchMacronutrientsData.m_Parent = this.m_Canvas.transform.Find("Macronutrients").gameObject; watchMacronutrientsData.m_Fat = watchMacronutrientsData.m_Parent.transform.Find("Fat").GetComponent <Image>(); watchMacronutrientsData.m_Carbo = watchMacronutrientsData.m_Parent.transform.Find("Carbo").GetComponent <Image>(); watchMacronutrientsData.m_Hydration = watchMacronutrientsData.m_Parent.transform.Find("Hydration").GetComponent <Image>(); watchMacronutrientsData.m_Proteins = watchMacronutrientsData.m_Parent.transform.Find("Proteins").GetComponent <Image>(); watchMacronutrientsData.m_FatBG = watchMacronutrientsData.m_Parent.transform.Find("FatBG").GetComponent <Image>(); watchMacronutrientsData.m_CarboBG = watchMacronutrientsData.m_Parent.transform.Find("CarboBG").GetComponent <Image>(); watchMacronutrientsData.m_HydrationBG = watchMacronutrientsData.m_Parent.transform.Find("HydrationBG").GetComponent <Image>(); watchMacronutrientsData.m_ProteinsBG = watchMacronutrientsData.m_Parent.transform.Find("ProteinsBG").GetComponent <Image>(); Color color = IconColors.GetColor(IconColors.Icon.Fat); watchMacronutrientsData.m_Fat.color = color; color = IconColors.GetColor(IconColors.Icon.Carbo); watchMacronutrientsData.m_Carbo.color = color; color = IconColors.GetColor(IconColors.Icon.Proteins); watchMacronutrientsData.m_Proteins.color = color; color = IconColors.GetColor(IconColors.Icon.Hydration); watchMacronutrientsData.m_Hydration.color = color; watchMacronutrientsData.m_Parent.SetActive(false); this.m_Datas.Add(2, watchMacronutrientsData); }
/// <summary> /// Adds a new Item to the list of possible purchases /// </summary> /// <param name="NewItem">The item to add</param> private void AddItem(BuyMenuItem item) { if (this.Items == null) { this.Items = new List <BuyMenuItem>(); } this.Items.Add(item); IconColors.Add(default(Color)); }
public void AddMessage(string text, Color?color = null, HUDMessageIcon icon = HUDMessageIcon.None, string icon_name = "", List <int> icon_indexes = null) { string[] array = text.Split(new char[] { '\n' }); for (int i = 0; i < array.Length; i++) { HUDMessage hudmessage = new HUDMessage(); hudmessage.m_StartTime = Time.time; hudmessage.m_HudElem = base.AddElement("HUDMessageElement"); hudmessage.m_HudElem.transform.position = Vector3.zero; hudmessage.m_HudElem.transform.SetParent(base.transform, false); hudmessage.m_TextComponent = hudmessage.m_HudElem.GetComponentInChildren <Text>(); hudmessage.m_TextComponent.text = array[i]; hudmessage.m_TextComponent.color = ((color == null) ? Color.white : color.Value); hudmessage.m_BGComponent = hudmessage.m_HudElem.transform.FindDeepChild("BG").GetComponentInChildren <RawImage>(); hudmessage.m_IconComponent = hudmessage.m_HudElem.transform.FindDeepChild("Icon").GetComponentInChildren <Image>(); hudmessage.m_Group = hudmessage.m_HudElem.transform.FindDeepChild("Group").gameObject; if (icon == HUDMessageIcon.None || (icon_indexes != null && !icon_indexes.Contains(i))) { hudmessage.m_IconComponent.gameObject.SetActive(false); } else if (icon == HUDMessageIcon.Carbo) { hudmessage.m_IconComponent.gameObject.SetActive(true); hudmessage.m_IconComponent.sprite = this.m_CarboIcon; hudmessage.m_IconComponent.color = IconColors.GetColor(IconColors.Icon.Carbo); } else if (icon == HUDMessageIcon.Fat) { hudmessage.m_IconComponent.gameObject.SetActive(true); hudmessage.m_IconComponent.sprite = this.m_FatIcon; hudmessage.m_IconComponent.color = IconColors.GetColor(IconColors.Icon.Fat); } else if (icon == HUDMessageIcon.Proteins) { hudmessage.m_IconComponent.gameObject.SetActive(true); hudmessage.m_IconComponent.sprite = this.m_ProteinsIcon; hudmessage.m_IconComponent.color = IconColors.GetColor(IconColors.Icon.Proteins); } else if (icon == HUDMessageIcon.Hydration) { hudmessage.m_IconComponent.gameObject.SetActive(true); hudmessage.m_IconComponent.sprite = this.m_HydrationIcon; hudmessage.m_IconComponent.color = IconColors.GetColor(IconColors.Icon.Hydration); } else if (icon == HUDMessageIcon.Energy) { hudmessage.m_IconComponent.gameObject.SetActive(true); hudmessage.m_IconComponent.sprite = this.m_EnergyIcon; hudmessage.m_IconComponent.color = IconColors.GetColor(IconColors.Icon.Energy); } else if (icon == HUDMessageIcon.FoodPoisoning) { hudmessage.m_IconComponent.gameObject.SetActive(true); hudmessage.m_IconComponent.sprite = this.m_FoodPoisoningIcon; hudmessage.m_IconComponent.color = Color.white; } else if (icon == HUDMessageIcon.ParasiteSickness) { hudmessage.m_IconComponent.gameObject.SetActive(true); hudmessage.m_IconComponent.sprite = this.m_ParasiteSicknessIcon; hudmessage.m_IconComponent.color = Color.white; } else if (icon == HUDMessageIcon.Item) { if (icon_name.Empty()) { hudmessage.m_IconComponent.gameObject.SetActive(false); } Sprite sprite = null; ItemsManager.Get().m_ItemIconsSprites.TryGetValue(icon_name, out sprite); if (sprite != null) { hudmessage.m_IconComponent.sprite = sprite; hudmessage.m_IconComponent.gameObject.SetActive(true); } else { hudmessage.m_IconComponent.gameObject.SetActive(false); } } hudmessage.m_HudElem.transform.SetParent(base.transform); hudmessage.m_TargetGroupPos = hudmessage.m_Group.transform.position; Vector3 vector = Vector3.zero; Vector3 position = hudmessage.m_Group.transform.position; vector = position; position.x = (float)Screen.width; vector -= position; hudmessage.m_Group.transform.position -= vector; if (Player.Get().m_DreamActive || !base.enabled) { hudmessage.m_HudElem.gameObject.SetActive(false); } this.m_Messages.Insert(0, hudmessage); } while (this.m_Messages.Count >= this.MAX_COUNT) { HUDMessage hudmessage2 = this.m_Messages[this.m_Messages.Count - 1]; UnityEngine.Object.Destroy(hudmessage2.m_HudElem); this.m_Messages.Remove(hudmessage2); } this.UpdateElements(); }
private void SetupConsumableEffects() { if (!this.m_ConsumableEffects) { return; } if (!Inventory3DManager.Get().gameObject.activeSelf || this.IsExpanded()) { this.m_ConsumableEffects.gameObject.SetActive(false); return; } Trigger trigger = this.GetTrigger(); if (trigger == null || !trigger.IsItem()) { this.m_ConsumableEffects.gameObject.SetActive(false); return; } Item item = (Item)trigger; if (!item.m_Info.IsConsumable() && !item.m_Info.IsLiquidContainer()) { this.m_ConsumableEffects.gameObject.SetActive(false); return; } int num = 0; if (item.m_Info.IsConsumable()) { if (!ItemsManager.Get().WasConsumed(item.m_Info.m_ID)) { this.m_UnknownEffect.SetActive(true); } else { this.m_UnknownEffect.SetActive(false); ConsumableInfo consumableInfo = (ConsumableInfo)item.m_Info; if (consumableInfo.m_Proteins > 0f) { this.SetupEffect("Watch_protein_icon", IconColors.GetColor(IconColors.Icon.Proteins), consumableInfo.m_Proteins, "HUD_Nutrition_Protein", ref num, -1f); } if (consumableInfo.m_Fat > 0f) { this.SetupEffect("Watch_fat_icon", IconColors.GetColor(IconColors.Icon.Fat), consumableInfo.m_Fat, "HUD_Nutrition_Fat", ref num, -1f); } if (consumableInfo.m_Carbohydrates > 0f) { this.SetupEffect("Watch_carbo_icon", IconColors.GetColor(IconColors.Icon.Carbo), consumableInfo.m_Carbohydrates, "HUD_Nutrition_Carbo", ref num, -1f); } if (consumableInfo.m_Water > 0f) { this.SetupEffect("Watch_water_icon", IconColors.GetColor(IconColors.Icon.Hydration), consumableInfo.m_Water, "HUD_Hydration", ref num, -1f); } if (consumableInfo.m_AddEnergy > 0f) { this.SetupEffect("Energy_icon", Color.white, consumableInfo.m_AddEnergy, "HUD_Energy", ref num, -1f); } if ((float)consumableInfo.m_SanityChange > 0f) { this.SetupEffect("Default_Pickup", Color.white, (float)consumableInfo.m_SanityChange, "HUD_Sanity", ref num, -1f); } if (consumableInfo.m_ConsumeEffect == ConsumeEffect.FoodPoisoning) { this.SetupEffect("Vomit_icon_H", Color.white, (float)consumableInfo.m_ConsumeEffectLevel, "HUD_FoodPoisoning", ref num, -1f); } } } else if (item.m_Info.IsLiquidContainer()) { LiquidContainerInfo liquidContainerInfo = (LiquidContainerInfo)item.m_Info; if (liquidContainerInfo.m_Amount > 0f) { LiquidData liquidData = LiquidManager.Get().GetLiquidData(liquidContainerInfo.m_LiquidType); if (liquidContainerInfo.m_Amount > 0f) { this.SetupEffect("Watch_water_icon", IconColors.GetColor(IconColors.Icon.Hydration), liquidContainerInfo.m_Amount, "HUD_Hydration", ref num, liquidContainerInfo.m_Capacity); } if (liquidData.m_Energy > 0f) { this.SetupEffect("Energy_icon", Color.white, liquidData.m_Energy, "HUD_Energy", ref num, -1f); } if (liquidData.m_ConsumeEffect == ConsumeEffect.FoodPoisoning) { this.SetupEffect("Vomit_icon_H", Color.white, (float)liquidData.m_ConsumeEffectLevel, "HUD_FoodPoisoning", ref num, -1f); } } this.m_UnknownEffect.SetActive(num == 0); } for (int i = num; i < this.m_EffectsData.Count; i++) { this.m_EffectsData[i].m_Parent.SetActive(false); } this.m_ConsumableEffects.gameObject.SetActive(true); }
// While hovering over a food, show food's consumable effects // Code below is mostly copy&pasted from original implementation protected override void SetupConsumableEffects() { if (!m_ConsumableEffects) { return; } if (IsExpanded()) { m_ConsumableEffects.gameObject.SetActive(false); } else { Trigger trigger = GetTrigger(); ItemInfo m_Info = null; if (trigger) { if (trigger.IsItem()) { m_Info = ((Item)trigger).m_Info; } else if (trigger is PlantFruit) { m_Info = ((PlantFruit)trigger).m_ItemInfo; } else if (trigger is ItemReplacer) { m_Info = ((ItemReplacer)trigger).m_ReplaceInfo; } } if (m_Info == null) { m_ConsumableEffects.gameObject.SetActive(false); } else { if (!m_Info.IsConsumable() && !m_Info.IsLiquidContainer()) { m_ConsumableEffects.gameObject.SetActive(false); } else { int index1 = 0; if (m_Info.IsConsumable()) { if (!ItemsManager.Get().WasConsumed(m_Info.m_ID)) { m_UnknownEffect.SetActive(true); } else { m_UnknownEffect.SetActive(false); ConsumableInfo info = (ConsumableInfo)m_Info; if (info.m_Proteins > 0.0) { SetupEffect("Watch_protein_icon", IconColors.GetColor(IconColors.Icon.Proteins), info.m_Proteins, "HUD_Nutrition_Protein", ref index1, -1f); } if (info.m_Fat > 0.0) { SetupEffect("Watch_fat_icon", IconColors.GetColor(IconColors.Icon.Fat), info.m_Fat, "HUD_Nutrition_Fat", ref index1, -1f); } if (info.m_Carbohydrates > 0.0) { SetupEffect("Watch_carbo_icon", IconColors.GetColor(IconColors.Icon.Carbo), info.m_Carbohydrates, "HUD_Nutrition_Carbo", ref index1, -1f); } if (info.m_Water > 0.0) { SetupEffect("Watch_water_icon", IconColors.GetColor(IconColors.Icon.Hydration), info.m_Water, "HUD_Hydration", ref index1, -1f); } if (info.m_Dehydration > 0.0) { SetupEffect("Watch_water_icon", IconColors.GetColor(IconColors.Icon.Hydration), -1f * info.m_Dehydration, "HUD_Hydration", ref index1, -1f); } if (info.m_AddEnergy > 0.0) { SetupEffect("Energy_icon", Color.white, info.m_AddEnergy, "HUD_Energy", ref index1, -1f); } if (info.m_SanityChange != 0.0) { SetupEffect("sanity_icon_H", Color.white, info.m_SanityChange, "HUD_Sanity", ref index1, -1f); } if (info.m_ConsumeEffect == ConsumeEffect.Fever) { SetupEffect("Fever_icon_T", Color.white, info.m_ConsumeEffectLevel, "Fever", ref index1, -1f); } if (info.m_ConsumeEffect == ConsumeEffect.FoodPoisoning) { SetupEffect("Vomit_icon_H", Color.white, info.m_ConsumeEffectLevel, "HUD_FoodPoisoning", ref index1, -1f); } else if (info.m_ConsumeEffect == ConsumeEffect.ParasiteSickness) { SetupEffect("ParasiteSichness_icon_H", Color.white, info.m_ConsumeEffectLevel, "HUD_ParasiteSickness", ref index1, -1f); } } } else if (m_Info.IsLiquidContainer()) { LiquidContainerInfo info = (LiquidContainerInfo)m_Info; if (info.m_Amount > 0.0) { LiquidData liquidData = LiquidManager.Get().GetLiquidData(info.m_LiquidType); if (info.m_Amount >= 1.0) { SetupEffect("Watch_water_icon", IconColors.GetColor(IconColors.Icon.Hydration), info.m_Amount, "HUD_Hydration", ref index1, info.m_Capacity); } if (liquidData.m_Energy > 0.0) { SetupEffect("Energy_icon", Color.white, liquidData.m_Energy, "HUD_Energy", ref index1, -1f); } for (int index2 = 0; index2 < liquidData.m_ConsumeEffects.Count; ++index2) { if (liquidData.m_ConsumeEffects[index2].m_ConsumeEffect == ConsumeEffect.FoodPoisoning) { SetupEffect("Vomit_icon_H", Color.white, liquidData.m_ConsumeEffects[index2].m_ConsumeEffectLevel, "HUD_FoodPoisoning", ref index1, -1f); } else if (liquidData.m_ConsumeEffects[index2].m_ConsumeEffect == ConsumeEffect.Fever) { SetupEffect("Fever_icon_T", Color.white, liquidData.m_ConsumeEffects[index2].m_ConsumeEffectLevel, "Fever", ref index1, -1f); } else if (liquidData.m_ConsumeEffects[index2].m_ConsumeEffect == ConsumeEffect.ParasiteSickness) { SetupEffect("ParasiteSichness_icon_H", Color.white, liquidData.m_ConsumeEffects[index2].m_ConsumeEffectLevel, "Parasite Sickness", ref index1, -1f); } } if (info.IsBowl()) { if (liquidData.m_Proteins > 0.0) { SetupEffect("Watch_protein_icon", IconColors.GetColor(IconColors.Icon.Proteins), liquidData.m_Proteins, "HUD_Nutrition_Protein", ref index1, -1f); } if (liquidData.m_Fat > 0.0) { SetupEffect("Watch_fat_icon", IconColors.GetColor(IconColors.Icon.Fat), liquidData.m_Fat, "HUD_Nutrition_Fat", ref index1, -1f); } if (liquidData.m_Carbohydrates > 0.0) { SetupEffect("Watch_carbo_icon", IconColors.GetColor(IconColors.Icon.Carbo), liquidData.m_Carbohydrates, "HUD_Nutrition_Carbo", ref index1, -1f); } if (liquidData.m_Dehydration > 0.0) { SetupEffect("Watch_water_icon", IconColors.GetColor(IconColors.Icon.Hydration), -1f * liquidData.m_Dehydration, "HUD_Hydration", ref index1, -1f); } if (liquidData.m_SanityChange != 0) { SetupEffect("sanity_icon_H", Color.white, liquidData.m_SanityChange, "HUD_Sanity", ref index1, -1f); } } } m_UnknownEffect.SetActive(index1 == 0); } for (int index2 = index1; index2 < m_EffectsData.Count; ++index2) { m_EffectsData[index2].m_Parent.SetActive(false); } m_ConsumableEffects.gameObject.SetActive(true); } } } }