Esempio n. 1
0
    private void Update()
    {
        if (actionsQueue.Count == 0)
        {
            AbstractAction action = PickAction();
            actionsQueue.Add(action);
        }

        currentAction.Execute();
        currentAction.Update();

        if (currentAction.IsDone())
        {
            currentAction = actionsQueue[0];
            actionsQueue.RemoveAt(0);
        }

        if (eggTimer >= Random.Range(minEggFrequency, maxEggFrequency))
        {
            EggBehaviour newEgg = Instantiate(egg, new Vector3(transform.position.x, transform.position.y, transform.position.z - transform.forward.z * -1), Quaternion.identity);
            newEgg.transform.GetChild(0).GetComponent <MeshRenderer>().material.color = transform.GetChild(0).GetComponent <MeshRenderer>().material.color;
            eggTimer = 0;
        }

        eggTimer += Time.deltaTime;
    }
Esempio n. 2
0
 void Update()
 {
     if (currentAction != null && currentAction.IsDone() && actionQ.Any())
     {
         currentAction = actionQ.Dequeue();
         currentAction.Execute();
     }
 }
 public void Process()
 {
     Queue<AbstractAction> actions_incomplete = new Queue<AbstractAction>();
     while(actionList.Count>0)
     {
         AbstractAction action_to_process = actionList.Dequeue();
         action_to_process.update();
         if (!action_to_process.IsDone())
             actions_incomplete.Enqueue(action_to_process);
     }
     actionList = actions_incomplete;
 }