override protected void Action()
    {
        if (actionSequence == null)
        {
            actionSequence = createActionSequence();
            if (actionSequence == null)
            {
                return;
            }

            Agent.AddBehaviour(actionSequence);
        }

        if (actionSequence != null && actionSequence.GetState() == State.Finished)
        {
            actionSequence = null;
            collected++;
        }

        if (actionSequence != null && actionSequence.GetState() == State.Stopped)
        {
            actionSequence = null;
        }
        if (amount - collected == 0)
        {
            Finish();
            notifyFinished();
            return;
        }
    }
    override protected void Action()
    {
        Agent.AddBehaviour(new ShowLabelBehaviour(Agent, "Gathering stone"));
        if (Vector3.Distance(stoneComponent.transform.position, backpackComponent.transform.position) > 2.0f)
        {
            Stop();
            Agent.AddBehaviour(new ShowLabelBehaviour(Agent, "Idle"));
            return;
        }
        if (startTime == 0)
        {
            startTime = Time.time;
        }
        if (stoneComponent.PiecesAvailable == 0)
        {
            Stop();
            Agent.AddBehaviour(new ShowLabelBehaviour(Agent, "Idle"));
        }

        if (Time.time - startTime > workDuration)
        {
            backpackComponent.hasStone = true;
            stoneComponent.PiecesAvailable--;
            Finish();
            Agent.AddBehaviour(new ShowLabelBehaviour(Agent, "Idle"));
        }
    }
    protected override void Action()
    {
        int amountOfWoodToCollect = calculateAmountOfResourceToCollect(MaterialConcept.MaterialType.Wood);

        if (amountOfWoodToCollect > 0)
        {
            Agent.AddBehaviour(new ScheduleCollectingWoodBehaviour(coordinatorAgent, controller));
            return;
        }
        else if (coordinatorAgent.GetAllJobsOfType(MaterialConcept.MaterialType.Wood).Count > 0)
        {
            Agent.AddBehaviour(new CancelAllJobsOfTypeBehaviour(coordinatorAgent, controller, MaterialConcept.MaterialType.Wood));
        }

        int amountOfStoneToCollect = calculateAmountOfResourceToCollect(MaterialConcept.MaterialType.Stone);

        if (amountOfStoneToCollect > 0)
        {
            Agent.AddBehaviour(new ScheduleCollectingStoneBehaviour(coordinatorAgent, controller));
            return;
        }
        else if (coordinatorAgent.GetAllJobsOfType(MaterialConcept.MaterialType.Stone).Count > 0)
        {
            Agent.AddBehaviour(new CancelAllJobsOfTypeBehaviour(coordinatorAgent, controller, MaterialConcept.MaterialType.Stone));
        }
        Finish();
    }
    override protected void Action()
    {
        Agent.AddBehaviour(new ShowLabelBehaviour(Agent, "Moving"));
        float step = Time.deltaTime * speed;

        if (Vector3.Distance(gameObject.transform.position, finalPosition) < 2.0)
        {
            Finish();
            Agent.AddBehaviour(new ShowLabelBehaviour(Agent, "Idle"));
            return;
        }
        gameObject.transform.position = Vector3.MoveTowards(gameObject.transform.position, finalPosition, step);
    }
Ejemplo n.º 5
0
 override protected void Action()
 {
     Agent.AddBehaviour(new ShowLabelBehaviour(Agent, "Putting material to storage"));
     if (Vector3.Distance(storageComponent.transform.position, backpackComponent.transform.position) > 2.0f)
     {
         Stop();
         Agent.AddBehaviour(new ShowLabelBehaviour(Agent, "Idle"));
         return;
     }
     if (backpackComponent.hasStone)
     {
         storageComponent.AddStone(1);
         backpackComponent.hasStone = false;
     }
     if (backpackComponent.hasWood)
     {
         storageComponent.AddWood(1);
         backpackComponent.hasWood = false;
     }
 }