Ejemplo n.º 1
0
    void UpdateAnimalGridList()
    {
        if (this.gameObject.activeSelf == false)
        {
            return;
        }

        List <LandAndFarmDataBase> landList = GameTableManager.Instance.GetTableList <LandAndFarmDataBase>();

        uint animalID = DataManager.Manager <HomeDataManager>().animalID;

        landList = landList.FindAll((LandAndFarmDataBase ld) => { return(ld.dwID == animalID); });

        for (int i = 0; i < m_grid_grid.transform.childCount; i++)
        {
            UIHomeAnimalGrid homeAnimalGrid = m_grid_grid.GetChild(i).GetComponent <UIHomeAnimalGrid>();
            if (homeAnimalGrid == null)
            {
                homeAnimalGrid = m_grid_grid.GetChild(i).gameObject.AddComponent <UIHomeAnimalGrid>();
            }

            if (landList[i] != null)
            {
                homeAnimalGrid.Init(landList[i].indexID);
            }
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 初始化界面
    /// </summary>
    void Init()
    {
        if (m_grid_grid.transform.childCount > 0)
        {
            UpdateAnimalGridList();
            return;
        }

        List <LandAndFarmDataBase> landList = GameTableManager.Instance.GetTableList <LandAndFarmDataBase>();

        uint animalID = DataManager.Manager <HomeDataManager>().animalID;

        landList = landList.FindAll((LandAndFarmDataBase ld) => { return(ld.dwID == animalID); });

        for (int i = 0; i < landList.Count; i++)
        {
            UnityEngine.GameObject obj = UIManager.GetResGameObj(GridID.Uihomeanimalgrid) as UnityEngine.GameObject;
            obj = Instantiate(obj);

            obj.transform.parent        = m_grid_grid.transform;
            obj.transform.localPosition = Vector3.zero;
            obj.transform.localScale    = Vector3.one;
            obj.transform.localRotation = Quaternion.identity;

            UIHomeAnimalGrid homeAnimalGrid = obj.GetComponent <UIHomeAnimalGrid>();
            if (homeAnimalGrid == null)
            {
                homeAnimalGrid = obj.AddComponent <UIHomeAnimalGrid>();
            }

            obj.SetActive(true);
            homeAnimalGrid.Init(landList[i].indexID);
        }

        m_grid_grid.Reposition();
    }