private IEnumerator EvaluateAssignment(GameLevel gameLevel) { LevelVariable variable = gameLevel.GetVariable(this.Arguments[0]); LevelVariable assignmentVariable = gameLevel.GetVariable(this.Arguments[1]); if (assignmentVariable != null) { variable.DataValue = assignmentVariable.DataValue; variable.ObjectValue = assignmentVariable.ObjectValue; } else { variable.DataValue = this.Arguments[1]; } yield return(null); }
private IEnumerator EvaludateSleep(GameLevel gameLevel) { LevelVariable variable = gameLevel.GetVariable(this.Arguments[0]); int sleepTime = (variable != null) ? int.Parse(variable.DataValue) : int.Parse(this.Arguments[0]); yield return(new WaitForSeconds(sleepTime)); }
public bool ShouldContinue(GameLevel gameLevel, string leftValue = null) { // TODO: Shoddy for loop. if (this.VariableName == null) { return(false); } if (leftValue == null) { LevelVariable leftVariable = gameLevel.GetVariable(this.VariableName); if (leftVariable == null) { return(false); } leftValue = leftVariable.AsString(); } LevelVariable rightVariable = gameLevel.GetVariable(this.Value); string rightValue = rightVariable != null ? rightVariable.AsString() : this.Value; switch (this.Is) { case Evaluator.Equals: return(leftValue == rightValue); case Evaluator.LessThan: return(int.Parse(leftValue) < int.Parse(rightValue)); case Evaluator.MoreThan: return(int.Parse(leftValue) > int.Parse(rightValue)); case Evaluator.Not: return(leftValue != rightValue); } return(false); }
public string ToString(GameLevel gameLevel, string forIterator = null) { string conditionVariable = forIterator != null ? forIterator : this.VariableName; string valueString = this.Value; LevelVariable valueVariable = gameLevel.GetVariable(this.Value); if (valueVariable != null) { valueString = valueVariable.Name; } return ($"{conditionVariable} {StringValueAttribute.StringEnum.GetStringValue(this.Is)} {valueString}"); }
private IEnumerator EvaluateMethod(GameLevel gameLevel) { LevelVariable[] variables = new LevelVariable[this.Arguments.Length]; for (int i = 0; i < variables.Length; i++) { variables[i] = gameLevel.GetVariable(this.Arguments[i]); if (variables[i] == null) { variables[i] = new LevelVariable(); variables[i].Name = "argument"; variables[i].DataValue = this.Arguments[i]; } } this.InvokeMethod.Invoke(variables); 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(); } }