public Sleep(GOAPAgent agent, Game game, Thing thing, Movement movement, Villager villager, Needs needs) : base(agent, game) { _thing = thing; _movement = movement; _villager = villager; _needs = needs; Goal = GOAPGoal.Goal.IS_RESTED; Preconditions.Add(GOAPAction.Effect.IS_RESTED, false); Preconditions.Add(GOAPAction.Effect.HAS_THING, TypeOfThing.None); Effects.Add(GOAPAction.Effect.IS_RESTED, true); }
/* * Survival */ public override void Awake() { base.Awake(); _thing = GetComponent <Thing>(); _game = FindObjectOfType <Game>(); _movement = transform.gameObject.AddComponent <Movement>(); _inventory = _thing.Inventory; Needs = transform.gameObject.AddComponent <Needs>(); _firstname = NameGenerator.GenerateFirstName(); _lastname = NameGenerator.GenerateLastName(); _thing.name = string.Format("{0} {1}", _firstname, _lastname); _villagerManager = MonoBehaviour.FindObjectOfType <VillageManager>(); //IdleAction = new Idle(this, _game, _movement); AddGoal(new IdleGoal()); AddGoal(new WorkingGoal()); AddGoal(new DrinkGoal(Needs)); AddGoal(new EatGoal(Needs)); AddGoal(new RestGoal(_game, Needs)); /* * Misc */ AddAction(new Drop(this, _game)); AddAction(new Sleep(this, _game, _thing, _movement, this, Needs)); AddAction(new Idle(this, _game, _movement)); AddAction(new ChopWood(this, _game, _movement)); AddAction(new PickMushroom(this, _game, _movement)); AddAction(new GetClayFromGround(this, _game, _movement)); /* * Survival */ AddAction(new DrinkFromStream(this, _game, _movement)); AddAction(new EastSomething(this, _game, _thing)); AddAction(new HasEdibleThing(this, _game, TypeOfThing.Mushroom)); /* * Resources */ var resources = new TypeOfThing[] { TypeOfThing.Water, TypeOfThing.Stream, TypeOfThing.Rock, TypeOfThing.Stone, TypeOfThing.MushroomGrowing, TypeOfThing.Mushroom, TypeOfThing.Tree, TypeOfThing.FallenWood, TypeOfThing.Wood, TypeOfThing.WoodenPlanks, TypeOfThing.ClayFloor, TypeOfThing.Clay, TypeOfThing.OreFloor, TypeOfThing.Ore, TypeOfThing.Iron, TypeOfThing.CabbageSeed, TypeOfThing.PotatoSeed, TypeOfThing.CarrotSeed, TypeOfThing.PumpkinSeed, TypeOfThing.HopSeed, TypeOfThing.TomatoSeed, TypeOfThing.Cabbage, TypeOfThing.PotatoSeed, TypeOfThing.Carrot, TypeOfThing.Hops, TypeOfThing.Axe, TypeOfThing.Hoe, TypeOfThing.WateringPot }; foreach (var resource in resources) { AddAction(new GetThing(this, _game, _thing, _movement, resource)); //AddAction(new GetThingToMoveToStorage(this, _game, _thing, _movement, resource, this)); //AddAction(new FillStorage(this, _game, _movement, _thing.Inventory, resource)); } /* * Factory Job */ // var factoryJobs = new List<Tuple<TypeOfThing, TypeOfThing, TypeOfThing, bool>>() // { // Tuple.Create(TypeOfThing.ClayForge, TypeOfThing.Ore, TypeOfThing.Iron, false), // Tuple.Create(TypeOfThing.Workbench, TypeOfThing.Iron, TypeOfThing.Axe, true), // Tuple.Create(TypeOfThing.Workbench, TypeOfThing.Iron, TypeOfThing.Hoe, true), // Tuple.Create(TypeOfThing.CarpentersBench, TypeOfThing.Wood, TypeOfThing.WoodenPlanks, true), // Tuple.Create(TypeOfThing.Kiln, TypeOfThing.Clay, TypeOfThing.WateringPot, false) // }; // foreach(var job in factoryJobs) // { // AddAction(new SubmitFactoryJob(this, _game, _thing, _movement, job.Item1, job.Item2, job.Item3, job.Item4)); // } /* * Construction */ AddAction(new Construct(this, _game, _movement, TypeOfThing.Wood, _thing)); AddAction(new Construct(this, _game, _movement, TypeOfThing.WoodenPlanks, _thing)); AddAction(new Construct(this, _game, _movement, TypeOfThing.Stone, _thing)); AddAction(new Construct(this, _game, _movement, TypeOfThing.Clay, _thing)); AddAction(new Construct(this, _game, _movement, TypeOfThing.Hoe, _thing)); AddAction(new Construct(this, _game, _movement, TypeOfThing.CabbageSeed, _thing)); AddAction(new Construct(this, _game, _movement, TypeOfThing.PotatoSeed, _thing)); AddAction(new Construct(this, _game, _movement, TypeOfThing.TomatoSeed, _thing)); AddAction(new Construct(this, _game, _movement, TypeOfThing.PumpkinSeed, _thing)); AddAction(new Construct(this, _game, _movement, TypeOfThing.CarrotSeed, _thing)); AddAction(new Construct(this, _game, _movement, TypeOfThing.Water, _thing)); AddAction(new Construct(this, _game, _movement, TypeOfThing.None, _thing)); }