public IEnumerator Evaluate(GameLevel gameLevel, int loopDepth, LevelLoop parentLoop) { // Main loop should always break out immediately upon finishing. if (!gameLevel.MainLoop.ShouldContinue(gameLevel)) { gameLevel.CompleteLevel(); yield break; } switch (this.Type) { case LoopType.Do: do { yield return(EvaluateChildren(gameLevel, loopDepth, this)); }while (ShouldContinue(gameLevel)); yield break; case LoopType.For: for (this.Iterator = 0; ShouldContinue(gameLevel); this.Iterator++) { yield return(EvaluateChildren(gameLevel, loopDepth, this)); } yield break; case LoopType.While: while (ShouldContinue(gameLevel)) { yield return(EvaluateChildren(gameLevel, loopDepth, this)); } yield break; case LoopType.If: if (ShouldContinue(gameLevel)) { yield return(EvaluateChildren(gameLevel, loopDepth, this)); } yield break; case LoopType.None: yield return(EvaluateChildren(gameLevel, loopDepth, this)); yield break; } gameLevel.UpdateLevelCode(); }
public IEnumerator Evaluate(GameLevel gameLevel) { if (this.Type == CodeStatementType.Assignment) { yield return(EvaluateAssignment(gameLevel)); } else if (this.Type == CodeStatementType.Method) { yield return(EvaluateMethod(gameLevel)); } else if (this.Type == CodeStatementType.Sleep) { yield return(EvaludateSleep(gameLevel)); } gameLevel.UpdateLevelCode(); }
private IEnumerator EvaluateChildren(GameLevel gameLevel, int loopDepth, LevelLoop parentLoop) { // Main loop should always break out immediately upon finishing. if (!gameLevel.MainLoop.ShouldContinue(gameLevel)) { gameLevel.CompleteLevel(); yield break; } foreach (CodeStatement statement in this.Statements) { yield return(statement.Evaluate(gameLevel)); } foreach (LevelLoop nestedLoop in this.NestedLoops) { yield return(nestedLoop.Evaluate(gameLevel, loopDepth + 1, parentLoop)); } gameLevel.UpdateLevelCode(); yield return(null); }
public void ContinueRitualSummoning() { if (GameLevel == null) { return; } LevelVariable levelVariable = GameLevel.GetVariable("summoningProgress"); if (levelVariable == null) { levelVariable = new LevelVariable(); levelVariable.Name = "summoningProgress"; levelVariable.DataValue = "1"; GameLevel.SetVariable(levelVariable); } else if (int.TryParse(levelVariable.DataValue, out int value)) { levelVariable.DataValue = (value + 1).ToString(); GameLevel.UpdateLevelCode(); } }