コード例 #1
0
        public IEnumerable <MapCoordinate> Path(MapCoordinate origin, MapCoordinate destination)
        {
            if (origin.Key != destination.Key)
            {
                return(null);
            }

            IMap map = _mapSystem.MapCollection[origin.Key];

            return(_pathfindingAlgorithm.Path(map, origin, destination));
        }
コード例 #2
0
        public override ActionEventData HandleMouse(MouseData mouse, IDataRogueControlRenderer renderer, ISystemContainer systemContainer)
        {
            MapCoordinate mapCoordinate = GetMapCoordinate(mouse, systemContainer);

            systemContainer.ControlSystem.HoveredCoordinate = mapCoordinate;

            var player = systemContainer.PlayerSystem.Player;

            if (mouse.IsLeftClick && systemContainer.TimeSystem.WaitingForInput && CanAutowalkToCoordinate(systemContainer, mapCoordinate))
            {
                var playerLocation = systemContainer.PositionSystem.CoordinateOf(player);
                var map            = systemContainer.MapSystem.MapCollection[systemContainer.RendererSystem.CameraPosition.Key];
                var path           = _pathfindingAlgorithm.Path(map, playerLocation, mapCoordinate);

                if (path != null)
                {
                    var action = new ActionEventData {
                        Action = ActionType.FollowPath, Parameters = string.Join(";", path.Select(m => m.ToString()))
                    };

                    return(action);
                }
            }

            if (mouse.IsRightClick && systemContainer.TimeSystem.WaitingForInput)
            {
                var map = systemContainer.MapSystem.MapCollection[systemContainer.RendererSystem.CameraPosition.Key];

                if (map.SeenCoordinates.Contains(mapCoordinate))
                {
                    var playerFov = FOVHelper.CalculatePlayerFov(systemContainer);

                    var entities = systemContainer.PositionSystem.EntitiesAt(mapCoordinate);

                    if (!playerFov.Contains(mapCoordinate))
                    {
                        entities = entities.Where(e => e.Has <Memorable>()).ToList();
                    }

                    IEntity entityToShow = entities.OrderByDescending(e => e.Has <Appearance>() ? e.Get <Appearance>().ZOrder : int.MinValue).First();

                    var action = new ActionEventData {
                        Action = ActionType.Examine, Parameters = entityToShow.EntityId.ToString()
                    };

                    return(action);
                }
            }

            return(null);
        }
コード例 #3
0
        private bool TryCarveTunnel(IMap map, MapCoordinate firstPoint, MapCoordinate secondPoint, List <VaultPlacement> vaultPlacements)
        {
            var path = _tunnelPathfinding.Path(map, firstPoint, secondPoint);

            if (path != null && path.Any())
            {
                CarveTunnel(map, path);

                RemoveConnectionPoints(vaultPlacements, firstPoint, secondPoint);

                return(true);
            }
            else
            {
                return(false);
            }
        }