Ejemplo n.º 1
0
            public CampBUFF_ItemBig GetInstance()
            {
                CampBUFF_ItemBig 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 <CampBUFF_ItemBig>(m_ItemBig);
                }
                Transform t0 = m_ItemBig.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);
            }
Ejemplo n.º 2
0
 public bool CacheInstance(CampBUFF_ItemBig instance)
 {
     if (instance == null || instance.Equals(null))
     {
         return(false);
     }
     if (mCachedInstances == null)
     {
         mCachedInstances = new Queue <CampBUFF_ItemBig>();
     }
     if (mCachedInstances.Contains(instance))
     {
         return(false);
     }
     instance.gameObject.SetActive(false);
     mCachedInstances.Enqueue(instance);
     return(true);
 }
Ejemplo n.º 3
0
        private void InitNode()
        {
            ItemBig.gameObject.SetActive(false);
            ItemSmall.gameObject.SetActive(false);
            TopItemDetail.gameObject.SetActive(false);
            ItemDetail.gameObject.SetActive(false);
            maskBtn.gameObject.SetActive(true);

            int totalNum = Global.gApp.gSystemMgr.GetNpcMgr().GetTotalNum();

            m_CampLevel = Global.gApp.gGameData.GetCampLevel(totalNum);

            //营地技能初始化
            for (int i = 0; i < Global.gApp.gGameData.CampBuffConfig.items.Length; i++)
            {
                CampBuffItem cbi = Global.gApp.gGameData.CampBuffConfig.items[i];

                RectTransform_Image_Container titleLockIcon = ReflectionUtil.GetValueByProperty <CampBUFF, RectTransform_Image_Container>("lock" + cbi.campLevel, this);
                titleLockIcon.gameObject.SetActive(m_CampLevel < cbi.campLevel);

                SkillItemDTO dto;
                Global.gApp.gSystemMgr.GetNpcMgr().CampBuffMap.TryGetValue(cbi.id, out dto);
                RectTransform_Button_Image_Container con = ReflectionUtil.GetValueByProperty <CampBUFF, RectTransform_Button_Image_Container>(cbi.id, this);
                RectTransform rt;
                bool          lockBuff = Global.gApp.gSystemMgr.GetNpcMgr().LockBuff(dto);
                if (i == 0)
                {
                    CampBUFF_ItemBig item = ItemBig.GetInstance();
                    item.gameObject.SetActive(true);
                    item.rectTransform().SetParent(con.rectTransform);
                    item.rectTransform().offsetMax = new Vector2(0, 0);
                    item.rectTransform().offsetMin = new Vector2(0, 0);

                    CampBUFF_TopItemDetail itemDetail   = TopItemDetail.GetInstance();
                    itemDetail.rectTransform().position = new Vector3(item.rectTransform().position.x, con.rectTransform.position.y + 1.5f, item.rectTransform().position.z);

                    TopName.text.text         = Global.gApp.gGameData.GetTipsInCurLanguage(cbi.name);
                    itemDetail.name.text.text = Global.gApp.gGameData.GetTipsInCurLanguage(cbi.name);

                    item.goods.image.sprite      = Global.gApp.gResMgr.LoadAssets <Sprite>(cbi.icon);
                    itemDetail.Icon.image.sprite = Global.gApp.gResMgr.LoadAssets <Sprite>(cbi.icon);
                    item.level.text.text         = dto.level.ToString();
                    itemDetail.level.text.text   = dto.level.ToString();
                    item.lockIcon.gameObject.SetActive(lockBuff);
                    CampBuff_dataItem curData;
                    CampBuff_dataItem nextData;
                    string            curPercent;
                    if (dto.level < Global.gApp.gGameData.CampBuffDataConfig.items.Length)
                    {
                        curData    = Global.gApp.gGameData.CampBuffDataConfig.items[dto.level - 1];
                        nextData   = Global.gApp.gGameData.CampBuffDataConfig.items[dto.level];
                        curPercent = GetPercentStr(cbi, curData.buff_atkNpc[0]);
                        string nextPercent = GetPercentStr(cbi, nextData.buff_atkNpc[0]);
                        //item.desc.text.text = string.Format(Global.gApp.gGameData.GetTipsInCurLanguage(cbi.desc), curPercent, nextPercent);
                        itemDetail.desc.text.text = string.Format(Global.gApp.gGameData.GetTipsInCurLanguage(cbi.desc), curPercent, nextPercent);
                    }
                    else
                    {
                        curData    = Global.gApp.gGameData.CampBuffDataConfig.items[dto.level - 2];
                        nextData   = Global.gApp.gGameData.CampBuffDataConfig.items[dto.level - 1];
                        curPercent = GetPercentStr(cbi, nextData.buff_atkNpc[0]);
                        //item.desc.text.text = string.Format(Global.gApp.gGameData.GetTipsInCurLanguage(cbi.max_desc), curPercent);
                        itemDetail.desc.text.text = string.Format(Global.gApp.gGameData.GetTipsInCurLanguage(cbi.max_desc), curPercent);
                    }

                    float min            = dto.level == 1 ? 0 : Global.gApp.gGameData.CampBuffDataConfig.items[dto.level - 2].buff_atkNpc_cost[0];
                    float max            = Global.gApp.gGameData.CampBuffDataConfig.items[dto.level - 1].buff_atkNpc_cost[0];
                    int   ignoreTotalNum = Global.gApp.gSystemMgr.GetNpcMgr().GetTotalNum(true);
                    item.CurText.text.text         = (ignoreTotalNum).ToString();
                    item.MaxText.text.text         = "/" + max.ToString();
                    item.Progress.image.fillAmount = (ignoreTotalNum) / (max);
                    item.AddText.text.text         = curPercent;

                    item.NormalLevel.gameObject.SetActive(dto.level < Global.gApp.gGameData.CampBuffDataConfig.items.Length);
                    item.MaxLevel.gameObject.SetActive(dto.level == Global.gApp.gGameData.CampBuffDataConfig.items.Length);

                    rt = itemDetail.rectTransform();
                }
                else
                {
                    CampBUFF_ItemSmall item = ItemSmall.GetInstance();
                    item.gameObject.SetActive(true);
                    item.rectTransform().SetParent(con.rectTransform);
                    item.rectTransform().offsetMax        = new Vector2(0, 0);
                    item.rectTransform().offsetMin        = new Vector2(0, 0);
                    CampBUFF_ItemDetail itemDetail        = ItemDetail.GetInstance();
                    itemDetail.rectTransform().localScale = new Vector3(1, 1, 1);
                    itemDetail.gameObject.SetActive(true);
                    itemDetail.rectTransform().position = new Vector3(item.rectTransform().position.x, con.rectTransform.position.y + 1.5f, item.rectTransform().position.z);

                    FreshItem(cbi, dto, lockBuff, item, itemDetail);
                    itemDetail.Button.button.onClick.AddListener(() =>
                    {
                        ItemDTO reduceItemDTO;
                        if (dto.level == 0)
                        {
                            reduceItemDTO = new ItemDTO(SpecialItemIdConstVal.RED_HEART, cbi.unlockCost, BehaviorTypeConstVal.OPT_CAMP_BUFF_UNLOCK);
                        }
                        else
                        {
                            CampBuff_dataItem curData = Global.gApp.gGameData.CampBuffDataConfig.items[dto.level - 1];
                            float[] cost            = ReflectionUtil.GetValueByProperty <CampBuff_dataItem, float[]>(cbi.id + "_cost", curData);
                            reduceItemDTO           = new ItemDTO(SpecialItemIdConstVal.RED_HEART, cost[0], BehaviorTypeConstVal.OPT_CAMP_BUFF_UPGRADE);
                            reduceItemDTO.paramStr2 = dto.level.ToString();
                        }
                        reduceItemDTO.paramStr1 = cbi.id;
                        GameItemFactory.GetInstance().ReduceItem(reduceItemDTO);
                        if (!reduceItemDTO.result)
                        {
                            ItemItem reduceItemCfg = Global.gApp.gGameData.ItemData.Get(reduceItemDTO.itemId);
                            Global.gApp.gMsgDispatcher.Broadcast <int, string>(MsgIds.ShowGameTipsByIDAndParam, 1008, Global.gApp.gGameData.GetTipsInCurLanguage(reduceItemCfg.sourceLanguage));
                        }
                        else
                        {
                            dto.level++;
                            Global.gApp.gSystemMgr.GetNpcMgr().SaveData();
                            lockBuff = Global.gApp.gSystemMgr.GetNpcMgr().LockBuff(dto);
                            FreshItem(cbi, dto, lockBuff, item, itemDetail);

                            GameObject effect         = UiTools.GetEffect(EffectConfig.Camp_buff_up, item.rectTransform());
                            effect.transform.position = item.rectTransform().position;
                        }
                    });


                    Debug.Log(cbi.id + "|" + lockBuff);
                    rt = itemDetail.rectTransform();
                }
                rt.gameObject.SetActive(false);
                con.button.onClick.AddListener(() =>
                {
                    CloseDetail();
                    rt.gameObject.SetActive(true);
                    rt.position = new Vector3(rt.position.x, con.rectTransform.position.y + 1.5f, rt.position.z);
                    m_HaveTip   = true;
                    m_CurY      = -100;
                });
            }
            //Content.rectTransform.position = new Vector3(Content.rectTransform.position.x, 0f, Content.rectTransform.position.z);
            maskBtn.button.onClick.AddListener(CloseDetail);
            CloseBtn.button.onClick.AddListener(TouchClose);
        }