コード例 #1
0
        public override List <Objective> GetSortedObjectives(BehaviorComponent agentComponent)
        {
            if (objectives.Count == 0)
            {
                List <PositionComponent> foods = ProceduralWorldSimulator.instance.foods;
                // AI goes here.
                //*
                if (UnityEngine.Random.value > .1f)
                {
                    // Building.
                    objectives.Add(new BuildObjective(agentComponent, new Vector2(UnityEngine.Random.Range(-10, 10), UnityEngine.Random.Range(-10, 10))));
                    Debug.Log("Starting objective to build something");
                }
                else if (UnityEngine.Random.value > .5)
                {
                    // Inventory.
                    InventoryComponent inventoryComponent = GetEntity().GetComponent <InventoryComponent> ();
                    if (!inventoryComponent.haulingSlot.IsFree())
                    {
                        // Drop it.
                        objectives.Add(new FullySpecifiedObjective(new DropEvent(inventoryComponent, inventoryComponent.haulingSlot, inventoryComponent.GetEntity().GetComponent <UnityMeshComponent> ())));
                        Debug.Log("Starting objective to drop hauled item");
                    }
                    else
                    {
                        // Pick something up.
                        if (foods.Count == 0)
                        {
                            return(new List <Objective> ());
                        }
                        var targetFood = foods [UnityEngine.Random.Range(0, foods.Count - 1)];
                        if (targetFood.GetEntity().GetComponent <CarriableComponent> ().carrier == null)
                        {
                            Debug.Log("Starting objective to pick up food at " + targetFood.position);
                            objectives.Add(new FullySpecifiedObjective(new PickUpEvent(inventoryComponent, targetFood.GetEntity().GetComponent <CarriableComponent> (), inventoryComponent.GetEntity().GetComponent <UnityMeshComponent> ())));
                        }
                    }
                }
                else
                {
                    // Eating.
                    if (foods.Count == 0)
                    {
                        return(new List <Objective> ());
                    }
                    var targetFood = foods [UnityEngine.Random.Range(0, foods.Count - 1)];
                    Debug.Log("Starting objective to eat food at " + targetFood.position);
                    objectives.Add(new FullySpecifiedObjective(new EatEvent(GetEntity(), targetFood)));
                }                //*/
                if (objectives.Count == 0)
                {
                    Debug.Log("No objectives!!!");
                }
            }
            else
            {
                Objective obj = objectives [0];
                if (obj is FullySpecifiedObjective)
                {
                    FullySpecifiedObjective fso = (FullySpecifiedObjective)obj;
                    if (fso.wayToDoObjective is PickUpEvent)
                    {
                        Math.Sqrt(2);
                    }
                }
                Math.Sqrt(2);
            }

            return(objectives);
        }
コード例 #2
0
 public void NotifyOfCompleteObjective(Objective obj)
 {
     //if(obj.IsComplete()) // TODO this may be needed
     objectives.Remove(obj);
 }