Ejemplo n.º 1
0
    // public List<CurrencySO> currencys = new List<CurrencySO>();

    public bool Add(CurrencySO currency, GameObject module, bool log = true)
    {
        bool contentOK = false;

        foreach (CurrencySO possibleContent in module.GetComponent <WalletInfos>().so.content)
        {
            contentOK |= currency.id == possibleContent.id;
        }
        if (!contentOK)
        {
            if (log)
            {
                module.GetComponent <DisplayUI>().FadeText("Bad Type Of Currency");
            }
            return(false);
        }

        if (dictionary[module].Count >= module.GetComponent <WalletInfos>().capacity)
        {
            if (log)
            {
                module.GetComponent <DisplayUI>().FadeText("Not enough Room");
            }
            return(false);
        }
        dictionary[module].Add(currency);

        if (onItemChangedCallBack != null)
        {
            onItemChangedCallBack.Invoke();
        }


        return(true);
    }
Ejemplo n.º 2
0
    // Clear the slot
    public void ClearSlot()
    {
        currency = null;

        icon.sprite  = null;
        icon.enabled = false;
        // removeButton.interactable = false;
        Destroy(temporary);
    }
Ejemplo n.º 3
0
    public void Remove(CurrencySO currency, GameObject module)
    {
        dictionary[module].Remove(currency);

        if (onItemChangedCallBack != null)
        {
            onItemChangedCallBack.Invoke();
        }
    }
Ejemplo n.º 4
0
 public void AddCurr(CurrencySO curr)
 {
     if (dic.ContainsKey(curr))
     {
         dic[curr]++;
     }
     else
     {
         dic[curr] = 1;
     }
 }
Ejemplo n.º 5
0
    public void RemoveCurrency(CurrencySO so)
    {
        bool removed = false;

        foreach (GameObject goModule in dictionary.Keys)
        {
            if (goModule.GetComponent <WalletInfos>().visible&& dictionary[goModule].Contains(so) && !removed)
            {
                Remove(so, goModule);
                removed = true;
            }
        }
    }
Ejemplo n.º 6
0
    public bool AddCurrency(CurrencySO so)
    {
        bool added = false;

        foreach (GameObject goModule in dictionary.Keys)
        {
            if (!added)
            {
                added = Add(so, goModule, false);
            }
        }
        return(added);
    }
Ejemplo n.º 7
0
    // Add item to the slot
    public void AddItem(CurrencySO newCurrency)
    {
        currency = newCurrency;

        icon.enabled = true;
        //removeButton.interactable = true;
        if (temporary != null)
        {
            Destroy(temporary);
        }


        temporary = GameObject.FindGameObjectWithTag("Parent").GetComponent <ItemCreation>().ItemGeneration(GetComponent <Transform>().position, currency.model, currency.taille);
        temporary.GetComponent <ItemSlotOrigin>().lastModule = (GameObject)GetComponentInParent <InventoryUI>().moduleActifs[invUI.Index(this)];
        temporary.GetComponent <ItemDrop>().currency         = currency;
        temporary.GetComponent <BoxCollider>().size          = new Vector3(temporary.GetComponentInChildren <MeshRenderer>().bounds.size.x, temporary.GetComponentInChildren <MeshRenderer>().bounds.size.y, 2.5f);
    }
Ejemplo n.º 8
0
    void newCurrency(CurrencySO so)
    {
        GameObject prefab;

        switch (so.type)
        {
        case CurrencySO.CurrencyType.Piece:
            prefab = prefabPiece;
            break;

        case CurrencySO.CurrencyType.Billet:
            prefab = prefabBillet;
            break;
        }

        GameObject newCurrency = Instantiate(prefabPiece, Vector3.zero, Quaternion.identity);

        newCurrency.transform.localScale = new Vector3(so.taille, so.taille, newCurrency.transform.localScale.z);
    }
Ejemplo n.º 9
0
    public void Swap(CurrencySO currency, GameObject module, CurrencySO currency2, GameObject module2)
    {
        Remove(currency, module);
        Remove(currency2, module2);
        Add(currency, module);
        Add(currency2, module2);

        /*
         * if (currency.type != currency2.type)
         * {
         *  module.GetComponent<DisplayUI>().FadeText("Bad Type Of Currency");
         *  return;
         * }
         *
         * dictionary[module].Add(currency);
         * dictionary[module2].Add(currency2);
         *
         *
         * if (onItemChangedCallBack != null)
         * onItemChangedCallBack.Invoke();
         */
    }