Exemplo n.º 1
0
    public void initStock(GDEItemData data
                          , SDConstants.MaterialType MType = SDConstants.MaterialType.end)

    {
        stockType    = SDConstants.StockType.material;
        materialType = MType;
        itemId       = data.id;
        itemNum      = data.num;
        hashcode     = 0;
        consumableItem item = SDDataManager.Instance.getConsumableById(itemId);

        if (starVision)
        {
            starVision.gameObject.SetActive(false);
        }
        if (NumText)
        {
            NumText.text = UsedNum + " / " + itemNum;
        }

        itemImg.sprite  = item.IconFromAtlas;
        bgImg.sprite    = SDDataManager.Instance.baseBgSpriteByRarity(item.LEVEL);
        frameImg.sprite = SDDataManager.Instance.baseFrameSpriteByRarity(item.LEVEL);

        //
        isLocked = false;
    }
Exemplo n.º 2
0
    public void AddDrop(GDEItemData drop)
    {
        string id = drop.id;

        if (SDDataManager.Instance.getItemTypeById(id) == SDConstants.ItemType.Consumable)
        {
            bool flag = false;
            for (int i = 0; i < allDropsGet.Count; i++)
            {
                if (allDropsGet[i].id == id)
                {
                    allDropsGet[i].num += drop.num;
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                allDropsGet.Add(drop);
            }
        }
        else
        {
            allDropsGet.Add(drop);
        }
    }
Exemplo n.º 3
0
 public void initDrop(GDEItemData drop)
 {
     itemId       = drop.id;
     itemHashcode = 0;
     if (fightForceText)
     {
         fightForceText.gameObject.SetActive(false);
     }
     if (upText)
     {
         upText.gameObject.SetActive(false);
     }
     SDConstants.ItemType it = SDDataManager.Instance.getItemTypeById(itemId);
     if (it == SDConstants.ItemType.Consumable)
     {
         if (downText)
         {
             downText.text = "" + drop.num;
         }
         consumableItem item = SDDataManager.Instance.getConsumableById(itemId);
         itemImg.sprite   = item.IconFromAtlas;
         itemBgImg.sprite = SDDataManager.Instance.baseBgSpriteByRarity(1);
         frameImg.sprite  = SDDataManager.Instance.baseFrameSpriteByRarity(1);
         if (starVision)
         {
             starVision.StarNum = item.LEVEL;
         }
     }
 }
Exemplo n.º 4
0
    public void initConsumable(GDEItemData M, bool showTaken = false)
    {
        itemId       = M.id;
        type         = SDConstants.ItemType.Consumable;
        itemHashcode = 0;
        consumableItem P = SDDataManager.Instance.getConsumableById(itemId);

        fightForceText?.gameObject.SetActive(false);
        itemUpLv = 0;
        upText?.gameObject.SetActive(true);
        upText.text = P.NAME;
        itemNum     = M.num;
        downText.gameObject.SetActive(true);
        downText.text = "" + M.num;
        slider?.gameObject.SetActive(false);

        int rarity = P.LEVEL;

        if (starVision != null)
        {
            starVision.StarNum = rarity;
        }
        itemImg.sprite   = P.IconFromAtlas;
        itemBgImg.sprite = SDDataManager.Instance.baseBgSpriteByRarity(1);
        frameImg.sprite  = SDDataManager.Instance.baseFrameSpriteByRarity(1);

        if (showTaken)
        {
            isSelected = SDDataManager.Instance.checkIfPropIsTaken(itemId);
        }
    }
Exemplo n.º 5
0
    public void selectPropToChangeCurrentSlot(string id)
    {
        string oldPropId = string.Empty;

        for (int i = 0; i < SDDataManager.Instance.PlayerData.propsTeam.Count; i++)
        {
            GDEItemData P = SDDataManager.Instance.PlayerData.propsTeam[i];
            if (P.index == currentSlotIndex)
            {
                if (P.id == id)
                {
                    return;
                }
                oldPropId = P.id;
                P.id      = id;
                int volume = SDDataManager.Instance.propTakenVolume(id);
                int allNum = SDDataManager.Instance.getConsumableNum(id);
                if (allNum >= volume)
                {
                    P.num = volume;
                }
                else
                {
                    P.num = allNum;
                }
                SDDataManager.Instance.PlayerData.propsTeam[i] = P;
                SDDataManager.Instance.PlayerData.Set_propsTeam();
            }
        }
        if (string.IsNullOrEmpty(oldPropId))
        {
            for (int i = 0; i < SDDataManager.Instance.PlayerData.propsTeam.Count; i++)
            {
                GDEItemData P = SDDataManager.Instance.PlayerData.propsTeam[i];
                if (P.index != currentSlotIndex)
                {
                    if (P.id == id)//旧位置
                    {
                        P.id = oldPropId;
                        int volume = SDDataManager.Instance.propTakenVolume(oldPropId);
                        int allNum = SDDataManager.Instance.getConsumableNum(oldPropId);
                        if (allNum >= volume)
                        {
                            P.num = volume;
                        }
                        else
                        {
                            P.num = allNum;
                        }
                        SDDataManager.Instance.PlayerData.propsTeam[i] = P;
                        SDDataManager.Instance.PlayerData.Set_propsTeam();
                    }
                }
            }
        }
        initPropList();
        InitBag(currentUseType);
    }
Exemplo n.º 6
0
    public void RefreshSliderCondition()
    {
        GDEItemData d = SDDataManager.Instance.getConsumeableDataById(id);

        SelectedNumSlider.minValue = 1;
        SelectedNumSlider.value    = SelectedNumSlider.minValue;
        SelectedNumSlider.maxValue = d.num;
        currentNumText.text        = CurrentSelectedScope.ToString("/");
    }
Exemplo n.º 7
0
 public override void GetSelectResultList(string id)
 {
     foreach (GDEItemData l_item in PlayerResourceManager.g_inventory_list)
     {
         if (id == l_item.Key)
         {
             item_data = l_item;
             PlayerResourceManager.instance.SellItem(l_item.Key, 1);
             break;
         }
     }
 }
Exemplo n.º 8
0
 public List <GDEItemData> GetInventoryList()
 {
     if (g_inventory_list == null)
     {
         g_inventory_list = new List <GDEItemData>();
     }
     g_inventory_list.Clear();
     foreach (KeyValuePair <string, int> pair in g_inventory)
     {
         GDEItemData data = new GDEItemData(pair.Key);
         g_inventory_list.Add(data);
     }
     return(g_inventory_list);
 }
Exemplo n.º 9
0
    public void initEnemy(GDEItemData item)
    {
        itemId  = item.id;
        itemNum = item.num;
        EnemyInfo E = SDDataManager.Instance.getEnemyInfoById(itemId);

        itemLevel = E.EnemyRank.Index;
        if (upText)
        {
            upText.gameObject.SetActive(true);
            upText.text = SDGameManager.T(E.Name);
        }
        starVision.StarNum = itemLevel;
    }
Exemplo n.º 10
0
    public void InitBag(useType use_type)
    {
        currentUseType = use_type;
        List <GDEItemData> list = SDDataManager.Instance.PlayerData.propsTeam;

        if (list.Count < SDConstants.BagStartVolime)//初始化
        {
            SDDataManager.Instance.PlayerData.propsTeam.Clear();
            SDDataManager.Instance.PlayerData.Set_propsTeam();
            GDEItemData a = new GDEItemData(GDEItemKeys.Item_MaterialEmpty)
            {
                id    = string.Empty,
                num   = 0,
                index = 0,
            };
            SDDataManager.Instance.PlayerData.propsTeam.Add(a);
            SDDataManager.Instance.PlayerData.Set_propsTeam();
            GDEItemData a1 = new GDEItemData(GDEItemKeys.Item_MaterialEmpty)
            {
                id    = string.Empty,
                num   = 0,
                index = 1,
            };
            SDDataManager.Instance.PlayerData.propsTeam.Add(a1);
            SDDataManager.Instance.PlayerData.Set_propsTeam();
            list = SDDataManager.Instance.PlayerData.propsTeam;
        }
        //
        allSlots.Clear();
        for (int i = 0; i < scrollRect.content.childCount; i++)
        {
            OneBagSlot bs = scrollRect.content.GetChild(i).GetComponent <OneBagSlot>();
            if (i < list.Count)//已解锁位置
            {
                bs.initSlot(currentUseType, list[i]);
            }
            else
            {
                bs.initSlot(useType.end
                            , new GDEItemData(GDEItemKeys.Item_MaterialEmpty)
                {
                    id  = string.Empty,
                    num = 0
                });
            }
            bs.index = i;
            allSlots.Add(bs);
        }
    }
Exemplo n.º 11
0
    public void showDropItem()
    {
        if (UnityEngine.Random.Range(0, 1f) < DropProb)
        {
            GDEItemData M = DropC.oneDropReward();
            //SDDataManager.Instance.addMaterial(M.id,M.num);
            string message = SDDataManager.Instance.getMaterialNameById(M.id) + " +"
                             + M.num;
            //dropItemImg.sprite =

            StartCoroutine(IEShowDropItemAnim());
            //GameC.allDropsGet.Add(M);
            GameC.AddDrop(M);
        }
    }
Exemplo n.º 12
0
    public void btnTapped_add()
    {
        if (ImprovePage && ImprovePage.TooFlowToAdd)
        {
            return;
        }
        GDEItemData data = SDDataManager.Instance.getConsumeableDataById(itemId);
        int         num  = data.num;

        if (CurrentNum < num)
        {
            CurrentNum++;
        }
        refreshSelf();
    }
Exemplo n.º 13
0
    public void initPurchase(GDEItemData Purchase, bool useDamond = false)
    {
        itemId       = Purchase.id;
        itemNum      = Purchase.num;
        extraTrigger = useDamond;
        SDConstants.ItemType item_type = SDDataManager.Instance.getItemTypeById(itemId);
        type = item_type;
        int bpg = 0;

        if (type == SDConstants.ItemType.Consumable)
        {
            consumableItem data = SDDataManager.Instance.getConsumableById(itemId);
            if (upText)
            {
                upText.text = SDGameManager.T(data.name);
            }
            //
            itemImg.sprite   = data.IconFromAtlas;
            itemBgImg.sprite = SDDataManager.Instance.baseBgSpriteByRarity(data.LEVEL);
            frameImg.sprite  = SDDataManager.Instance.baseFrameSpriteByRarity(data.LEVEL);
            //
            string downT = "";
            if (!useDamond)
            {
                bpg   = data.buyPrice_coin * Purchase.num;
                downT = SDGameManager.T("金币") + " - " + bpg;
            }
            else
            {
                bpg   = data.buyPrice_diamond * Purchase.num;
                downT = SDGameManager.T("钻石") + " - " + bpg;
            }
            if (downText)
            {
                downText.text = downT;
            }
        }


        if (SDDataManager.Instance.PlayerData.damond < bpg)
        {
            downText.transform.parent.GetComponent <Button>().interactable = false;
        }
        else
        {
            downText.transform.parent.GetComponent <Button>().interactable = true;
        }
    }
Exemplo n.º 14
0
    public void refreshSelf()
    {
        UsedNumText.text = "" + CurrentNum;
        if (CurrentNum <= 0)
        {
            btn_reduce.interactable = false;
        }
        else
        {
            btn_reduce.interactable = true;
        }
        //
        GDEItemData data = SDDataManager.Instance.getConsumeableDataById(itemId);

        if (data == null)
        {
            MainNum = 0;
        }
        else
        {
            MainNum = data.num;
        }
        //
        if (CurrentNum >= MainNum)
        {
            btn_add.interactable = false;
        }
        else
        {
            btn_add.interactable = true;
        }

        //
        consumableItem item = SDDataManager.Instance.getConsumableById(itemId);

        //
        icon.sprite      = item.IconFromAtlas;
        bgIcon.sprite    = SDDataManager.Instance.baseBgSpriteByRarity(item.LEVEL);
        frameIcon.sprite = SDDataManager.Instance.baseFrameSpriteByRarity(item.LEVEL);
        if (starVision)
        {
            starVision.StarNum = item.LEVEL;
        }
        upText?.gameObject.SetActive(false);
        downText.text = "X" + MainNum;
    }
Exemplo n.º 15
0
    public void showAllDropItems()
    {
        GameController GameC = GetComponentInParent <GameController>();

        itemCount = GameC.allDropsGet.Count;
        for (int i = 0; i < itemCount; i++)
        {
            GDEItemData M = GameC.allDropsGet[i];
            Transform   s = Instantiate(SItem) as Transform;
            s.transform.SetParent(scrollRect.content);
            s.transform.localScale = Vector3.one;
            s.gameObject.SetActive(true);
            SingleItem _s = s.GetComponent <SingleItem>();
            _s.sourceController = this;
            _s.index            = i;
            _s.initDrop(M);
            items.Add(_s);
        }
    }
Exemplo n.º 16
0
    public void initDetailPanel(string id)
    {
        GDEItemData d = SDDataManager.Instance.getConsumeableDataById(id);

        if (d == null)
        {
            return;
        }
        this.id = id; hashcode = 0;
        consumableItem item = SDDataManager.Instance.getConsumableById(id);

        if (!item)
        {
            return;
        }
        if (itemNameText)
        {
            itemNameText.text = item.NAME;
        }
        //if(itemExtraText) itemExtraText.text =
        if (itemDescText)
        {
            itemDescText.text = item.DESC;
        }
        if (btnToResolve)
        {
            btnToResolve.gameObject.SetActive(!item.isProp);
        }
        starVision.StarNum = item.LEVEL;
        //minNumText.text = "" + 1;
        //maxNumText.text = "" + d.num;
        CurrentSelectedScope.Min = 1;
        CurrentSelectedScope.Max = d.num;
        currentNumText.text      = CurrentSelectedScope.ToString("/");
        //
        itemImg.sprite  = item.IconFromAtlas;
        bgImg.sprite    = SDDataManager.Instance.baseBgSpriteByRarity(item.LEVEL);
        frameImg.sprite = SDDataManager.Instance.baseFrameSpriteByRarity(item.LEVEL);
        //
        RefreshSliderCondition();
    }
Exemplo n.º 17
0
    public void item_use(OneBagSlot slot)
    {
        currentSlotIndex = slot.index;
        GDEItemData P = SDDataManager.Instance.PlayerData.propsTeam[currentSlotIndex];

        if (P != null && !string.IsNullOrEmpty(P.id))
        {
            consumableItem item = SDDataManager.Instance.getConsumableById(P.id);
            if (!item.isProp)
            {
                return;
            }
            CurrentPropItem = item;
            BM._PropTarget  = item.AIM;
            BM.refreshPropEnableTarget();
            BM._PropRange = item.AOE;
            SDGameManager.Instance.isUsingProp = true;
            BM.PropSpecialStr = item.SpecialStr;
            BM.PF.checkSpecialStr(item.SpecialStr, P.id);
        }
    }
Exemplo n.º 18
0
    public GDEItemData oneDropReward()
    {
        float[]       all   = new float[] { normalRate, rareRate, epicRate, legendRate };
        int           final = RandomIntger.StandardReturn(all);
        GDEItemData   drop  = new GDEItemData(GDEItemKeys.Item_MaterialEmpty);
        List <string> list  = allProbablyDropIds_normal;

        if (final == 0)//normal
        {
            list = allProbablyDropIds_normal;
        }
        else if (final == 1)//rare
        {
            list = allProbablyDropIds_rare;
        }
        else if (final == 2)//epic
        {
            list = allProbablyDropIds_epic;
        }
        else if (final == 3)//legend
        {
            list = allProbablyDropIds_legend;
        }
        int flag = UnityEngine.Random.Range(0, list.Count);

        drop.id = list[flag];
        //int stockKind = drop.id % 1000000;
        int weight = SDDataManager.Instance.getMaterialWeightById(list[flag]);

        if (weight <= 1)
        {
            drop.num = 1;
        }
        else
        {
            drop.num = UnityEngine.Random.Range(1, weight + 1);
        }
        return(drop);
    }
Exemplo n.º 19
0
        private void SearchPlayerInventory()
        {
            Button button     = gameObject.GetComponent <Button>();
            string string_key = button.GetComponentInChildren <Text>().text;

            Debug.Log("Button_text:" + string_key);
            foreach (var l_item in PlayerResourceManager.g_inventory_list)
            {
                if (string_key == l_item.Key.ToString())
                {
                    item = l_item;
                    break;
                }
            }
            // foreach (HeroParty l_party in PlayerResourceManager.g_hero_party)
            // {
            //     if (string_key == l_party.id.ToString())
            //     {
            //         hero_party = l_party;
            //         break;
            //     }
            // }
        }
Exemplo n.º 20
0
    public void AddConsumableInSlot(string id)
    {
        if (isLocked)
        {
            return;
        }
        GDEItemData data = SDDataManager.Instance.getConsumeableDataById(id);

        if (data == null)
        {
            return;
        }
        if (data.num <= 0)
        {
            return;
        }
        consumableItem info = SDDataManager.Instance.getConsumableItemById(id);

        if (info == null)
        {
            return;
        }
        //
        isEmpty          = false;
        Icon.sprite      = info.IconFromAtlas;
        bgIcon.sprite    = SDDataManager.Instance.baseBgSpriteByRarity(info.LEVEL);
        frameIcon.sprite = SDDataManager.Instance.baseFrameSpriteByRarity(info.LEVEL);
        //
        starVision?.gameObject.SetActive(false);
        aboveText?.gameObject.SetActive(false);
        belowText.gameObject.SetActive(false);
        //
        ItemType  = SDConstants.ItemType.Consumable;
        _id       = id;
        _hashcode = 0;
    }
Exemplo n.º 21
0
    public void initSlot(BagController.useType use_type, GDEItemData prop)
    {
        currentUseType = use_type;
        if (currentUseType == BagController.useType.end)
        {
            Islocked = true;
        }
        else
        {
            Islocked = false;
            if (string.IsNullOrEmpty(prop.id))
            {
                IsEmpty = true;
            }
            else
            {
                IsEmpty = false;
                propId  = prop.id;
                int limit = SDDataManager.Instance.propTakenVolume(propId);
                num = prop.num;

                consumableItem D = SDDataManager.Instance.getConsumableById(propId);
                nameText.text = D.NAME;
                numText.text  = "" + num + (num >= limit?"(上限)":"");
                //
                propIcon.sprite      = D.IconFromAtlas;
                propBgIcon.sprite    = SDDataManager.Instance.baseBgSpriteByRarity(1);
                propFrameIcon.sprite = SDDataManager.Instance.baseFrameSpriteByRarity(1);
                //
                if (starVision)
                {
                    starVision.StarNum = D.LEVEL;
                }
            }
        }
    }
Exemplo n.º 22
0
    public void initConsumable(string id, bool showTaken = false)
    {
        GDEItemData data = SDDataManager.Instance.getConsumeableDataById(id);

        initConsumable(data, showTaken);
    }