Example #1
0
    private string ParseLevelAction(string parsingState, Match token)
    {
        if (token.Groups["EndSequence"].Length != 0)
        {
            if (this.conditionStack.Count > 0)
            {
                ADLConditionAction condition = this.conditionStack.Pop();
                condition.totalActions = this.currentSequence.actions.Count - this.currentSequence.actions.IndexOf(condition) - 1;
                this.Log("End Condition");
            }
            else
            {
                parsingState = this.compilerStack.Pop();
            }
        }
        else if (token.Groups["Action"].Length != 0)
        {
            this.compilerStack.Push(parsingState);
            parsingState = "parameter";

            this.Log("Action : " + token.Groups["Action"]);

            ADLAction    action    = this.createNewADLAction(token.Groups["Action"].Value);
            ADLParameter parameter = new ADLParameter();
            this.currentAction    = action;
            this.currentParameter = parameter;
            this.currentAction.parameters.Add(parameter);
            this.currentSequence.actions.Add(action);
        }
        else if (token.Groups["If"].Length != 0)
        {
            this.compilerStack.Push(parsingState);
            parsingState = "parameter";

            ADLConditionAction action    = new ADLConditionAction(token.Groups["Action"].Value);
            ADLParameter       parameter = new ADLParameter();
            this.currentAction    = action;
            this.currentParameter = parameter;
            this.currentAction.parameters.Add(parameter);
            this.currentSequence.actions.Add(action);

            this.conditionStack.Push(action);
        }
        else if (token.Groups["Else"].Length != 0)
        {
        }
        return(parsingState);
    }
Example #2
0
 private void UpdateSimulationState()
 {
     foreach (ADLSequence seq in this.simulationState.currentState.seqs)
     {
         int       currentSequenceIndex = this.simulationState.sequenceIndexes[seq.name];
         ADLAction action = seq.actions[currentSequenceIndex];
         if (action is SpannableAction)
         {
             if (((SpannableAction)action).IsEnd())
             {
                 this.simulationState.IncreaseSequenceIndex(seq);
                 if (action is ADLMoveAction)
                 {
                     this.velocity = new Vector2(0, 0);
                 }
             }
         }
         else if (action is ADLToStateAction)
         {
             action.PerformAction(this);
             break;
         }
         else if (action is ADLConditionAction)
         {
             ADLConditionAction condition = (ADLConditionAction)action;
             if (condition.PerformAction(this))
             {
                 this.simulationState.IncreaseSequenceIndex(seq);
             }
             else
             {
                 this.simulationState.IncreaseSequenceIndex(seq, condition.totalActions + 1);
             }
         }
         else
         {
             this.simulationState.IncreaseSequenceIndex(seq);
         }
     }
 }