Ejemplo n.º 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);
    }
Ejemplo n.º 2
0
    public override object PerformFunction()
    {
        ADLAction currentAction = ADLAction.performingAction;
        ADLAgent  currentAgent  = ADLAgent.currentUpdatingAgent;

        if (!currentAgent.simulationState.singleQueryProperties[currentAction].ContainsKey(this))
        {
            currentAgent.simulationState.singleQueryProperties[currentAction].Add(this, 0);
        }

        int count = (int)currentAgent.simulationState.singleQueryProperties[currentAction][this];

        if (this.GetIsConditionMatched())
        {
            count++;
            currentAgent.simulationState.singleQueryProperties[currentAction][this] = count;
        }
        return(count >= this.GetAmount());
    }
Ejemplo n.º 3
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);
         }
     }
 }
Ejemplo n.º 4
0
    private void PerformAction()
    {
        foreach (ADLSequence seq in this.simulationState.currentState.seqs)
        {
            ADLAction action = (ADLAction)seq.actions[this.simulationState.sequenceIndexes[seq.name]];

            if (this.simulationState.elapsedTimes.ContainsKey(action))
            {
                this.simulationState.elapsedTimes[action] += Time.fixedDeltaTime;
            }
            else
            {
                this.simulationState.elapsedTimes.Add(action, Time.fixedDeltaTime);
                this.simulationState.singleQueryProperties.Add(action, new Dictionary <object, object>());
            }

            if (!(action is ADLToStateAction) && !(action is ADLConditionAction))
            {
                action.PerformAction(this);
            }
        }
    }
Ejemplo n.º 5
0
 public void PerformAction(ADLAgent agent)
 {
     ADLAction.performingAction = this;
     this.Perform(agent);
 }