Beispiel #1
0
    public void HandlePacket(GC_UPDATE_COST_REBATE_INFO packet)
    {
        m_bCostRebateOpen = (packet.Isopen == 1)?true:false;
        m_nStartTime      = packet.Start;
        m_nEndTime        = packet.End;
        m_nCostType       = packet.Costtype;
        if (m_CostRebateDataList == null)
        {
            m_CostRebateDataList = new List <Tab_LevelAwardSimulate>();
        }
        int count = packet.costlimitCount;

        for (int index = 0; index < count; ++index)
        {
            if (m_CostRebateDataList.Count > index)
            {
                if (m_CostRebateDataList[index] != null)
                {
                    m_CostRebateDataList[index].SetInfo(
                        index, (int)ActivityRewardType.Cost, 0, 0, packet.GetCostlimit(index),
                        new int[] { packet.GetId1(index), packet.GetId2(index), packet.GetId3(index) },
                        new int[] { packet.GetNum1(index), packet.GetNum2(index), packet.GetNum3(index), }
                        );
                }
                else
                {
                    Tab_LevelAwardSimulate lap = new Tab_LevelAwardSimulate(
                        index, (int)ActivityRewardType.Cost, 0, 0, packet.GetCostlimit(index),
                        new int[] { packet.GetId1(index), packet.GetId2(index), packet.GetId3(index) },
                        new int[] { packet.GetNum1(index), packet.GetNum2(index), packet.GetNum3(index), }
                        );
                    m_CostRebateDataList[index] = lap;
                }
            }
            else
            {
                Tab_LevelAwardSimulate lap = new Tab_LevelAwardSimulate(
                    index, (int)ActivityRewardType.Cost, 0, 0, packet.GetCostlimit(index),
                    new int[] { packet.GetId1(index), packet.GetId2(index), packet.GetId3(index) },
                    new int[] { packet.GetNum1(index), packet.GetNum2(index), packet.GetNum3(index), }
                    );

                m_CostRebateDataList.Add(lap);
            }
        }
        if (m_CostRebateDataList.Count > count)
        {
            m_CostRebateDataList.RemoveRange(count, m_CostRebateDataList.Count - count);
        }

        /*天龙的返利存储服务器推送数据,先注释掉,为适合Cabal的界面
         *      for (int index = 0; index < packet.costlimitCount; index++)
         *      {
         *          m_nRebateLimit[index] = packet.GetCostlimit(index);
         *      }
         *      for (int index = 0; index < packet.id1Count; index++)
         *      {
         *          m_nRebateId1[index] = packet.GetId1(index);
         *      }
         *      for (int index = 0; index < packet.id2Count; index++)
         *      {
         *          m_nRebateId2[index] = packet.GetId2(index);
         *      }
         *      for (int index = 0; index < packet.id3Count; index++)
         *      {
         *          m_nRebateId3[index] = packet.GetId3(index);
         *      }
         *      for (int index = 0; index < packet.num1Count; index++)
         *      {
         *          m_nRebateNum1[index] = packet.GetNum1(index);
         *      }
         *      for (int index = 0; index < packet.num2Count; index++)
         *      {
         *          m_nRebateNum2[index] = packet.GetNum2(index);
         *      }
         *      for (int index = 0; index < packet.num3Count; index++)
         *      {
         *          m_nRebateNum3[index] = packet.GetNum3(index);
         *      }
         */
//           for (int index = 0; index < packet.flagsCount; index++) {
//             m_bRebateFlag[index] = (packet.GetFlags(index) == 1) ? true : false;
//           }
        List <int> alreadyget;

        if (GameManager.gameManager.ActivityRewardGetDic.TryGetValue(ActivityRewardType.Cost, out alreadyget))
        {
            alreadyget.Clear();
            alreadyget.AddRange(packet.flagsList);
        }
        else
        {
            GameManager.gameManager.ActivityRewardGetDic.Add(ActivityRewardType.Cost, new List <int>(packet.flagsList));
        }
//         if (ChargeActivityLogic.Instance())
//         {
//             ChargeActivityLogic.Instance().UpdateCurTab();
//         }
        if (ActivityRewardsController.Instance() != null)
        {
            ActivityRewardsController.Instance().RefreshCostRebate();
        }
    }
    private void SetItemInfo(Transform itemtf, Tab_LevelAwardSimulate data, int index)
    {
        if (itemtf != null && data != null)
        {
            bool      isgray        = false;
            Transform buttontfbc    = itemtf.Find("LingquButton");
            Transform buttontfbg    = itemtf.Find("LingquButton/Background");
            Transform buttontflabel = itemtf.Find("LingquButton/Label0");
            if (buttontfbc != null && buttontfbg != null && buttontflabel != null)
            {
                UIImageButton us = buttontfbc.GetComponent <UIImageButton>();
                UILabel       ul = buttontflabel.GetComponent <UILabel>();
                if (us != null && ul != null)
                {
                    List <int> alreadygetlist;
                    if (GameManager.gameManager.ActivityRewardGetDic.TryGetValue(NowType, out alreadygetlist))
                    {
                        if (alreadygetlist.Count > index && alreadygetlist[index] > 0)
                        {
                            us.isEnabled = false;
                            ul.text      = StrDictionary.GetClientDictionaryString("#{1380}");
                            NGUITools.SetActive(buttontfbg.gameObject, false);
                            isgray = true;
                            SetBackStatu(itemtf, BackState.Gray);
                            itemtf.name = "z" + itemtf.name;
                        }
                        else
                        {
                            us.isEnabled = true;
                            ul.text      = StrDictionary.GetClientDictionaryString("#{1378}");
                            NGUITools.SetActive(buttontfbg.gameObject, true);
                        }
                    }
                    else
                    {
                        us.isEnabled = true;
                        ul.text      = StrDictionary.GetClientDictionaryString("#{1378}");
                        NGUITools.SetActive(buttontfbg.gameObject, true);
                    }
                }
            }
            int counter = 0;
            if (data.Money > 0)
            {
                ++counter;
                Tab_CommonItem cItem = TableManager.GetCommonItemByID(GoldCoinId, 0);
                if (cItem != null)
                {
                    Transform tf = itemtf.Find("IconItem/Grid/Icon_" + counter + "/sprite");
                    if (tf != null)
                    {
                        UISprite us = tf.GetComponent <UISprite>();
                        if (us != null)
                        {
                            us.spriteName = cItem.Icon;
                        }
                    }
                    tf = itemtf.Find("IconItem/Grid/Icon_" + counter + "/BG_2");
                    if (tf != null)
                    {
                        UISprite us = tf.GetComponent <UISprite>();
                        if (us != null)
                        {
                            us.spriteName = Games.GlobeDefine.GlobeVar.QualityColorGrid[cItem.Quality - 1];
                        }
                    }
                    tf = itemtf.Find("IconItem/Grid/Icon_" + counter + "/Label");
                    if (tf != null)
                    {
                        UILabel ul = tf.GetComponent <UILabel>();
                        if (ul != null)
                        {
                            ul.text = "X" + data.Money;
                        }
                    }
                }
            }
            if (data.BindYuanbao > 0)
            {
                ++counter;
                Tab_CommonItem cItem = TableManager.GetCommonItemByID(YuanBaoId, 0);
                if (cItem != null)
                {
                    Transform tf = itemtf.Find("IconItem/Grid/Icon_" + counter + "/sprite");
                    if (tf != null)
                    {
                        UISprite us = tf.GetComponent <UISprite>();
                        if (us != null)
                        {
                            us.spriteName = cItem.Icon;
                        }
                    }
                    tf = itemtf.Find("IconItem/Grid/Icon_" + counter + "/BG_2");
                    if (tf != null)
                    {
                        UISprite us = tf.GetComponent <UISprite>();
                        if (us != null)
                        {
                            us.spriteName = Games.GlobeDefine.GlobeVar.QualityColorGrid[cItem.Quality - 1];
                        }
                    }
                    tf = itemtf.Find("IconItem/Grid/Icon_" + counter + "/Label");
                    if (tf != null)
                    {
                        UILabel ul = tf.GetComponent <UILabel>();
                        if (ul != null)
                        {
                            ul.text = "X" + data.BindYuanbao;
                        }
                    }
                }
            }
            int dataIdCount = data.getItemDataIDCount();
            int dataCount   = data.getItemCountCount();
            if (dataIdCount == dataCount)
            {
                for (int i = 0; i < dataIdCount; ++i)
                {
                    if (data.GetItemDataIDbyIndex(i) > -1 && data.GetItemCountbyIndex(i) > -1)
                    {
                        ++counter;
                        if (counter == 5)
                        {
                            break;
                        }
                        Tab_CommonItem cItem = TableManager.GetCommonItemByID(data.GetItemDataIDbyIndex(i), 0);
                        if (cItem != null)
                        {
                            Transform tf = itemtf.Find("IconItem/Grid/Icon_" + counter + "/sprite");
                            if (tf != null)
                            {
                                UISprite us = tf.GetComponent <UISprite>();
                                if (us != null)
                                {
                                    us.spriteName = cItem.Icon;
                                }
                            }
                            tf = itemtf.Find("IconItem/Grid/Icon_" + counter + "/BG_2");
                            if (tf != null)
                            {
                                UISprite us = tf.GetComponent <UISprite>();
                                if (us != null)
                                {
                                    us.spriteName = Games.GlobeDefine.GlobeVar.QualityColorGrid[cItem.Quality - 1];
                                }
                            }
                            tf = itemtf.Find("IconItem/Grid/Icon_" + counter + "/Label");
                            if (tf != null)
                            {
                                UILabel ul = tf.GetComponent <UILabel>();
                                if (ul != null)
                                {
                                    ul.text = "X" + data.GetItemCountbyIndex(i);
                                }
                            }
                        }
                    }
                }
            }
            for (int i = 1; i < 5; ++i)
            {
                Transform tf = itemtf.Find("IconItem/Grid/Icon_" + i);
                if (tf != null)
                {
                    if (i > counter)
                    {
                        NGUITools.SetActive(tf.gameObject, false);
                    }
                    else
                    {
                        NGUITools.SetActive(tf.gameObject, true);
                    }
                }
            }
            int    left              = 0;
            int    right             = data.Condition;
            string strdicidCondition = "";
            string strdicidPB        = "";
            string path              = "";
            switch ((ActivityRewardType)data.Type)
            {
            case ActivityRewardType.Level:
                strdicidCondition = "#{11333}";
                strdicidPB        = "#{11248}";
                path = "Leijixiaofei/Label_level";
                left = Singleton <ObjManager> .GetInstance().MainPlayer.BaseAttr.Level;

                break;

            case ActivityRewardType.Fight:
                strdicidCondition = "#{11250}";
                strdicidPB        = "#{11251}";
                path = "Leijixiaofei/Label";
                left = Singleton <ObjManager> .GetInstance().MainPlayer.BaseAttr.CombatValue;

                break;

            case ActivityRewardType.Cost:
                strdicidCondition = "#{11253}";
                strdicidPB        = "#{11254}";
                path = "Leijixiaofei/Label_battlecount";
                left = GameManager.gameManager.PlayerDataPool.CommonData.GetCommonData((int)Games.UserCommonData.USER_COMMONDATA.CD_COSTREBATE_VALUE);
                break;

            case ActivityRewardType.TimeLimit:
                break;

            default:
                break;
            }
            Transform tful = itemtf.Find("LingquButton/Label1");
            if (tful != null)
            {
                UILabel ul = tful.GetComponent <UILabel>();
                if (ul != null)
                {
                    ul.text = "" + (left > right ? right : left) + "/" + right;
                    ul.text = StrDictionary.GetClientDictionaryString(strdicidPB, (left > right ? right : left), right);
                }
            }
            tful = itemtf.Find("LingquButton");
            if (tful != null)
            {
                UIImageButton uib = tful.GetComponent <UIImageButton>();
                if (uib != null)
                {
                    if (left < right)
                    {
                        uib.isEnabled = false;
                        SetBackStatu(itemtf, BackState.Normal);
                    }
                    else
                    {
                        uib.isEnabled = true;
                        if (!isgray)
                        {
                            SetBackStatu(itemtf, BackState.Light);
                        }
                    }
                }
            }
            tful = itemtf.Find("Leijixiaofei");
            if (tful != null)
            {
                int count = tful.childCount;
                for (int i = 0; i < count; ++i)
                {
                    Transform tf = tful.GetChild(i);
                    if (tf != null)
                    {
                        tf.gameObject.SetActive(false);
                    }
                }
            }
            tful = itemtf.Find(path);
            if (tful != null)
            {
                tful.gameObject.SetActive(true);
                UILabel ul = tful.GetComponent <UILabel>();
                if (ul != null)
                {
                    ul.text = StrDictionary.GetClientDictionaryString(strdicidCondition, right);
                }
            }
        }
    }