コード例 #1
0
    public void ButtonClick(ButtonUpgradeScript script)
    {
        if (currencySystem != null)
        {
            if (!currencySystem.Buy(script.Cost))
                return;
        }

        print("Changing item " + script.TargetIndex);
        var theItem = myVariables[script.TargetIndex];
        switch (theItem.Type)
        {
            case Variable.DataType.Float:
                if (script.SetToFloat)
                {
                    theItem.FloatValue = script.FloatChange;
                }
                else
                {
                    theItem.FloatValue += script.FloatChange;
                }
                break;
            case Variable.DataType.Bool:

                if(script.UseToggle)
                {
                    theItem.BoolValue = !theItem.BoolValue;
                }
                else
                {
                    theItem.BoolValue = script.SetToBool;
                }

                break;
        }
        script.Usages--;
        if (script.Usages <= 0)
            script.GetComponent<Button>().interactable = false;
    }
コード例 #2
0
 void OnEnable()
 {
     script = (ButtonUpgradeScript)target;
 }