Exemple #1
0
    public override bool checkProceduralPrecondition(GameObject agent)
    {
        // find the nearest supply pile that has spare tools
        InnComponent[] inns        = (InnComponent[])UnityEngine.GameObject.FindObjectsOfType(typeof(InnComponent));
        InnComponent   closest     = null;
        float          closestDist = 0;

        foreach (InnComponent inn in inns)
        {
            if (inn.NumMeat > 5)
            {
                if (closest == null)
                {
                    // first one, so choose it for now
                    closest     = inn;
                    closestDist = (inn.gameObject.transform.position - agent.transform.position).magnitude;
                }
                else
                {
                    // is this one closer than the last?
                    float dist = (inn.gameObject.transform.position - agent.transform.position).magnitude;
                    if (dist < closestDist)
                    {
                        // we found a closer one, use it
                        closest     = inn;
                        closestDist = dist;
                    }
                }
            }
        }
        if (closest == null)
        {
            return(false);
        }

        targetInn = closest;
        target    = targetInn.gameObject;

        return(closest != null);
    }
 public override void reset()
 {
     droppedOffFood = false;
     targetInn      = null;
 }
Exemple #3
0
 public override void reset()
 {
     hasTool   = false;
     targetInn = null;
 }
Exemple #4
0
 public override void reset()
 {
     chopped   = false;
     targetInn = null;
     startTime = 0;
 }