/// <summary> /// !!! FOR TESTING ONLY DO NOT USE !!! <para/> /// Given: A Gobber is hungry and is within range of a Plinkett. <para /> /// When: Plinkett is attacked by Gobber.<para /> /// Then: Plinkett's memory of Gobber has negative safety.<para /> /// </summary> /// <returns>Success/Fail</returns> public bool T_PlinkettSafetyLearning() { bool testResult = false; // Ross -- Tested & working 8/8/17 19:45 // Given: A Gobber is hungry and is within range of a Plinkett. Subject newSubject = masterSubjectList.GetSubject(DbIds.Plinkett); GameObject testPlinkett = Instantiate(newSubject.Prefab, new Vector3(0, 0, 1), Quaternion.identity); AnimalObjectScript sPlinkett = testPlinkett.GetComponent <AnimalObjectScript>(); sPlinkett.InitializeFromSubject(masterSubjectList, newSubject); // When: Plinkett is attacked by Gobber. sPlinkett.Damage(masterSubjectList.GetSubject(DbIds.Gobber), 10); // Then: Plinkett's memory of Gobber has negative safety. SubjectMemory subMem = sPlinkett.T_Npc.T_GetMemory(6); List <SubjectMemory> sMem = sPlinkett.T_Npc.T_Memories; if (subMem != null) { testResult = (subMem.Safety < 0); } else { testResult = false; } Destroy(testPlinkett); return(testResult); }
/// <summary> /// Checks the attitude of the NPC towards conSubject. IsSubjectKnown() must be used to verify the Subject is known before IsSubjectDangerous(). /// </summary> /// <param name="conSubject">The Subject to be considered.</param> /// <returns>True = dangerous; False = not dangerous. If conSubject does not exist and Exception will be thrown.</returns> internal bool IsSubjectDangerous(Subject conSubject) { if (IsSubjectKnown(conSubject)) { SubjectMemory subjectAttitude = definition.Memories.Find(o => o.SubjectID == conSubject.SubjectID); return(subjectAttitude.Safety < 0); } else { throw new Exception("The queried Subject is not in the memories list."); } }
public SubjectMemory(SubjectMemory copySubjectMemory) { subjectID = copySubjectMemory.subjectID; safety = copySubjectMemory.safety; food = copySubjectMemory.food; }