Example #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);
    }
Example #2
0
 public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     base.OnStateEnter(animator, stateInfo, layerIndex);
     _remainingPrice = _hirePrice;
     _aiAgent        = animator.GetComponent <AiAgent>();
 }
Example #3
0
 private void ResetPrice()
 {
     _remainingPrice = _price;
 }