コード例 #1
0
        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");
        }
コード例 #2
0
        public IEnumerator ShortTermMemoryCommit()
        {
            SetupMemory();

            // Add the three short term memories destined to stay in short term
            controller.AddMemory(shortTermMemory);
            Assert.AreEqual(1, controller.GetShortTermMemories().Length, "The first short term memory item was not committed to memory.");
            Assert.AreEqual(5, controller.GetShortTermMemoriesAbout(shortTermInfluencer)[0].influence);

            controller.AddMemory(shortTermMemory);
            Assert.AreEqual(1, controller.GetShortTermMemories().Length, "The second short term memory item should not have been committed as it is a duplicate of an existing short term memory.");

            controller.AddMemory(shortTermMemoryNegativeInflunce);
            Assert.AreEqual(2, controller.GetShortTermMemories().Length, "The short term memory item 1 should have been committed.");
            Assert.AreEqual(1, controller.GetShortTermMemoriesAbout(shortTermInfluencer).Length, "The first short term memory item was not committed to memory.");
            Assert.AreEqual(1, controller.GetShortTermMemoriesAbout(shortTermNegativeInfluencer).Length, "The first short term 1 memory item was not committed to memory.");
            Assert.AreEqual(-5, controller.GetShortTermMemoriesAbout(shortTermNegativeInfluencer)[0].influence);

            yield return(null);
        }