private static void AssignStateToNextState(long transitionNodeId, ref NextAIState nextAIState) { TransitionNode _transitionNode = AIBehaviourEditor.GetNode(transitionNodeId) as TransitionNode; if (_transitionNode.ToStateNode != null) { switch (_transitionNode.ToStateNode.stateType) { case StateNode.StateType.Attack: { nextAIState.nextState = m_nodeIdToAttackStates[_transitionNode.ToStateNode.ID]; break; } case StateNode.StateType.Idle: { nextAIState.nextState = m_nodeIdToIdleStates[_transitionNode.ToStateNode.ID]; break; } case StateNode.StateType.Move: { nextAIState.nextState = m_nodeIdToMoveStates[_transitionNode.ToStateNode.ID]; break; } } } }
private static void AssignNextStatesToState(long stateNodeId, AIStateBase state) { List <TransitionNode> _transitionNodes = ((StateNode)AIBehaviourEditor.GetNode(stateNodeId)).transitions_out; NextAIState[] _nextAIStates = new NextAIState[_transitionNodes.Count]; for (int _transitionNodeIndex = 0; _transitionNodeIndex < _transitionNodes.Count; _transitionNodeIndex++) { _nextAIStates[_transitionNodeIndex] = new NextAIState { conditions = new List <AIConditionBase>() }; long _transitonNodeID = _transitionNodes[_transitionNodeIndex].ID; AssignConditionToNextState(_transitonNodeID, ref _nextAIStates[_transitionNodeIndex]); AssignStateToNextState(_transitonNodeID, ref _nextAIStates[_transitionNodeIndex]); } state.SetNextAIStates(_nextAIStates); }
private static void AssignConditionToNextState(long transitionNodeId, ref NextAIState nextAIState) { if (m_nodeIdToDistanceConditions.ContainsKey(transitionNodeId)) { for (int _conditionIndex = 0; _conditionIndex < m_nodeIdToDistanceConditions[transitionNodeId].Count; _conditionIndex++) { nextAIState.conditions.Add(m_nodeIdToDistanceConditions[transitionNodeId][_conditionIndex]); } } if (m_nodeIdToNearestIsConditions.ContainsKey(transitionNodeId)) { for (int _conditionIndex = 0; _conditionIndex < m_nodeIdToNearestIsConditions[transitionNodeId].Count; _conditionIndex++) { nextAIState.conditions.Add(m_nodeIdToNearestIsConditions[transitionNodeId][_conditionIndex]); } } if (m_nodeIdToStatusConditions.ContainsKey(transitionNodeId)) { for (int _conditionIndex = 0; _conditionIndex < m_nodeIdToStatusConditions[transitionNodeId].Count; _conditionIndex++) { nextAIState.conditions.Add(m_nodeIdToStatusConditions[transitionNodeId][_conditionIndex]); } } }