Ejemplo n.º 1
0
        /// <summary>
        /// Remove all agents from the slots they currently paticipate in and delete them.
        /// </summary>
        public void killAll()
        {
            for (int i = 0; i < spawnedObjects.Length; i++)
            {
                if (spawnedObjects [i] != null)
                {
                    NEEDSIM.NEEDSIMNode node = spawnedObjects[i].GetComponent <NEEDSIM.NEEDSIMNode>();

                    Simulation.Slot activeSlot = node.Blackboard.activeSlot;
                    node.AffordanceTreeNode.Remove();

                    if (activeSlot != null)
                    {
                        activeSlot.AgentDeparture();
                    }
                    else
                    {
                        Debug.Log("Active slot was null");
                    }



                    GameObject.Destroy(spawnedObjects[i]);
                    PopulationCount--;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Do the necessary stept to follow up on accepting a slot. Set destination on nav mesh, and put agent into the correct state
        /// </summary>
        /// <param name="slot"></param>
        /// <returns></returns>
        public bool AcceptSlot(Simulation.Slot slot)
        {
            NavMeshAgent.SetDestination(slot.Position); //This has to be replaced if not using the Unity NavMesh.
            currentState = Blackboard.AgentState.MovingToSlot;
            activeSlot   = slot;

            return(true);
        }