private void GridInteract(GridInteractMessage cellMessage)
        {
            if (walking)
            {
                return;
            }

            var path = _pathFindService.Find(_graph, new PathFindingOptions()
            {
                Start = _gridAgent.Position,
                End   = cellMessage.Node
            });

            if (path == null)
            {
                _messageBroker.Publish(new PathNotFoundMessage());
                return;
            }

            var collision =
                _pathIntersectionService.CheckIntersections(path.Path, _navigationGridAgentCollector.GetAgents());

            if (collision != null)
            {
                path.Path = collision.IntersectedPath;
            }

            _pathVisualizer.Visualize(path.Path);

            _pathAskView.Ask().Subscribe(result =>
            {
                if (collision != null)
                {
                    enemyNode = collision.IntersectionNode;
                }
                else
                {
                    enemyNode = null;
                }


                if (!result)
                {
                    OnWalked(false);
                    return;
                }

                walking = true;
                _gridAgent.Move(path.Path).Subscribe(OnWalked);
            });
        }
Exemplo n.º 2
0
 private void GridInterract(GridInteractMessage obj)
 {
     Debug.Log(obj);
 }