private string ParseLevelState(string parsingState, Match token) { if (token.Groups["EndName"].Length != 0) { parsingState = this.compilerStack.Pop(); } else if (token.Groups["State"].Length != 0) { ADLState state = new ADLState(token.Groups["State"].Value); this.currentState = state; this.currentAgentScript.states.Add(state); this.compilerStack.Push(parsingState); if (token.Groups["State"].Value.Equals("init") || token.Groups["State"].Value.Equals("des")) { parsingState = "action"; this.Log("Special State : " + token.Groups["State"]); ADLSequence sequence = new ADLSequence("seq"); this.currentSequence = sequence; this.currentState.seqs.Add(sequence); } else { parsingState = "sequence"; this.Log("State : " + token.Groups["State"]); } } return(parsingState); }
private void InitializeAgent() { this.agentName = this.agentScript.agentName; this.gameObject.name = this.agentName; ADLState initState = this.agentScript.states.Find((state) => state.name.Equals("init")); if (initState != null) { foreach (ADLAction action in initState.seqs[0].actions) { action.PerformAction(this); } ADLState firstState = this.agentScript.states.Find((state) => !state.name.Equals("init") && !state.name.Equals("des")); if (firstState != null) { this.simulationState = new SimulationState(this.agentScript.states[1]); } else { throw new Exception("Unable to find the first state after init state"); } } base.Start(); if (agentLifePointText != null) { agentLifePointText.text = "LP: " + this.lifePoint; } this.isInitStateExecuted = true; }
public void SetCurrentState(ADLState state) { this.currentState = state; this.sequenceIndexes.Clear(); this.elapsedTimes.Clear(); this.singleQueryProperties.Clear(); this.currentState.seqs.ForEach((seq) => this.sequenceIndexes.Add(seq.name, 0)); }
public SimulationState(ADLState state) { this.SetCurrentState(state); }