Ejemplo n.º 1
0
        public void ComplexPattern()
        {
            PatternParser p = new PatternParser("500,x,20,y,loop 1,2,50,z");

            Assert.True(p.GetNextExecution() > 0);
            Assert.AreEqual("x", p.GetNextAction());

            p.Next();

            Assert.True(p.GetNextExecution() > 0);
            Assert.AreEqual("y", p.GetNextAction());

            p.Next();

            Assert.True(p.GetNextExecution() > 0);
            Assert.AreEqual("y", p.GetNextAction());

            p.Next();

            Assert.True(p.GetNextExecution() > 0);
            Assert.AreEqual("y", p.GetNextAction());

            p.Next();

            Assert.True(p.GetNextExecution() > 0);
            Assert.AreEqual("z", p.GetNextAction());

            p.Next();

            Assert.IsNull(p.GetNextExecution());
            Assert.IsNull(p.GetNextAction());
        }
Ejemplo n.º 2
0
 private void InitRotatePattern(string pattern)
 {
     rotatePattern = new PatternParser(pattern, true);
     if (rotatePattern.GetNextExecution() != null)
     {
         nextRotateAction = Time.time + (float)rotatePattern.GetNextExecution() / 1000f;
     }
 }
Ejemplo n.º 3
0
 private void InitSpawnPattern(string pattern)
 {
     spawnPattern = new PatternParser(pattern, true);
     if (spawnPattern.GetNextExecution() != null)
     {
         nextSpawnAction = Time.time + (float)spawnPattern.GetNextExecution() / 1000f;
     }
 }
Ejemplo n.º 4
0
        public void EmptyPattern()
        {
            PatternParser p = new PatternParser("");

            Assert.IsNull(p.GetNextExecution());
            Assert.IsNull(p.GetNextAction());

            p = new PatternParser(null);

            Assert.IsNull(p.GetNextExecution());
            Assert.IsNull(p.GetNextAction());
        }
Ejemplo n.º 5
0
        public void GlobalLoopingPattern()
        {
            PatternParser p = new PatternParser("500,x", true);

            for (int i = 0; i < 100; i++)
            {
                Assert.True(p.GetNextExecution() > 0);
                Assert.AreEqual("x", p.GetNextAction());

                p.Next();
            }
        }
Ejemplo n.º 6
0
        public void SimplePattern()
        {
            PatternParser p = new PatternParser("500 , x");

            Assert.True(p.GetNextExecution() > 0);
            Assert.AreEqual("x", p.GetNextAction());

            p.Next();

            Assert.IsNull(p.GetNextExecution());
            Assert.IsNull(p.GetNextAction());
        }
Ejemplo n.º 7
0
        public void InfinitePattern()
        {
            PatternParser p = new PatternParser("50,x,20,y,10,z,loop 3,*");

            for (int i = 0; i < 100; i++)
            {
                Assert.True(p.GetNextExecution() > 0);
                Assert.AreEqual("x", p.GetNextAction());

                p.Next();

                Assert.True(p.GetNextExecution() > 0);
                Assert.AreEqual("y", p.GetNextAction());

                p.Next();

                Assert.True(p.GetNextExecution() > 0);
                Assert.AreEqual("z", p.GetNextAction());

                p.Next();
            }
        }