You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
internal class HarvestResource : AIState
|
|
|
|
|
{
|
|
|
|
|
private readonly Gatherer _gatherer;
|
|
|
|
|
private readonly Animator _animator;
|
|
|
|
|
private float _resourcesPerSecond = 3;
|
|
|
|
|
|
|
|
|
|
private float _nextTakeResourceTime;
|
|
|
|
|
private static readonly int Harvest = Animator.StringToHash("Harvest");
|
|
|
|
|
|
|
|
|
|
public HarvestResource(Gatherer gatherer, Animator animator)
|
|
|
|
|
{
|
|
|
|
|
_gatherer = gatherer;
|
|
|
|
|
_animator = animator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Tick()
|
|
|
|
|
{
|
|
|
|
|
if (_gatherer.Target != null)
|
|
|
|
|
{
|
|
|
|
|
if (_nextTakeResourceTime <= Time.time)
|
|
|
|
|
{
|
|
|
|
|
_nextTakeResourceTime = Time.time + (1f / _resourcesPerSecond);
|
|
|
|
|
_gatherer.TakeFromTarget();
|
|
|
|
|
_animator.SetTrigger(Harvest);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnEnter()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnExit()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|