private void SetupMemory()
        {
            GameObject go = new GameObject("Memory");

            controller = new GameObject().AddComponent <MemoryController>();

            shortTermInfluencer         = new GameObject("ShortTermInfluencer");
            shortTermNegativeInfluencer = new GameObject("ShortTermInfluencer1");

            shortTermMemory           = ScriptableObject.CreateInstance <MemorySO>();
            shortTermMemory.about     = shortTermInfluencer;
            shortTermMemory.statName  = "ShortTermTest";
            shortTermMemory.influence = 5;
            shortTermMemory.cooldown  = 0.1f;

            shortTermMemoryNegativeInflunce           = ScriptableObject.CreateInstance <MemorySO>();
            shortTermMemoryNegativeInflunce.about     = shortTermNegativeInfluencer;
            shortTermMemoryNegativeInflunce.statName  = "ShortTermTestNegativeInfluence";
            shortTermMemoryNegativeInflunce.influence = -5;

            longTermInfluencer = new GameObject("LongTermInfluencer");

            longTermMemory           = ScriptableObject.CreateInstance <MemorySO>();
            longTermMemory.about     = longTermInfluencer;
            longTermMemory.statName  = "LongTermTest";
            longTermMemory.influence = 50;
            longTermMemory.cooldown  = 0;

            // Validate setup
            Assert.Zero(controller.GetShortTermMemories().Length, "There are short term memories in a new Memory Controller");
            Assert.Zero(controller.GetLongTermMemories().Length, "There are long term memories in a new Memory Controller");
        }
Esempio n. 2
0
        public IEnumerator LongTermMemoryCommit()
        {
            SetupMemory();

            // Add the first memory destined for long term memory, should go into short term
            controller.AddMemory(longTermMemory);
            Assert.NotZero(controller.GetShortTermMemoriesAbout(longTermInfluencer).Length, "There are no short term memories even after adding a memory");
            Assert.Zero(controller.GetLongTermMemories().Length, "There are long term memories in a new Memory Controller");

            // Add the second memory destined for long term memory, should go into short term
            controller.AddMemory(longTermMemory);
            Assert.AreEqual(1, controller.GetShortTermMemoriesAbout(longTermInfluencer).Length);
            Assert.Zero(controller.GetLongTermMemories().Length, "There still shouldn't be any long term memories after adding three short terms.");

            // Add one more short term memory, this should push the two destined for long term into long term to make space for the short term
            controller.AddMemory(shortTermMemory);
            Assert.AreEqual(1, controller.GetShortTermMemoriesAbout(shortTermInfluencer).Length, "There should be 3 memories about " + shortTermInfluencer.name + " short term items in short term memory at this point");
            Assert.AreEqual(1, controller.GetLongTermMemoriesAbout(longTermInfluencer).Length, "There should now be a long term memory.");

            yield return(null);
        }