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()); }
private void InitRotatePattern(string pattern) { rotatePattern = new PatternParser(pattern, true); if (rotatePattern.GetNextExecution() != null) { nextRotateAction = Time.time + (float)rotatePattern.GetNextExecution() / 1000f; } }
private void InitSpawnPattern(string pattern) { spawnPattern = new PatternParser(pattern, true); if (spawnPattern.GetNextExecution() != null) { nextSpawnAction = Time.time + (float)spawnPattern.GetNextExecution() / 1000f; } }
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()); }
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(); } }
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()); }
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(); } }