Exemplo n.º 1
0
 /* 神秘商店物品列表返回 */
 private static void msg_SC_SHOP_SECRET_GOODS_ACK(int iMsgID, ref CMessage msg)
 {
     CliProto.SC_SHOP_SECRET_GOODS_ACK refMsg = (CliProto.SC_SHOP_SECRET_GOODS_ACK)msg;
     sdMysteryShopMgr.Instance.m_freeRefreshTime = refMsg.m_FreeRefreshRemainCount;
     sdMysteryShopMgr.Instance.m_nTimeTick       = (long)refMsg.m_RefreshRemainTimeMS / 1000 + System.DateTime.Now.Ticks / 10000000L;
     sdMysteryShopMgr.Instance.m_lstItem.Clear();
     for (int index = 0; index < refMsg.m_ItemCount; ++index)
     {
         CliProto.SSecretItemInfo item = new CliProto.SSecretItemInfo();
         item.m_UID    = refMsg.m_SecretItems[index].m_UID;
         item.m_Bought = refMsg.m_SecretItems[index].m_Bought;
         sdMysteryShopMgr.Instance.m_lstItem.Add(item);
     }
     sdMysteryShopMgr.Instance.Refresh();
 }
Exemplo n.º 2
0
 public void Buy(int index)
 {
     if (index < 0 || index >= m_lstItem.Count)
     {
         return;
     }
     CliProto.SSecretItemInfo item = m_lstItem[index];
     if (item.m_Bought == 1)
     {
         sdUICharacter.Instance.ShowOkMsg("不能重复购买!", null);
     }
     else
     {
         sdMysteryShopMsg.Send_SHOP_SECRET_BUY_REQ(item.m_UID);
     }
 }
Exemplo n.º 3
0
 /* 神秘商店购买物品返回 */
 private static void msg_SC_SHOP_SECRET_BUY_ACK(int iMsgID, ref CMessage msg)
 {
     CliProto.SC_SHOP_SECRET_BUY_ACK refMsg = (CliProto.SC_SHOP_SECRET_BUY_ACK)msg;
     for (int index = 0; index < sdMysteryShopMgr.Instance.m_lstItem.Count; ++index)
     {
         CliProto.SSecretItemInfo item = sdMysteryShopMgr.Instance.m_lstItem[index];
         if (item.m_UID == refMsg.m_UID)
         {
             if (refMsg.m_Result == (byte)HeaderProto.EShopBuyResult.EShopBuyResult_Success)
             {
                 sdUICharacter.Instance.ShowOkMsg("兑换成功!", null);
                 item.m_Bought = 1;
             }
             else if (refMsg.m_Result == (byte)HeaderProto.EShopBuyResult.EShopBuyResult_BagFull)
             {
                 sdUICharacter.Instance.ShowOkMsg("背包已满,无法兑换!", null);
             }
             else if (refMsg.m_Result == (byte)HeaderProto.EShopBuyResult.EShopBuyResult_NoCrystal)
             {
                 sdUICharacter.Instance.ShowOkMsg("神秘水晶不足,无法兑换!", null);
             }
             else if (refMsg.m_Result == (byte)HeaderProto.EShopBuyResult.EShopBuyResult_NoCash)
             {
                 sdUICharacter.Instance.ShowOkMsg("徽章不足,无法兑换", null);
             }
             else if (refMsg.m_Result == (byte)HeaderProto.EShopBuyResult.EShopBuyResult_NoMoney)
             {
                 sdUICharacter.Instance.ShowOkMsg("金钱不足,无法兑换", null);
             }
             else if (refMsg.m_Result == (byte)HeaderProto.EShopBuyResult.EShopBuyResult_Fail)
             {
                 sdUICharacter.Instance.ShowOkMsg("兑换失败!", null);
             }
             break;
         }
     }
     sdMysteryShopMgr.Instance.Refresh();
 }
Exemplo n.º 4
0
    public void Refresh()
    {
        if (this == null)
        {
            return;
        }
        if (sdMysteryShopMgr.Instance.m_freeRefreshTime > 0)
        {
            refresh_type.SetActive(false);
            label_freefreshtime.text = "免费刷新次数:" + sdMysteryShopMgr.Instance.m_freeRefreshTime.ToString() + "次";
        }
        else if (sdGameItemMgr.Instance.GetItemCount(103) > 0)
        {
            refresh_type.SetActive(true);
            Vector3 pos = refresh_type.transform.localPosition;
            refresh_type.transform.localPosition = new Vector3(525, pos.y, pos.z);

            label_freefreshtime.text = "刷新消耗:1/" + sdGameItemMgr.Instance.GetItemCount(103).ToString();
            UISprite sprite = refresh_type.GetComponent <UISprite>();
            sdUICharacter.Instance.LoadAtlas("UI/$rankList/ranklistAtlas.prefab", sprite, "sxlp");
        }
        else
        {
            refresh_type.SetActive(true);
            label_freefreshtime.text = "刷新消耗:" + m_HZRefresh.ToString();
            Vector3 pos = refresh_type.transform.localPosition;
            refresh_type.transform.localPosition = new Vector3(520, pos.y, pos.z);
            UISprite sprite = refresh_type.GetComponent <UISprite>();
            sprite.atlas      = sdConfDataMgr.Instance().commonAtlas;
            sprite.spriteName = "icon_xz";
        }
        label_crystal.text = sdGameItemMgr.Instance.GetItemCount(102).ToString();
        Hashtable shopTable = sdConfDataMgr.Instance().GetTable("dmdsshopconfig.shop_secrets");

        for (int index = 0; index < sdMysteryShopMgr.Instance.m_lstItem.Count; ++index)
        {
            CliProto.SSecretItemInfo item = sdMysteryShopMgr.Instance.m_lstItem[index];

            GameObject uiItem     = null;
            Transform  trans_item = panel.FindChild("item" + index.ToString());
            if (trans_item == null)
            {
                uiItem = GameObject.Instantiate(template_item) as GameObject;
            }
            else
            {
                uiItem = trans_item.gameObject;
            }
            uiItem.SetActive(true);
            uiItem.name                    = "item" + index.ToString();
            uiItem.transform.parent        = panel;
            uiItem.transform.localPosition = new Vector3(template_item.transform.localPosition.x, template_item.transform.localPosition.y - 130.0f * index, 0);
            uiItem.transform.localScale    = Vector3.one;
            uiItem.transform.localRotation = Quaternion.identity;

            bool bCanBuy = false;
            if (shopTable.ContainsKey(item.m_UID.ToString()))
            {
                Hashtable  subTable    = shopTable[item.m_UID.ToString()] as Hashtable;
                sdSlotIcon sloticon    = uiItem.transform.FindChild("Sprite_item").GetComponent <sdSlotIcon>();
                UISprite   sprite_item = uiItem.transform.FindChild("Sprite_item").GetComponent <UISprite>();
                sprite_item.atlas      = sdConfDataMgr.Instance().commonAtlas;
                sprite_item.spriteName = "IconFrame0";
                Hashtable itemInfo = null;
                itemInfo = sdConfDataMgr.Instance().GetItemById(subTable["ItemId"] as string);
                sloticon.SetInfo(subTable["ItemId"] as string, itemInfo);
                int     nCount = int.Parse(subTable["ItemNum"] as string);
                UILabel lb_num = uiItem.transform.FindChild("Sprite_item").FindChild("Label_num").GetComponent <UILabel>();
                lb_num.text = nCount.ToString();

                UILabel lb_money = uiItem.transform.FindChild("Label_money").GetComponent <UILabel>();
                int     costNum  = int.Parse(subTable["CostNum"].ToString());
                lb_money.text = costNum.ToString();

                UISprite sprite_moneytype = uiItem.transform.FindChild("Sprite_monetytype").GetComponent <UISprite>();
                int      moneyType        = int.Parse(subTable["CostType"].ToString());

                if (moneyType == 3)//水晶aaaa
                {
                    sprite_moneytype.width  = 40;
                    sprite_moneytype.height = 48;
                    sdUICharacter.Instance.LoadAtlas("UI/$common2/common2.prefab", sprite_moneytype, "smsj");
                    if (sdGameItemMgr.Instance.GetItemCount(102) >= costNum)
                    {
                        bCanBuy = true;
                    }
                }
                else if (moneyType == 1)//勋章aaa
                {
                    sprite_moneytype.width      = 40;
                    sprite_moneytype.height     = 47;
                    sprite_moneytype.atlas      = sdConfDataMgr.Instance().commonAtlas;
                    sprite_moneytype.spriteName = "icon_xz";
                    int Cash = int.Parse(((Hashtable)sdGlobalDatabase.Instance.globalData["MainCharBaseProp"])["Cash"].ToString());
                    if (Cash >= costNum)
                    {
                        bCanBuy = true;
                    }
                }
                else if (moneyType == 2)//游戏币aa
                {
                    sprite_moneytype.width      = 45;
                    sprite_moneytype.height     = 38;
                    sprite_moneytype.atlas      = sdConfDataMgr.Instance().commonAtlas;
                    sprite_moneytype.spriteName = "icon_jinb";
                    int money = int.Parse(((Hashtable)sdGlobalDatabase.Instance.globalData["MainCharBaseProp"])["NonMoney"].ToString());
                    if (money >= costNum)
                    {
                        bCanBuy = true;
                    }
                }
                UIPlaySound sound = sloticon.gameObject.GetComponent <UIPlaySound>();
                if (sound)
                {
                    int id = int.Parse(subTable["ItemId"] as string);
                    sound.enabled = (id != 100 && id != 101 && id != 200);
                }
                lb_money.color = bCanBuy ? Color.white : Color.red;
                UILabel   lb_itemName = uiItem.transform.FindChild("Label_name").GetComponent <UILabel>();
                Hashtable itemTable   = sdConfDataMgr.Instance().GetItemById(subTable["ItemId"] as string);
                lb_itemName.text  = itemTable["ShowName"].ToString();
                lb_itemName.color = sdConfDataMgr.Instance().GetItemQuilityColor(int.Parse(itemInfo["Quility"].ToString()));
                UISprite sprite_quality = uiItem.transform.FindChild("Sprite_item").FindChild("Sprite").GetComponent <UISprite>();
                sprite_quality.spriteName = sdConfDataMgr.Instance().GetItemQuilityBorder(int.Parse(itemInfo["Quility"].ToString()));
            }
            uiItem.transform.FindChild("Button_buy").gameObject.SetActive(item.m_Bought == 0);
            uiItem.transform.FindChild("Sprite_ydh").gameObject.SetActive(item.m_Bought != 0);
        }
    }