示例#1
0
    private void checkHRLists()
    {
        //print ("i am in check list");
        //print ("m_buildings.Count:"+m_buildings.Count);
        //get the transform of "BigDig_for_Evelyn"
        Transform hr       = GameObject.Find("HRBuildings").transform;
        int       children = hr.childCount;

        //loop to inverse every child node under this parent node
        for (int i = 0; i < children; i++)
        {
            //get the dates info from attached HRBuildingBase
            Transform      sub         = hr.GetChild(i).transform;
            HRBuildingBase currentBase = sub.GetComponent("HRBuildingBase") as HRBuildingBase;
            int            subchildren = sub.childCount;
            int            by          = currentBase.BirthYear;
            int            dy          = currentBase.DeathYear;
            switch (currentBase.Status)
            {
            case -1:
                if (TimeManager.Instance.Year >= by && TimeManager.Instance.Year <= dy)
                {
                    for (int j = 0; j < subchildren; j++)
                    {
                        sub.GetChild(j).gameObject.SetActive(true);
                    }
                    currentBase.Status = 0;
                }
                else if (TimeManager.Instance.Year > dy)
                {
                    currentBase.Status = 1;
                }
                else if (TimeManager.Instance.Year < by)
                {
                }
                break;

            case 0:
                if (TimeManager.Instance.Year > dy)
                {
                    for (int j = 0; j < subchildren; j++)
                    {
                        sub.GetChild(j).gameObject.SetActive(false);
                    }
                    currentBase.Status = 1;
                }

                break;

            case 1:
                break;
            }
        }
    }
示例#2
0
    private void checkReset(bool b)
    {
        if (b)
        {
            Transform hr       = GameObject.Find("HRBuildings").transform;
            int       children = hr.childCount;
            //loop to inverse every child node under this parent node
            for (int i = 0; i < children; i++)
            {
                Transform      sub         = hr.GetChild(i).transform;
                HRBuildingBase currentBase = sub.GetComponent("HRBuildingBase") as HRBuildingBase;
                currentBase.Status = -1;
                int subchildren = sub.childCount;
                for (int j = 0; j < subchildren; j++)
                {
                    sub.GetChild(j).gameObject.SetActive(false);
                }
            }

            needToResetStatus = false;
        }
    }