// Use this for initialization void Start() { masterSubjectList = new MasterSubjectList(); centerPosition = new Vector3(); edgePosition = new Vector3(); placeID = -2; testPanel.SetActive(true); lastDistance = 0; cameraDestination = Camera.main.transform.position; }
/// <summary> /// Constructor for an Inventory object. Must set the initial size in constructor. /// </summary> /// <param name="newSize"></param> public Inventory(int newSize, MasterSubjectList masterSubjectListRef) { size = newSize; inventorySlots = new InventoryItem[size]; for (int i = 0; i < size; i++) { inventorySlots[i] = new InventoryItem(); } masterSubjectList = masterSubjectListRef; }
public override void InitializeFromSubject(MasterSubjectList _masterSubjectList, Subject newSubject) { AiTickRate = 0.5f; isDead = false; subject = newSubject as AnimalSubject; masterSubjectList = _masterSubjectList; npcCharacter = new NpcCore(this, masterSubjectList, subject); Inventory = new Inventory((subject as AnimalSubject).InventorySize, masterSubjectList); destinationWayPoints = new Vector3[0]; isCurrentLocationExplored = false; }
/// <summary> /// Sets the stack, but limits based on subject MaxStack /// </summary> /// <param name="newSubjectID"></param> /// <param name="newStackSize"></param> /// <param name="masterSubjectList"></param> /// <returns></returns> public bool SetStack(int newSubjectID, int newStackSize, MasterSubjectList masterSubjectList) { ItemSubject newSubject = masterSubjectList.GetSubject(newSubjectID, typeof(ItemSubject)) as ItemSubject; if (newSubject != null) { subjectID = newSubjectID; stackSize = Math.Min(newStackSize, newSubject.MaxStack); return(true); } else { return(false); } }
/// <summary> /// Adds to the stack, limits based on the subject MaxStack /// </summary> /// <param name="newSubjectID"></param> /// <param name="newStackSize"></param> /// <param name="masterSubjectList"></param> /// <returns></returns> public int Add(int newSubjectID, int newStackSize, MasterSubjectList masterSubjectList) { if (newSubjectID != subjectID) { return(newStackSize); //reject entire amount } ItemSubject newSubject = masterSubjectList.GetSubject(newSubjectID) as ItemSubject; if (newSubject != null) { int tempStack = stackSize + newStackSize; stackSize = Math.Min(tempStack, newSubject.MaxStack); newStackSize = Math.Max(0, tempStack - newSubject.MaxStack); } return(newStackSize); }
/// <summary> /// Adds to the stack, limits based on the subject MaxStack /// </summary> /// <param name="addedInvItem"></param> /// <param name="masterSubjectList"></param> /// <returns></returns> public int Add(InventoryItem addedInvItem, MasterSubjectList masterSubjectList) { if (addedInvItem.subjectID != subjectID) { return(addedInvItem.stackSize); //reject entire amount } ItemSubject newSubject = masterSubjectList.GetSubject(addedInvItem.subjectID) as ItemSubject; if (newSubject != null) { int tempStack = stackSize + addedInvItem.stackSize; stackSize = Math.Min(tempStack, newSubject.MaxStack); addedInvItem.stackSize = Math.Max(0, tempStack - newSubject.MaxStack); } return(addedInvItem.stackSize); }
/// <summary> /// Create a generic NpcCharacter. /// </summary> /// <param name="ParentObjectScript">The in-game object that represents this NPC.</param> /// <param name="MasterSubjectListRef">A reference to the main MasterSubjectList.</param> public NpcCore(AnimalObjectScript ParentObjectScript, MasterSubjectList MasterSubjectListRef) { db = MasterSubjectListRef; objectScript = ParentObjectScript; health = 100; food = 100; safety = 100; definition = new NpcDefinition(); status = new NpcStatus(); drivers = new NpcDriversList(); unexploredLocations = new List <LocationSubject>(); subjectID = -1; searchedObjects = new List <int>(); searchedLocations = new List <int>(); reExploreLocations = new List <LocationSubject>(); SetFoodPreference(); }
/// <summary> /// Initialize a new NpcCharacter. /// </summary> /// <param name="ParentObject">The in-game object that represents this NPC.</param> /// <param name="MasterSubjectListRef">A reference to the main MasterSubjectList.</param> /// <param name="BasedOnSubject">Subject's NpcDefinition will define the character's initial resource pools, thresholds for fulfilling basic needs, and memories.</param> public NpcCore(AnimalObjectScript ParentObjectScript, MasterSubjectList MasterSubjectListRef, Subject BasedOnSubject) { db = MasterSubjectListRef; if (BasedOnSubject is AnimalSubject) { objectScript = ParentObjectScript; AnimalSubject animalSubject = BasedOnSubject as AnimalSubject; definition = animalSubject.Definition; subjectID = animalSubject.SubjectID; health = definition.HealthMax; food = definition.FoodMax; safety = definition.SafetyHigh; status = new NpcStatus(); drivers = new NpcDriversList(); unexploredLocations = new List <LocationSubject>(); searchedObjects = new List <int>(); searchedLocations = new List <int>(); reExploreLocations = new List <LocationSubject>(); SetFoodPreference(); } }
/// <summary> /// Set this Plant Object's variables from the subject card /// </summary> /// <param name="_masterSubjectList"></param> /// <param name="newSubject"></param> public override void InitializeFromSubject(MasterSubjectList _masterSubjectList, Subject newSubject) { masterSubjectList = _masterSubjectList; subject = newSubject; if (newSubject is PlantSubject) { PlantSubject plantSubject = newSubject as PlantSubject; produceID = plantSubject.ProduceID; produceTime = plantSubject.ProduceTime; maxGrowth = plantSubject.MaxGrowth; growthTime = plantSubject.GrowthTime; matureGrowth = plantSubject.MatureGrowth; inventory = new Inventory(plantSubject.InventorySize, _masterSubjectList); mature = false; age = 0.1f; currentGrowth = 0.5f; lastProduce = Time.time; } else { //default values used if no valid subject for initialization produceID = 1; produceTime = 20; maxGrowth = 1; growthTime = 20; matureGrowth = 15; inventory = new Inventory(3, _masterSubjectList); mature = false; age = 0.1f; currentGrowth = 5.0f; lastProduce = Time.time; } gameObject.transform.localScale = new Vector3(currentGrowth * 0.01f + 0.5f, currentGrowth * 0.02f + 0.5f, currentGrowth * 0.01f + 0.5f); }
public override void InitializeFromSubject(MasterSubjectList _masterSubjectList, Subject newSubject) { subject = newSubject as LocationSubject; count = 0; }
/// <summary> /// Will be used by derived classes /// </summary> /// <param name="_masterSubjectList"></param> /// <param name="newSubject"></param> public abstract void InitializeFromSubject(MasterSubjectList _masterSubjectList, Subject newSubject);