Example #1
0
    private void processGoTarget()
    {
        INeed currentNeed = queue[0].need;
        var   gos         = GameObject.FindObjectsOfType(currentNeed.satisfyType) as Objects.IObject[];

        Debug.Log("Found " + gos.Length + " object that can satisfy need");

        var target = gos
                     .Where(e => e.canBeUsed())
                     .OrderBy(e => Vector3.Distance(e.transform.position, transform.position))
                     .FirstOrDefault();

        if (!target)
        {
            Debug.Log("Could not find target to satisfy " + currentNeed.GetAction());
            return;
        }
        objToInteract = target;
        traveler.SetTarget(target);
    }
Example #2
0
    public void processCurrent()
    {
        if (currentStep == queue[0].need.GetSteps().Count)
        {
            finishedOne();
            objToInteract = null;
            currentStep   = 0;
            if (queue.Count != 0 && !queue[0].need.GetSteps().Any(e => e == MemberSteps.ACT))
            {
                Debug.LogError("No ACT on current need: " + queue[0].need.GetAction() + ", useless action ?");
            }
            Debug.Log("New current target: " + queue[0].need.GetAction());
        }
        if (queue.Count == 0)
        {
            return;
        }

        List <MemberSteps> steps = queue[0].need.GetSteps();

        switch (steps[currentStep])
        {
        case MemberSteps.ACT:
            processAct();
            break;

        case MemberSteps.GO_HERE:
            processGoHere();
            break;

        case MemberSteps.GO_HOME:
            processGoHome();
            break;

        case MemberSteps.GO_TARGET:
            processGoTarget();
            break;
        }
    }
Example #3
0
 public void SetTarget(Objects.IObject obj)
 {
     Debug.Log("Travelling to " + obj.name);
     currentTarget = obj.transform;
 }
Example #4
0
 public void RegisterNewObject(Objects.IObject obj)
 {
     ownedObjects.Add(obj);
 }
Example #5
0
 public void UnregisterObject(Objects.IObject oldObj)
 {
     ownedObjects.Remove(oldObj);
 }