private void ExecuteConditionCommand(ConditionCommand command) { int a, b; switch (command) { case ConditionCommand.LessThan: b = IntStack.Pop(); a = IntStack.Pop(); BoolStack.Push(a < b); break; case ConditionCommand.GreaterThan: b = IntStack.Pop(); a = IntStack.Pop(); BoolStack.Push(a > b); break; case ConditionCommand.Equals: b = IntStack.Pop(); a = IntStack.Pop(); BoolStack.Push(a == b); break; case ConditionCommand.NotEquals: b = IntStack.Pop(); a = IntStack.Pop(); BoolStack.Push(a != b); break; } }
public void Reset() { m_isList = false; m_isOr = false; m_isNot = false; m_conditionCommand = null; }
public void ReadStoryFormFile() { Command command = new Command(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(story.text); XmlNodeList storyElementList = xmlDoc.SelectSingleNode("/Story").ChildNodes; foreach (XmlNode _storyElement in storyElementList) { StoryElement storyElement = new StoryElement(); XmlNode conditionListNode = _storyElement.SelectSingleNode("ConditionList"); XmlNode TaskNode = _storyElement.SelectSingleNode("Task"); XmlNode dialogListNode = _storyElement.SelectSingleNode("DialogList"); XmlNode npcActionListNode = _storyElement.SelectSingleNode("NpcActionList"); if (conditionListNode != null) { List <Condition> ConditionList; ConditionList = ReadConditionList(conditionListNode); ConditionCommand conditionCommand = new ConditionCommand(ConditionList); storyElement.commandList.Add(conditionCommand); } if (dialogListNode != null) { List <Dialog> DialogList; DialogList = ReadDialogList(dialogListNode); DialogCommand dialogCommand = new DialogCommand(DialogList); storyElement.commandList.Add(dialogCommand); } if (npcActionListNode != null) { List <NpcAction> NpcActionList; NpcActionList = ReadNpcActionList(npcActionListNode); NpcActionCommand npcActionCommand = new NpcActionCommand(NpcActionList); storyElement.commandList.Add(npcActionCommand); } if (TaskNode != null) { Task task; task = ReadTask(TaskNode); TaskCommand taskCommand = new TaskCommand(task); storyElement.commandList.Add(taskCommand); } storyList.Add(storyElement); } }