Example #1
0
    public static string ToString(this SpiceName name)
    {
        switch (name)
        {
        case SpiceName.Ca:
            return("Ca");

        case SpiceName.Tu:
            return("Tu");

        case SpiceName.Sa:
            return("Sa");

        case SpiceName.Ci:
            return("Ci");

        case SpiceName.Cl:
            return("Cl");

        case SpiceName.Pe:
            return("Pe");

        default:
            return("Su");
        }
    }
Example #2
0
 public void GetItemFromTrader(SpiceName name, int value)
 {
     if (capacity >= value)
     {
         for (int i = 0; i < value; i++)
         {
             PutItem(name);
         }
     }
 }
Example #3
0
    public void GetItemFromInventory(SpiceName name, int value)
    {
        int curValue = inventory.GetItemValue(name);

        if (curValue >= value)
        {
            for (int i = 0; i < value; i++)
            {
                PutItem(name);
            }
            inventory.RemoveItemByQuanlity(name, value);
        }
    }
Example #4
0
    public void PutItem(SpiceName name, int value)
    {
        if (items.TryGetValue(name, out int v))
        {
            items.Remove(name);
            items.Add(name, value + v);
        }
        else
        {
            items.Add(name, value);
        }

        value++;
        caravanText      = GameObject.FindGameObjectWithTag(SpiceNames.ToString(name) + "_c").GetComponent <Text>();
        caravanText.text = "" + value;
    }
Example #5
0
    public void GetItemFromCaravan(SpiceName name, int value)
    {
        int curValue = caravan.GetItemValue(name);

        if (curValue >= value && capacity >= value)
        {
            for (int i = 0; i < value; i++)
            {
                PutItem(name);
            }
            for (int i = 0; i < value; i++)
            {
                caravan.RemoveItemByOne(name);
            }
        }
    }
Example #6
0
    public void RemoveItemByOne(SpiceName name)
    {
        int value = 0;

        if (items.TryGetValue(name, out value))
        {
            if (value != 0)
            {
                value--;
                items.Remove(name);
                items.Add(name, value);

                caravanText      = GameObject.FindGameObjectWithTag(SpiceNames.ToString(name) + "_c").GetComponent <Text>();
                caravanText.text = string.Format("{0}", value);
            }
        }
    }
Example #7
0
    public void PutItem(SpiceName name)
    {
        int value = 0;

        if (capacity >= 0)
        {
            if (items.TryGetValue(name, out value))
            {
                items.Remove(name);
                items.Add(name, value + 1);
            }
            else
            {
                items.Add(name, 1);
            }

            value++;
            inventoryText      = GameObject.FindGameObjectWithTag(SpiceNames.ToString(name)).GetComponent <Text>();
            inventoryText.text = "" + value;
            capacity--;
        }
    }
Example #8
0
    public bool RemoveItemByQuanlity(SpiceName name, int quanlity)
    {
        int value = 0;

        if (capacity >= 0)
        {
            if (items.TryGetValue(name, out value))
            {
                if (value != 0 && value >= quanlity)
                {
                    value -= quanlity;
                    items.Remove(name);
                    items.Add(name, value);

                    capacity          += quanlity;
                    inventoryText      = GameObject.FindGameObjectWithTag(SpiceNames.ToString(name)).GetComponent <Text>();
                    inventoryText.text = string.Format("{0}", value);
                    return(true);
                }
            }
        }
        return(false);
    }
Example #9
0
 public int GetItemValue(SpiceName name)
 {
     items.TryGetValue(name, out int value);
     return(value);
 }