/// <summary> /// Copy an existing FoodSubject. /// </summary> public override Subject Copy() { FoodSubject newFoodSubject = new FoodSubject(); newFoodSubject.subjectID = subjectID; newFoodSubject.name = name; newFoodSubject.description = description; newFoodSubject.icon = icon; newFoodSubject.prefab = prefab; newFoodSubject.relatedSubjects = relatedSubjects; newFoodSubject.foodType = foodType; newFoodSubject.foodValue = foodValue; return(newFoodSubject); }
/// <summary> /// Modify status by eating something. /// </summary> /// <param name="FoodItem">The food item to be eaten.</param> /// <returns>True: Item consumed. False: Item not consumed.</returns> public bool Eat(InventoryItem FoodItem) { if (this.IsDead) { return(false); } bool wasConsumed = false; //check flags to make sure we're able to eat if (status.CanEat()) { if (food < definition.FoodMax) { status.SetState(NpcStates.Eating); //set eating flag FoodSubject foodSubject = db.GetSubject(FoodItem.SubjectID, typeof(FoodSubject)) as FoodSubject; if (foodSubject != null) { food += foodSubject.FoodValue; food = System.Math.Min(food, definition.FoodMax); // heal a little when we eat. health += definition.HealthRegen * 2; health = Mathf.Min(health, definition.HealthMax); wasConsumed = true; } status.UnsetState(NpcStates.Eating); //unset eating flag } if (food >= definition.FoodMax) { drivers.Remove(NpcDrivers.Hunger); } } return(wasConsumed); }
public MasterSubjectList() { masterSubjectList = new List <Subject>(); //`-.,.-'-.,.-'-.,.-'-.,.-'-.,.-' maxID = DbIds.Plinkett; // == Plinkett //,.-`-.,.-`-.,.-`-.,.-`-.,.-`-., NpcDefinition plinkettNpcDefinition = new NpcDefinition() { Memories = new List <SubjectMemory>(), AttackDamage = 10, FoodHungry = 60, FoodMax = 100, FoodMetabolizeRate = 1, HealthDanger = 40, HealthMax = 50, HealthRegen = 1, MetabolizeInterval = 1, MoveSpeed = 5, Nest = null, SafetyDeadly = -10, SafetyHigh = 10, SightRangeFar = 10, SightRangeNear = 2.5f, StarvingDamage = 3, Traits = new NpcCharacterTraits(NpcTraits.Herbivore) }; AnimalSubject plinkett = new AnimalSubject() { Definition = plinkettNpcDefinition, Description = "A herbivore.", GrowthTime = 5, Icon = new UnityEngine.Sprite(), InventorySize = 1, LootID = 5, MatureTime = 200, MaxGrowth = 400, Name = "Plinkett", RelatedSubjects = new int[0], SubjectID = maxID, Prefab = Resources.Load("GameObjects/Plinkett") as GameObject }; masterSubjectList.Add(plinkett); //`-.,.-'-.,.-'-.,.-'-.,.-'-.,.-' maxID = DbIds.Location; // == Location //,.-`-.,.-`-.,.-`-.,.-`-.,.-`-., LocationSubject NewLocationOne = new LocationSubject() { Coordinates = new UnityEngine.Vector3(1, 1, 1), Description = "A very positional kind of location", Icon = new UnityEngine.Sprite(), Layer = 1, Name = "Location", Radius = 2, RelatedSubjects = new int[0], SubjectID = maxID, Prefab = Resources.Load("GameObjects/LocationMarker") as GameObject }; masterSubjectList.Add(NewLocationOne); //`-.,.-'-.,.-'-.,.-'-.,.-'-.,.-' maxID = DbIds.Bush; // == Bush //,.-`-.,.-`-.,.-`-.,.-`-.,.-`-., PlantSubject Bush = new PlantSubject() { SubjectID = maxID, Name = "Bush", Description = "A Berry Bush", Icon = new UnityEngine.Sprite(), RelatedSubjects = new int[0], Prefab = Resources.Load("GameObjects/Bush") as GameObject, ProduceID = 4, ProduceTime = 2, MaxGrowth = 30, GrowthTime = 1, MatureGrowth = 2, InventorySize = 3 }; masterSubjectList.Add(Bush); //`-.,.-'-.,.-'-.,.-'-.,.-'-.,.-' maxID = DbIds.Berry; // == Berry //,.-`-.,.-`-.,.-`-.,.-`-.,.-`-., FoodSubject Berry = new FoodSubject() { SubjectID = maxID, Name = "Berry", Description = "A Juicy Berry", Icon = new UnityEngine.Sprite(), RelatedSubjects = new int[0], BuildDirections = null, MaxStack = 10, FoodType = 0, FoodValue = 10 }; masterSubjectList.Add(Berry); //`-.,.-'-.,.-'-.,.-'-.,.-'-.,.-' maxID = DbIds.Meat; // == Meat //,.-`-.,.-`-.,.-`-.,.-`-.,.-`-., FoodSubject Meat = new FoodSubject() { SubjectID = maxID, Name = "Meat", Description = "It was once muscle...", Icon = new UnityEngine.Sprite(), RelatedSubjects = new int[0], BuildDirections = null, MaxStack = 10, FoodType = 1, FoodValue = 10 }; masterSubjectList.Add(Meat); //`-.,.-'-.,.-'-.,.-'-.,.-'-.,.-' maxID = DbIds.Gobber; // == Gobber //,.-`-.,.-`-.,.-`-.,.-`-.,.-`-., NpcDefinition gobberNpcDefinition = new NpcDefinition() { Memories = new List <SubjectMemory>(), AttackDamage = 10, FoodHungry = 50, FoodMax = 100, FoodMetabolizeRate = 1, HealthDanger = 40, HealthMax = 100, HealthRegen = 1, MetabolizeInterval = 1, MoveSpeed = 5, Nest = null, SafetyDeadly = -10, SafetyHigh = 10, SightRangeFar = 10, SightRangeNear = 2, StarvingDamage = 5, Traits = new NpcCharacterTraits(NpcTraits.Carnivore) }; AnimalSubject gobber = new AnimalSubject() { Definition = gobberNpcDefinition, Description = "A carnivore.", GrowthTime = 5, Icon = new UnityEngine.Sprite(), InventorySize = 1, LootID = 5, MatureTime = 200, MaxGrowth = 400, Name = "Gobber", RelatedSubjects = new int[0], SubjectID = maxID, Prefab = Resources.Load("GameObjects/Gobber") as GameObject }; masterSubjectList.Add(gobber); // \/ \/ DO NOT CHANGE \/ \/ maxID = DbIds.LastIndex; // /\ /\ DO NOT CHANGE /\ /\ }