Beispiel #1
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);
        }
        public IDataRogueControl GetControlFromMousePosition(ISystemContainer systemContainer, IActivity activity, MapCoordinate cameraPosition, int x, int y)
        {
            var playerFov = systemContainer.ActivitySystem.GameplayActivity.Running ? FOVHelper.CalculatePlayerFov(systemContainer) : null;

            DoLayout(systemContainer, activity, playerFov);

            var mousePoint = new Point(x, y);

            var onControls = activity.Controls.Where(c => c.Position.Contains(mousePoint));

            return(onControls.LastOrDefault());
        }
        public void Render(ISystemContainer systemContainer, IActivity activity, int activityIndex)
        {
            if (activity.RendersEntireSpace)
            {
                BLT.Clear();
            }

            var playerFov = systemContainer.ActivitySystem.GameplayActivity.Running ? FOVHelper.CalculatePlayerFov(systemContainer) : null;

            activity.Layout(_controlRenderers, systemContainer, playerFov, _spriteManager);

            Paint(systemContainer, activity, playerFov, activityIndex);
        }
        public void Render(ISystemContainer systemContainer, IActivity activity, int activityIndex)
        {
            if (activity.RendersEntireSpace)
            {
                _console.Clear();
            }

            var playerFov = systemContainer.ActivitySystem.GameplayActivity.Running ? FOVHelper.CalculatePlayerFov(systemContainer) : null;

            DoLayout(systemContainer, activity, playerFov);

            foreach (var control in activity.Controls)
            {
                control.SetActivityIndex(activityIndex);
                IDataRogueControlRenderer controlRenderer = GetRendererFor(control);
                controlRenderer.Paint(_console, control, systemContainer, playerFov);
            }
        }
        public IDataRogueControl GetControlFromMousePosition(ISystemContainer systemContainer, IActivity activity, MapCoordinate cameraPosition, int x, int y)
        {
            var playerFov = systemContainer.ActivitySystem.GameplayActivity.Running ? FOVHelper.CalculatePlayerFov(systemContainer) : null;

            activity.Layout(_controlRenderers, systemContainer, playerFov, _spriteManager);
            var allControls = activity.Controls.GetControlsRecursive();


            var mousePoint = new Point(x, y);

            var onControls = allControls.Where(c => c.CanHandleMouse && c.Position.Contains(mousePoint));

            return(onControls.LastOrDefault());
        }