Ejemplo n.º 1
0
    private void OnCaughtTarget(PlayerContext nearestPlayer, Animator animator)
    {
        var newRemainingPrice = new PricesDictionary();

        _remainingPrice.CopyTo(newRemainingPrice);
        foreach (var priceItem in _remainingPrice)
        {
            if (!nearestPlayer.InteractionController.IsGrabbingObjects)
            {
                break;
            }
            if (!nearestPlayer.InteractionController.TryGiveItem(priceItem.Key))
            {
                continue;
            }
            newRemainingPrice[priceItem.Key] -= 1;
            if (newRemainingPrice[priceItem.Key] <= 0)
            {
                newRemainingPrice.Remove(priceItem.Key);
            }
        }

        _remainingPrice = newRemainingPrice;

        if (_remainingPrice.Count == 0)
        {
            SetHired(animator, nearestPlayer);
            return;
        }

        nearestPlayer.MovementController.TrySetFleeing(_aiAgent.transform.position);
    }
Ejemplo n.º 2
0
    public void Pay(ItemType currency)
    {
        _price[currency] -= 1;
        if (_price[currency] <= 0)
        {
            _price.Remove(currency);
        }

        if (_price.Count > 0)
        {
            return;
        }

        var spawnPosition = MathUtil.GetPointAroundHorizontalRadius(transform.position, _resultYieldRadius);

        ObjectSpawner.Instance.SpawnItemByType(_resultItem, spawnPosition, transform.rotation);
        if (_destroyOnPaymentsFulfilled)
        {
            Destroy(gameObject);
        }
        else
        {
            ResetPrice();
        }
    }