Beispiel #1
0
            public CampsiteUI_ResourceItemUI GetInstance()
            {
                CampsiteUI_ResourceItemUI instance = null;

                if (mCachedInstances != null)
                {
                    while ((instance == null || instance.Equals(null)) && mCachedInstances.Count > 0)
                    {
                        instance = mCachedInstances.Dequeue();
                    }
                }
                if (instance == null || instance.Equals(null))
                {
                    instance = Instantiate <CampsiteUI_ResourceItemUI>(m_ResourceItemUI);
                }
                Transform t0 = m_ResourceItemUI.transform;
                Transform t1 = instance.transform;

                t1.SetParent(t0.parent);
                t1.localPosition = t0.localPosition;
                t1.localRotation = t0.localRotation;
                t1.localScale    = t0.localScale;
                t1.SetSiblingIndex(t0.GetSiblingIndex() + 1);
                return(instance);
            }
Beispiel #2
0
 public bool CacheInstance(CampsiteUI_ResourceItemUI instance)
 {
     if (instance == null || instance.Equals(null))
     {
         return(false);
     }
     if (mCachedInstances == null)
     {
         mCachedInstances = new Queue <CampsiteUI_ResourceItemUI>();
     }
     if (mCachedInstances.Contains(instance))
     {
         return(false);
     }
     instance.gameObject.SetActive(false);
     mCachedInstances.Enqueue(instance);
     return(true);
 }
Beispiel #3
0
        private void FreshNodeInfo()
        {
            string[] curConsume = Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.CAMP_NPC_DAY_COST).contents;
            string   maxDayStr  = Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.CAMP_NPC_MAX_STORE_DAY).content;
            double   maxDayD    = double.Parse(maxDayStr);
            int      curId      = 0;
            SortedDictionary <int, double> maxCousumeCountMap = new SortedDictionary <int, double>();
            Dictionary <string, ItemDTO>   npcMap             = m_NpcMgr.NpcMap;
            double totlaNpcNum         = 0;
            double totalNotFreshNpcNum = 0;

            foreach (KeyValuePair <string, ItemDTO> kvValue in npcMap)
            {
                totlaNpcNum += kvValue.Value.num;
                ItemItem    itemCfg = Global.gApp.gGameData.ItemData.Get(kvValue.Value.itemId);
                CampNpcItem cfg     = Global.gApp.gGameData.CampNpcConfig.Get(itemCfg.name);
                if (cfg.notFresh == 1)
                {
                    totalNotFreshNpcNum += kvValue.Value.num;
                }
            }
            for (int i = 0; i < curConsume.Length; i += 2)
            {
                curId = int.Parse(curConsume[i]);
                double curMat = totlaNpcNum * double.Parse(curConsume[i + 1]) * maxDayD;
                maxCousumeCountMap[curId] = curMat;
            }

            // npc人数
            CurNpcNum.text.text = ((int)totlaNpcNum).ToString();
            string[] maxNpcNum = Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.CAMP_MAX_NUM).contents;

            int campLv = m_NpcMgr.CalCampLevel();

            MaxNpcNum.text.text = (int.Parse(maxNpcNum[2 * campLv - 1]) + Global.gApp.gGameData.NotFreshNpcList.Count).ToString();

            FreshBuild();
            FreshCakeBuild();
            FreshCampLvState();
            FreshRecycleAndResState();
            FreshTaskIconState();
            string[] levelNames = Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.CAMP_LEVELS).contents;
            CampName.text.text = Global.gApp.gGameData.GetTipsInCurLanguage(int.Parse(levelNames[campLv - 1]));



            double totalCount    = 0d;
            double totalMaxCount = 0d;

            ResourceItemUI.gameObject.SetActive(false);
            ClearResourceList();
            foreach (int id in maxCousumeCountMap.Keys)
            {
                double curV = GameItemFactory.GetInstance().GetItem(id);
                double maxV = maxCousumeCountMap[id];
                totalCount    += curV;
                totalMaxCount += maxV;
                ItemItem itemCfg = Global.gApp.gGameData.ItemData.Get(id);

                CampsiteUI_ResourceItemUI itemUI = ResourceItemUI.GetInstance();
                itemUI.gameObject.SetActive(true);
                itemUI.Materials.image.sprite = Global.gApp.gResMgr.LoadAssets <Sprite>(itemCfg.image_grow);
                itemUI.Amount.text.text       = System.Math.Ceiling(curV).ToString("0.##") + "/" + System.Math.Ceiling(maxV).ToString("0.##");
                itemUI.transform.SetSiblingIndex(id);

                m_ResourceItemList.Add(itemUI);
            }

            int index = -1;

            if (totalMaxCount > 0)
            {
                double   rata       = (totalCount / (totalMaxCount)) * 100;
                string[] stateJudge = Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.CAMP_NPC_HEATH_DEFINITION).contents;
                for (int i = 0; i < stateJudge.Length; i++)
                {
                    if (rata <= double.Parse(stateJudge[i]))
                    {
                        index = i;
                        break;
                    }
                }
                if (index < 0)
                {
                    index = stateJudge.Length;
                }
            }
            else
            {
                index = 0;
            }
            string[] stateIds = Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.CAMP_NPC_HEATH_NAME).contents;
            CmpState.text.text = Global.gApp.gGameData.GetTipsInCurLanguage(int.Parse(stateIds[index]));
            if (index == 0)
            {
                CmpState.text.color = new Color(255.0f / 255, 39.0f / 255, 39.0f / 255);
            }
            else if (index == 1)
            {
                CmpState.text.color = new Color(255.0f / 255, 234.0f / 255, 99.0f / 255);
            }
            else if (index == 2)
            {
                CmpState.text.color = new Color(183.0f / 255, 245.0f / 255, 60.0f / 255);
            }
        }