예제 #1
0
    private void Start()
    {
        if (binding == null)
        {
            binding = GetComponent <UserProgressBinding>();
        }

        switch (binding.Path)
        {
        case BindingPath.COUNT:
            CostBindingSource = costSource.Count;
            break;

        case BindingPath.DAMAGE:
            CostBindingSource = costSource.Damage;
            break;

        case BindingPath.FREQUENCY:
            CostBindingSource = costSource.SpawnRate;
            break;

        case BindingPath.SPEED:
            CostBindingSource = costSource.AttackSpeed;
            break;

        default:
            throw new NotImplementedException(binding.Path.ToString());
        }
    }
    private void Start()
    {
        binding     = GetComponent <UserProgressBinding>();
        costBinding = GetComponent <UserProgressCostBinding>();

        button.onClick.AddListener(() =>
        {
            var cost = costBinding.CostBindingSource.EvaluateRelated;
            if (score.Money < cost)
            {
                return;
            }

            binding.BindingSource.Value += value;
            foreach (var addbinding in additionalBindings)
            {
                addbinding.BindingSource.Value += value;
            }

            if (bindingIntecactable)
            {
                SetEnabled(binding.BindingSource.PercentValue < 1);
            }

            score.Money -= cost;

            //onBindingExecuted?.Invoke();
        });

        if (bindingIntecactable)
        {
            SetEnabled(binding.BindingSource.PercentValue < 1);
        }
    }