Пример #1
0
        private static MockCriterion CreateTutorial(out Tutorial tutorial)
        {
            var textParagraph = new TutorialParagraph();

            textParagraph.m_Type = ParagraphType.Instruction;

            var instructionParagraph = new TutorialParagraph();

            instructionParagraph.m_Type = ParagraphType.Instruction;

            var c  = ScriptableObject.CreateInstance <MockCriterion>();
            var tc = new TypedCriterion(new SerializedType(typeof(MockCriterion)), c);

            instructionParagraph.m_Criteria = new TypedCriterionCollection(new[] { tc });


            var page1 = ScriptableObject.CreateInstance <TutorialPage>();

            page1.m_Paragraphs = new TutorialParagraphCollection(new[] { textParagraph });

            var page2 = ScriptableObject.CreateInstance <TutorialPage>();

            page2.m_Paragraphs = new TutorialParagraphCollection(new[] { instructionParagraph });

            var page3 = ScriptableObject.CreateInstance <TutorialPage>();

            page3.m_Paragraphs = new TutorialParagraphCollection(new[] { textParagraph });

            tutorial = ScriptableObject.CreateInstance <Tutorial>();

            tutorial.m_Pages = new Tutorial.TutorialPageCollection(new[] { page1, page2, page3 });
            return(c);
        }
Пример #2
0
        public void PageDoesNotPlayCompletionSound_WhenCompletedCriterionIsNotActiveInstruction()
        {
            MockCriterion secondCriterion = null;

            try
            {
                secondCriterion = ScriptableObject.CreateInstance <MockCriterion>();
                var secondInstruction = new TutorialParagraph
                {
                    m_Type     = ParagraphType.Instruction,
                    m_Criteria = new TypedCriterionCollection(
                        new[] { new TypedCriterion(new SerializedType(typeof(MockCriterion)), secondCriterion) }
                        )
                };
                m_Page.m_Paragraphs =
                    new TutorialParagraphCollection(new[] { m_Page.paragraphs.First(), secondInstruction });

                var playedSound = false;
                m_Page.playedCompletionSound += page => playedSound = true;

                secondCriterion.Complete(true);
                Assert.IsFalse(playedSound, "Played sound for second step when first step was not yet completed.");
            }
            finally
            {
                if (secondCriterion != null)
                {
                    UnityObject.DestroyImmediate(secondCriterion);
                }
            }
        }
Пример #3
0
        public void SetUp()
        {
            m_Tutorial = ScriptableObject.CreateInstance <Tutorial>();

            m_Tutorial.m_Pages = new Tutorial.TutorialPageCollection(
                new[] { ScriptableObject.CreateInstance <TutorialPage>(), ScriptableObject.CreateInstance <TutorialPage>() }
                );
            for (int i = 0; i < m_Tutorial.m_Pages.count; ++i)
            {
                m_Tutorial.m_Pages[i].name       = string.Format("{0}-PAGE-{1}", TestContext.CurrentContext.Test.FullName, i + 1);
                m_Tutorial.m_Pages[i].DoneButton = doneButtonText;
                m_Tutorial.m_Pages[i].NextButton = nextButtonText;
            }

            var paragraph = new TutorialParagraph
            {
                m_Type     = ParagraphType.Instruction,
                m_Criteria = new TypedCriterionCollection(
                    new[]
                {
                    new TypedCriterion(new SerializedType(typeof(MockCriterion)), ScriptableObject.CreateInstance <MockCriterion>())
                }
                    )
            };

            paragraph.Title = firstPageInstructionSummary;
            paragraph.Text  = firstPageInstructionText;
            m_Tutorial.m_Pages[0].m_Paragraphs = new TutorialParagraphCollection(new[] { paragraph });

            m_Window = EditorWindow.GetWindow <TutorialWindow>();
            TutorialWindow.ShowTutorialsClosedDialog.SetValue(false);
            m_Window.SetTutorial(m_Tutorial, reload: false);
        }
Пример #4
0
        public void SetUp()
        {
            m_Page = ScriptableObject.CreateInstance <TutorialPage>();

            var instructionParagraph = new TutorialParagraph();

            instructionParagraph.m_Type = ParagraphType.Instruction;

            m_Criterion = ScriptableObject.CreateInstance <MockCriterion>();
            var tc = new TypedCriterion(new SerializedType(typeof(MockCriterion)), m_Criterion);

            instructionParagraph.m_Criteria = new TypedCriterionCollection(new[] { tc });

            m_Page.m_Paragraphs = new TutorialParagraphCollection(new[] { instructionParagraph });

            m_Page.Initiate();
        }