Beispiel #1
0
 public void OnClickHome()
 {
     if (m_settler.GetHouse() != null)
     {
         UI_ScreenBuilding.SShowStats(M_BuildingManager.SGetBuilding(m_settler.GetHouse()));
     }
 }
Beispiel #2
0
    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);
    }