public override void DetermineTarget(AIActionIAgent agent)
    {
        var closest2 = agent.Navigation.GetClosest(_resourceMemory.GetAll(typeof(TDestination)).Select(m => new System.Collections.Generic.KeyValuePair <Vector3, ResourceRecollection>(m.position, m)).ToList());

        destination = closest2.Value.Key;
        target      = closest2.Value.Value;
    }
Beispiel #2
0
 protected bool Success(AIActionIAgent agent)
 {
     Debugger.Instance.Log <AIActionBase>("Action Success: " + this.GetType().Name, agent.gameObject);
     isDone = true;
     //agent.WorldState.Apply(this.Effects);
     return(true);
 }
Beispiel #3
0
 public override bool Perform(AIActionIAgent agent)
 {
     if (!(agent as AgentBase).WorldState.ContainsKey("know" + typeof(TResource).Name))
     {
         return(Failure(agent));
     }
     return(Success(agent));
 }
    public override bool Perform(AIActionIAgent agent)
    {
        var resource = target as ResourceRecollection;

        if (resource == null)
        {
            return(Failure(agent));
        }
        var original = resource.manager.FindByID(resource.id);

        if (original == null)
        {
            _resourceMemory.Forget(resource.id);
            return(Failure(agent));
        }
        original.Inc((agent as AgentBase).Backpack.Take <TResource>(1f));
        return(Failure(agent));
    }
    public override bool Perform(AIActionIAgent agent)
    {
        var resource = target as ResourceRecollection;

        if (resource == null)
        {
            return(Failure(agent));
        }
        var original = resource.manager.FindByID(resource.id);

        if (original == null)
        {
            _resourceMemory.Forget(target.id);
            return(Failure(agent));
        }
        (agent as AgentBase).Backpack.Inc <TResource>(original.Take(1f));
        if (original.Quantity == 0f)
        { // empty
            _resourceMemory.Forget(target.id);
        }
        return(Success(agent));
    }
    public override bool Perform(AIActionIAgent agent)
    {
        var resource = target as ResourceRecollection;

        if (resource == null)
        {
            return(Failure(agent));
        }
        var original = resource.manager.FindByID(resource.id);

        if (original == null)
        {
            _resourceMemory.Forget(target.id);
            return(Failure(agent));
        }
        var qty = original.Take(4f);

        if (original.Quantity == 0f)
        { // destroyed
            _resourceMemory.Forget(target.id);
        }
        if (qty > 0)
        {
            OutputManager.Create(target.position + new Vector3(-2, 0, 0), Mathf.Min(1f, qty));
        }
        if (qty > 1)
        {
            OutputManager.Create(target.position + new Vector3(2, 0, 0), Mathf.Min(1f, qty - 1f));
        }
        if (qty > 2)
        {
            OutputManager.Create(target.position + new Vector3(0, 0, 2), Mathf.Min(1f, qty - 2f));
        }
        if (qty > 3)
        {
            OutputManager.Create(target.position + new Vector3(0, 0, -2), Mathf.Min(1f, qty - 3f));
        }
        return(Success(agent));
    }
Beispiel #7
0
 protected bool Failure(AIActionIAgent agent)
 {
     Debugger.Instance.Log <AIActionBase>("Action Failed: " + this.GetType().Name, agent.gameObject);
     isDone = true;
     return(false);
 }
Beispiel #8
0
 public abstract bool Perform(AIActionIAgent agent);
 public override bool Perform(AIActionIAgent agent)
 {
     throw new System.NotImplementedException();
 }
Beispiel #10
0
 public abstract void DetermineTarget(AIActionIAgent agent);
Beispiel #11
0
    public override void DetermineTarget(AIActionIAgent agent)
    {
        var moveto = Random.insideUnitCircle * 10;

        destination = agent.gameObject.transform.position + new Vector3(moveto.x, 0, moveto.y);
    }