/// <summary> /// Advances the entity by one node of the path. /// </summary> public void AdvanceOneNode() { // Is it a delay node? if (_previousNode != null && _previousNode.Delay != 0) { if (_delayProcess == null) { _delayProcess = new DelayProcess(_previousNode.Delay); ProcessManager.AttachProcess(_delayProcess); WaitForProcess(_delayProcess, ProcessResult.Success); return; } else { _delayProcess = null; } } // Trigger the events of the previous node. if (_previousNode != null) { _previousNode.TriggerEvents(); } // Are we finished? if (_currentNode == null) { Finish(ProcessResult.Success); return; } // Move to the node! Transformation nodeTransform = _currentNode.CalculateTransformation(); _moveToProcess = new EntityMoveToProcess(_entity, nodeTransform.X + (_currentNode.Width / 2), nodeTransform.Y + (_currentNode.Height / 2), _currentNode.Speed); ProcessManager.AttachProcess(_moveToProcess); WaitForProcess(_moveToProcess, ProcessResult.Success); // Get the next node. _previousNode = _currentNode; _currentNode = _currentNode.NextNode; }
/// <summary> /// Advances the entity by one node of the path. /// </summary> public void AdvanceOneNode() { // Is it a delay node? if (_previousNode != null && _previousNode.Delay != 0) { if (_delayProcess == null) { _delayProcess = new DelayProcess(_previousNode.Delay); ProcessManager.AttachProcess(_delayProcess); WaitForProcess(_delayProcess, ProcessResult.Success); return; } else _delayProcess = null; } // Trigger the events of the previous node. if (_previousNode != null) _previousNode.TriggerEvents(); // Are we finished? if (_currentNode == null) { Finish(ProcessResult.Success); return; } // Move to the node! Transformation nodeTransform = _currentNode.CalculateTransformation(); _moveToProcess = new EntityMoveToProcess(_entity, nodeTransform.X + (_currentNode.Width / 2), nodeTransform.Y + (_currentNode.Height / 2), _currentNode.Speed); ProcessManager.AttachProcess(_moveToProcess); WaitForProcess(_moveToProcess, ProcessResult.Success); // Get the next node. _previousNode = _currentNode; _currentNode = _currentNode.NextNode; }