コード例 #1
0
    public void UseItem(ItemBase item)
    {
        if (item != null)
        {
            Debug.Log("Item is: " + item);
            ItemsDescription description = item.itemProperties.itemDescription;
            Corrosion        c           = GetComponentInParent <Corrosion>();
            if (c != null && description != null)
            {
                if (description.GetItemType().GetType() == (typeof(AcidsList)))
                {
                    //Corrode the item based on it's pH value.....Lesser pH, more corrosion
                    //100 will be taken as a reference to calculate corrosion damage to all the platforms
                    Debug.Log("Trying to corrode");
                    float value = (1 / (float)((description.pHValue) + 1)) * 100;
                    c.Corrode(value);
                }
                else
                if (description.GetItemType().GetType() == (typeof(BasesList)))
                {
                    //Corrode the item based on it's pH value.....Higher pH, more corrosion
                    //100 will be taken as a reference to calculate corrosion damage to all the platforms
                    int alteratedpH = 7 - (description.pHValue - 7);

                    float value = (1 / ((alteratedpH) + 1)) * 100;
                    c.Corrode(value);
                }
            }
            else
            {
                Debug.Log("Dude....There is no corrosion");
            }
        }
    }
コード例 #2
0
    public void Extract(SelectionObjectData item)
    {
        ItemBase         i   = Extraction.Extract(item.item).GetComponent <ItemBase>();
        ItemsDescription des = i.itemProperties.itemDescription;

        des.GetItemType();

        //The extraction will take default information from the prefab object.
        //must check if the item type is already present.
        int phVal = des.pHValue;

        AddItem(i); //invenetory will take care of everything checking for ph if present.


        //IF the item type is already present, it's pH value in the description data must be checked.
        //If the pH is same, the extra volume must be added to the existing item slot
    }