示例#1
0
 bool ShowFarmUI(KeyValuePair <long, HomeDataManager.HomeEntityInfo> info, Vector3 enpos)
 {
     HomeDataManager.HomeEntityInfo ei = info.Value;
     if (ei.type == EntityType.EntityType_Soil)//土地
     {
         IEntity en = es.FindEntity(info.Key);
         if (en != null)
         {
             if (uiDic.ContainsKey(en.GetUID()))
             {
                 GameObject go = uiDic[en.GetUID()];
                 if (go != null)
                 {
                     RefreshFarmState(go, ei);
                     return(false);
                 }
             }
             GameObject ui = GetUIGameObejct(enpos);
             if (ui)
             {
                 RefreshFarmState(ui, ei);
                 uiDic.Add(en.GetUID(), ui);
             }
         }
     }
     return(true);
 }
示例#2
0
    public void ReleaseUI()
    {
        foreach (var dic in uiDic)
        {
            long uid = dic.Key;

            if (homeDM.EntityStateDic.ContainsKey(uid))
            {
                HomeDataManager.HomeEntityInfo info = homeDM.EntityStateDic[uid];
                if (info.type == EntityType.EntityType_Soil)
                {
                    RetrunUIGameObject(dic.Value);
                }
                else if (info.type == EntityType.EntityType_Animal)
                {
                    RetrunUIAnimalGameObject(dic.Value);
                }
                else if (info.type == EntityType.EntityType_Tree)
                {
                    RetrunUITreeGameObject(dic.Value);
                }
            }
        }
        uiDic.Clear();
        gameObject.SetActive(false);
    }
示例#3
0
    void RefreshTreeState(GameObject go, HomeDataManager.HomeEntityInfo ei)
    {
        TreeState ts = go.GetComponent <TreeState>();

        if (ts == null)
        {
            ts = go.AddComponent <TreeState>();
            go.SetActive(false);
        }
        TreeData td = DataManager.Manager <HomeDataManager>().GetTreeData();

        if (td != null)
        {
            ts.Init();
        }
    }
示例#4
0
    void RefreshFarmState(GameObject go, HomeDataManager.HomeEntityInfo ei)
    {
        FarmState fs = go.GetComponent <FarmState>();

        if (fs == null)
        {
            fs = go.AddComponent <FarmState>();
            go.SetActive(false);
        }
        if (fs != null)
        {
            fs.InitIndex(ei.index);
        }
        if (ei.state == (int)HomeDataManager.LandState.Idle)
        {
            fs.gameObject.SetActive(false);
            if (homeDM.CanGetLeftTime(ei.index))
            {
                fs.Init(homeDM.GetLeftTimeByIndex(ei.index), ei.index);
            }
            else
            {
                fs.ShowUIByState(HomeDataManager.CreatureSmallState.None);
            }
        }
        else if (ei.state == (int)HomeDataManager.LandState.LockCanBuy)
        {
            if (ei.index == homeDM.LandUnlockNum + 1)
            {
                fs.gameObject.SetActive(true);
                fs.ShowLandState();
            }
        }
        else if (ei.state == (int)HomeDataManager.LandState.CanGain)
        {
            fs.ShowUIByState(HomeDataManager.CreatureSmallState.CanGain);
        }
        else if (ei.state == (int)HomeDataManager.LandState.Growing)
        {
            fs.ShowUIByState(HomeDataManager.CreatureSmallState.Seeding);
        }
    }
示例#5
0
    void RefreshAnimalState(GameObject go, HomeDataManager.HomeEntityInfo ei)
    {
        AnimalState fs = go.GetComponent <AnimalState>();

        if (fs == null)
        {
            fs = go.AddComponent <AnimalState>();
            go.SetActive(false);
        }
        if (fs != null)
        {
            fs.InitIndex(ei.index);
        }

        fs.gameObject.SetActive(true);
        if (homeDM.CanGetLeftTime(ei.index))
        {
            fs.Init(homeDM.GetLeftTimeByIndex(ei.index), ei.index, ei.state);
        }
    }