public void Setup(ISettler settler, GameObject settlerScreen) { if (settler == null) { Debug.LogWarning("Settler cannot be null!"); return; } else if (settlerScreen == null) { Debug.LogWarning("SettlerScreen cannot be null!"); return; } if (s_count % 2 == 0) { gameObject.GetComponent <Image>().color = backgroundAColor; m_baseColor = backgroundAColor; } else { gameObject.GetComponent <Image>().color = backgroundBColor; m_baseColor = backgroundBColor; } m_settler = settler; name.text = settler.GetName(); settlerPortrait.sprite = M_SettlersManager.SGetPortrait(settler.GetPortraitId()); m_settlerScreen = settlerScreen; s_count++; }
public void Setup(ISettler settler, GameObject settlerScreen) { if (s_counter % 2 == 0) { gameObject.GetComponent <Image>().color = colorRowA; } else { gameObject.GetComponent <Image>().color = colorRowB; } m_settler = settler; m_settlerScreen = settlerScreen; name.text = settler.GetName(); moodSlider.value = settler.GetMood(); settlerPortrait.sprite = M_SettlersManager.SGetPortrait(settler.GetPortraitId()); infoButton.onClick.AddListener(OnClickInfo); s_counter++; }
public void ShowSettler(ISettler settler) { if (settler == null) { Debug.LogWarning(typeof(ISettler).Name + " cannot be null!"); M_ScreenManager.SPreviousScreen(); return; } m_settler = settler; settlerName.text = settler.GetName(); settlerUpkeep.text = settler.GetUpkeep().ToString(); settlerMood.value = settler.GetMood(); moodValue.text = string.Format("{0}%", settler.GetMood()); // Preferences List <GameObject> favBuildings = new List <GameObject>(); foreach (FavoriteBuilding favoriteBuilding in settler.GetFavoriteBuildings()) { GameObject obj = Instantiate(favoriteThingRowElementPrefab); if (favoriteBuilding.active) { obj.GetComponent <Image>().color = elemBgHighlightColor; } obj.GetComponentInChildren <TMP_Text>().text = M_BuildingManager.SGetDatBuilding(favoriteBuilding.buildingTemplId).name; obj.GetComponentInChildren <Slider>().value = favoriteBuilding.maxMood; favBuildings.Add(obj); } List <GameObject> favWares = new List <GameObject>(); foreach (FavoriteWare favoriteWare in settler.GetFavoriteWares()) { GameObject obj = Instantiate(favoriteThingRowElementPrefab); if (favoriteWare.active) { obj.GetComponent <Image>().color = elemBgHighlightColor; } obj.GetComponentInChildren <TMP_Text>().text = favoriteWare.ware.ToString(); obj.GetComponentInChildren <Slider>().value = favoriteWare.mood; favWares.Add(obj); } GUIUtils.AddElementsToCleanYScrollContainer(favoriteBuildingsContainer, favBuildings); GUIUtils.AddElementsToCleanYScrollContainer(favoriteWaresContainer, favWares); preferencesSubPage.SetActive(false); settlerPortrait.sprite = M_SettlersManager.SGetPortrait(settler.GetPortraitId()); if (settler.GetWorkplace() != System.Guid.Empty) { workplaceButton.image.sprite = M_BuildingManager.SGetBuilding(settler.GetWorkplace()).GetIcon(); } else { workplaceButton.image.sprite = spriteWhenNoWorkplace; } if (settler.GetHouse() != System.Guid.Empty) { homeButton.image.sprite = M_BuildingManager.SGetBuilding(settler.GetHouse()).GetIcon(); } else { homeButton.image.sprite = spriteWhenNoWorkplace; } M_ScreenManager.SChangeScreenPersistentBack(this.gameObject); }