private static void SelectStaticObject(ISectorUiState uiState, ISectorNode playerActorSectorNode, int targetId) { var entitiesManager = playerActorSectorNode.Sector.StaticObjectManager; var targetObject = entitiesManager.Items.SingleOrDefault(x => x.Id == targetId); uiState.SelectedViewModel = new StaticObjectViewModel { StaticObject = targetObject }; }
private static void SelectActor(ISectorUiState uiState, ISectorNode playerActorSectorNode, int targetId) { var actorManager = playerActorSectorNode.Sector.ActorManager; var targetObject = actorManager.Items.SingleOrDefault(x => x.Id == targetId); uiState.SelectedViewModel = new ActorViewModel { Actor = targetObject }; }
private static void HandleLookCommand(ISectorUiState uiState, ISectorNode playerActorSectorNode) { var nextMoveNodes = playerActorSectorNode.Sector.Map.GetNext(uiState.ActiveActor.Actor.Node); var actorFow = uiState.ActiveActor.Actor.Person.GetModule <IFowData>(); var fowNodes = actorFow.GetSectorFowData(playerActorSectorNode.Sector) .Nodes.Where(x => x.State == SectorMapNodeFowState.Observing) .Select(x => x.Node); var fowNodesAll = actorFow.GetSectorFowData(playerActorSectorNode.Sector) .Nodes.Where(x => x.State == SectorMapNodeFowState.Explored || x.State == SectorMapNodeFowState.Observing) .Select(x => x.Node); Console.WriteLine($"{UiResource.NodesLabel}:"); Console.WriteLine(); foreach (var node in fowNodes) { Console.Write(node); if (nextMoveNodes.Contains(node)) { Console.Write($" {UiResource.NextNodeMarker}"); } if (playerActorSectorNode.Sector.Map.Transitions.TryGetValue(node, out var _)) { Console.Write($" {UiResource.TransitionNodeMarker}"); } var undiscoveredNodes = playerActorSectorNode.Sector.Map.GetNext(node) .Where(x => !fowNodesAll.Contains(x)); if (undiscoveredNodes.Any()) { Console.Write($" {UiResource.UndiscaveredNodeMarker}"); } var monsterInNode = playerActorSectorNode.Sector.ActorManager.Items.SingleOrDefault(x => x.Node == node); if (monsterInNode != null && monsterInNode != uiState.ActiveActor.Actor) { Console.Write( $" {UiResource.MonsterNodeMarker} {monsterInNode.Person.Id}:{monsterInNode.Person}"); } var staticObjectInNode = playerActorSectorNode.Sector.StaticObjectManager.Items.SingleOrDefault(x => x.Node == node); if (staticObjectInNode != null) { Console.Write( $" {UiResource.StaticObjectNodeMarker} {staticObjectInNode.Id}:{staticObjectInNode.Purpose}"); } Console.WriteLine(); } }
public ContainerModalDialog(ISectorUiState uiState, IUiContentStorage uiContentStorage, GraphicsDevice graphicsDevice, IServiceProvider serviceProvider) : base( uiContentStorage, graphicsDevice) { _uiState = uiState; _uiContentStorage = uiContentStorage; _serviceProvider = serviceProvider; _containerName = UiResources.FakeContainerName; }
public GameLoopUpdater( IPlayer player, IAnimationBlockerService commandBlockerService, IInventoryState inventoryState, ISectorUiState playerState) { _commandBlockerService = commandBlockerService ?? throw new ArgumentNullException(nameof(commandBlockerService)); _inventoryState = inventoryState ?? throw new ArgumentNullException(nameof(inventoryState)); _playerState = playerState ?? throw new ArgumentNullException(nameof(playerState)); _player = player ?? throw new ArgumentNullException(nameof(player)); }
public MainScreen(Game game, SpriteBatch spriteBatch) : base(game) { _spriteBatch = spriteBatch; var serviceScope = ((LivGame)Game).ServiceProvider; _uiState = serviceScope.GetRequiredService <ISectorUiState>(); _player = serviceScope.GetRequiredService <IPlayer>(); _transitionPool = serviceScope.GetRequiredService <ITransitionPool>(); _animationBlockerService = serviceScope.GetRequiredService <IAnimationBlockerService>(); var uiContentStorage = serviceScope.GetRequiredService <IUiContentStorage>(); _camera = new Camera(); _personEffectsPanel = new PersonConditionsPanel(_uiState, screenX: 8, screenY: 8, uiContentStorage: uiContentStorage); _personEquipmentModal = new PersonPropsModalDialog( uiContentStorage, game.GraphicsDevice, _uiState, ((LivGame)game).ServiceProvider); _personStatsModal = new PersonStatsModalDialog( uiContentStorage, game.GraphicsDevice, _uiState); _containerModal = new ContainerModalDialog( _uiState, uiContentStorage, Game.GraphicsDevice, serviceScope); var humanActorTaskSource = serviceScope.GetRequiredService <IHumanActorTaskSource <ISectorTaskSourceContext> >(); var mainPerson = _player.MainPerson; if (mainPerson is null) { throw new InvalidOperationException("Main person is not initalized. Generate globe first."); } _bottomMenu = new BottomMenuPanel( humanActorTaskSource, mainPerson.GetModule <ICombatActModule>(), uiContentStorage, mainPerson.GetModule <IEquipmentModule>(), _uiState); _bottomMenu.PropButtonClicked += BottomMenu_PropButtonClicked; _bottomMenu.StatButtonClicked += BottomMenu_StatButtonClicked; }
private static IAttackTarget GetTarget(ISectorUiState sectorUiState) { var selectedActorViewModel = GetCanExecuteActorViewModel(sectorUiState); var selectedStaticObjectViewModel = GetCanExecuteStaticObjectViewModel(sectorUiState); var canTakeDamage = selectedStaticObjectViewModel?.StaticObject?.GetModuleSafe <IDurabilityModule>()?.Value > 0; if (!canTakeDamage) { selectedStaticObjectViewModel = null; } return((IAttackTarget)selectedActorViewModel?.Actor ?? selectedStaticObjectViewModel?.StaticObject); }
public MoveCommand( IPlayer player, ISectorUiState playerState) : base(playerState) { if (playerState is null) { throw new ArgumentNullException(nameof(playerState)); } Path = new List <IGraphNode>(); _player = player ?? throw new ArgumentNullException(nameof(player)); }
public MapViewModel(Game game, IPlayer player, ISectorUiState uiState, ISector sector, SpriteBatch spriteBatch) { _hexSprite = game.Content.Load <Texture2D>("Sprites/hex"); _spriteBatch = spriteBatch; _game = game; _player = player; _uiState = uiState; _sector = sector; _hexSprites = new ConcurrentDictionary <OffsetCoords, Sprite>(); sector.TrasitionUsed += Sector_TrasitionUsed; }
public GameObjectsViewModel(GameObjectParams gameObjectParams) { _viewModelContext = gameObjectParams.SectorViewModelContext ?? throw new ArgumentException( $"{nameof(gameObjectParams.SectorViewModelContext)} is not defined.", nameof(gameObjectParams)); _player = gameObjectParams.Player ?? throw new ArgumentException($"{nameof(gameObjectParams.Player)} is not defined.", nameof(gameObjectParams)); _camera = gameObjectParams.Camera ?? throw new ArgumentException($"{nameof(gameObjectParams.Camera)} is not defined.", nameof(gameObjectParams)); _game = gameObjectParams.Game ?? throw new ArgumentException($"{nameof(gameObjectParams.Game)} is not defined.", nameof(gameObjectParams)); _spriteBatch = gameObjectParams.SpriteBatch ?? throw new ArgumentException($"{nameof(gameObjectParams.SpriteBatch)} is not defined.", nameof(gameObjectParams)); _uiState = gameObjectParams.UiState ?? throw new ArgumentException( $"{nameof(gameObjectParams.UiState)} is not defined.", nameof(gameObjectParams)); foreach (var actor in _viewModelContext.Sector.ActorManager.Items) { var actorViewModel = new ActorViewModel(actor, gameObjectParams); if (actor.Person == _player.MainPerson) { _uiState.ActiveActor = actorViewModel; } _viewModelContext.GameObjects.Add(actorViewModel); } foreach (var staticObject in _viewModelContext.Sector.StaticObjectManager.Items) { var staticObjectModel = new StaticObjectViewModel(gameObjectParams.Game, staticObject, gameObjectParams.SpriteBatch); _viewModelContext.GameObjects.Add(staticObjectModel); } var sector = _viewModelContext.Sector; sector.ActorManager.Removed += ActorManager_Removed; sector.StaticObjectManager.Added += StaticObjectManager_Added; sector.StaticObjectManager.Removed += StaticObjectManager_Removed; }
public CommandInput( ISectorUiState sectorUiState, ICommandPool commandPool, Camera camera, ISector sector, SectorViewModelContext sectorViewModelContext, ServiceProviderCommandFactory commandFactory) { _uiState = sectorUiState; _commandPool = commandPool; _camera = camera; _sector = sector; _sectorViewModelContext = sectorViewModelContext; _commandFactory = commandFactory; }
public CombatActPanel(ICombatActModule combatActModule, IEquipmentModule equipmentModule, IUiContentStorage uiContentStorage, ISectorUiState sectorUiState) { _combatActModule = combatActModule; _equipmentModule = equipmentModule; _uiContentStorage = uiContentStorage; _sectorUiState = sectorUiState; _buttons = new List <CombatActButton>(); _buttonGroup = new CombatActButtonGroup(); Initialize(_buttons); _equipmentModule.EquipmentChanged += EquipmentModule_EquipmentChanged; }
public PersonConditionsPanel(ISectorUiState uiState, int screenX, int screenY, IUiContentStorage uiContentStorage, IUiSoundStorage uiSoundStorage, SoundtrackManager soundtrackManager, GraphicsDevice graphicsDevice) { _uiState = uiState; _screenX = screenX; _screenY = screenY; _uiContentStorage = uiContentStorage; _uiSoundStorage = uiSoundStorage; _soundtrackManager = soundtrackManager; _alertSoundEffect = _uiSoundStorage.GetAlertEffect().CreateInstance(); _alertTexture = CreateTexture(graphicsDevice, ICON_SIZE + ICON_SPACING * 2, ICON_SIZE + ICON_SPACING * 2, LastColors.Red); _alertedConditions = new List <IPersonCondition>(); }
public BottomMenuPanel( IHumanActorTaskSource <ISectorTaskSourceContext> humanActorTaskSource, ICombatActModule combatActModule, IUiContentStorage uiContentStorage, IEquipmentModule equipmentModule, ISectorUiState sectorUiState, ICommandPool commandPool, ServiceProviderCommandFactory commandFactory, ICommandLoopContext commandLoopContext, IPlayerEventLogService logService) { _travelPanel = new TravelPanel(humanActorTaskSource, uiContentStorage, commandPool, commandFactory, commandLoopContext); _combatActPanel = new CombatActPanel(combatActModule, equipmentModule, uiContentStorage, sectorUiState); _travelPanel.PropButtonClicked += PersonPropButton_OnClick; _travelPanel.StatButtonClicked += PersonStatsButton_OnClick; _travelPanel.TraitsButtonClicked += PersonTraitsButton_OnClick; _travelPanel.FastDeathButtonClicked += FastDeathButtonClicked; _currentModeMenu = _travelPanel; var combatButtonIcon = new IconData( uiContentStorage.GetSmallVerticalButtonIconsTexture(), new Rectangle(48, 0, SWITCHER_MODE_BUTTON_WIDTH, SWITCHER_MODE_BUTTON_HEIGHT) ); var idleButtonIcon = new IconData( uiContentStorage.GetSmallVerticalButtonIconsTexture(), new Rectangle(0, 32, SWITCHER_MODE_BUTTON_WIDTH, SWITCHER_MODE_BUTTON_HEIGHT) ); _idleModeSwitcherButton = new IconButton( uiContentStorage.GetSmallVerticalButtonBackgroundTexture(), idleButtonIcon, new Rectangle(0, 0, SWITCHER_MODE_BUTTON_WIDTH, SWITCHER_MODE_BUTTON_HEIGHT)); _idleModeSwitcherButton.OnClick += IdleModeSwitcherButton_OnClick; _combatActModule = combatActModule; _uiContentStorage = uiContentStorage; _sectorUiState = sectorUiState; _logService = logService; _combatModeSwitcherButton = new IconButton( texture: uiContentStorage.GetSmallVerticalButtonBackgroundTexture(), iconData: combatButtonIcon, rect: new Rectangle(0, 0, SWITCHER_MODE_BUTTON_WIDTH, SWITCHER_MODE_BUTTON_HEIGHT)); _combatModeSwitcherButton.OnClick += CombatModeSwitcherButton_OnClick; }
public PersonMarkersPanel(int positionOffsetY, IUiContentStorage uiContentStorage, SectorViewModelContext sectorViewModelContext, IPlayer player, ISectorUiState sectorUiState, ICommandPool commandPool, ServiceProviderCommandFactory commandFactory) { _positionOffsetY = positionOffsetY; _uiContentStorage = uiContentStorage; _sectorViewModelContext = sectorViewModelContext; _player = player; _sectorUiState = sectorUiState; _commandPool = commandPool; _commandFactory = commandFactory; _visibleActors = new List <ActorViewModel>(); _drawnItemList = new List <Marker>(); }
public GlobeSelectionScreen(Game game, SpriteBatch spriteBatch) : base(game) { _spriteBatch = spriteBatch; var serviceProvider = ((LivGame)game).ServiceProvider; _uiContentStorage = serviceProvider.GetRequiredService <IUiContentStorage>(); _globeInitializer = serviceProvider.GetRequiredService <IGlobeInitializer>(); _globeLoop = serviceProvider.GetRequiredService <IGlobeLoopUpdater>(); _commandLoop = serviceProvider.GetRequiredService <ICommandLoopUpdater>(); _playerState = serviceProvider.GetRequiredService <ISectorUiState>(); _inventoryState = serviceProvider.GetRequiredService <IInventoryState>(); var buttonTexture = _uiContentStorage.GetButtonTexture(); var font = _uiContentStorage.GetButtonFont(); _generateButton = new TextButton(UiResources.GenerateGlobeButtonTitle, buttonTexture, font, new Rectangle(150, 150, BUTTON_WIDTH, BUTTON_HEIGHT)); _generateButton.OnClick += GenerateButtonClickHandlerAsync; }
public BottomMenuPanel( IHumanActorTaskSource <ISectorTaskSourceContext> humanActorTaskSource, ICombatActModule combatActModule, IUiContentStorage uiContentStorage, IEquipmentModule equipmentModule, ISectorUiState sectorUiState) { _travelPanel = new TravelPanel(humanActorTaskSource, uiContentStorage); _combatActPanel = new CombatActPanel(combatActModule, equipmentModule, uiContentStorage, sectorUiState); _travelPanel.PropButtonClicked += PersonPropButton_OnClick; _travelPanel.StatButtonClicked += PersonStatsButton_OnClick; _currentModeMenu = _travelPanel; var idleButtonIcon = new IconData( uiContentStorage.GetSmallVerticalButtonIconsTexture(), new Rectangle(48, 0, SWITCHER_MODE_BUTTON_WIDTH, SWITCHER_MODE_BUTTON_HEIGHT) ); var combatButtonIcon = new IconData( uiContentStorage.GetSmallVerticalButtonIconsTexture(), new Rectangle(0, 32, SWITCHER_MODE_BUTTON_WIDTH, SWITCHER_MODE_BUTTON_HEIGHT) ); _idleModeSwitcherButton = new IconButton(uiContentStorage.GetSmallVerticalButtonBackgroundTexture(), combatButtonIcon, new Rectangle(0, 0, SWITCHER_MODE_BUTTON_WIDTH, SWITCHER_MODE_BUTTON_HEIGHT)); _idleModeSwitcherButton.OnClick += IdleModeSwitcherButton_OnClick; _combatActModule = combatActModule; _uiContentStorage = uiContentStorage; _combatModeSwitcherButton = new IconButton( texture: uiContentStorage.GetSmallVerticalButtonBackgroundTexture(), iconData: idleButtonIcon, rect: new Rectangle(0, 0, SWITCHER_MODE_BUTTON_WIDTH, SWITCHER_MODE_BUTTON_HEIGHT)); _combatModeSwitcherButton.OnClick += CombatModeSwitcherButton_OnClick; }
private static void HandleLookCommand(ISectorUiState uiState, ISectorNode playerActorSectorNode, string inputText) { var isDetailed = inputText.Equals("look2", StringComparison.InvariantCultureIgnoreCase); var nextMoveNodes = playerActorSectorNode.Sector.Map.GetNext(uiState.ActiveActor.Actor.Node); var actorFow = uiState.ActiveActor.Actor.Person.GetModule <IFowData>(); var fowNodes = actorFow.GetSectorFowData(playerActorSectorNode.Sector) .Nodes.Where(x => x.State == SectorMapNodeFowState.Observing) .Select(x => x.Node); var fowNodesAll = actorFow.GetSectorFowData(playerActorSectorNode.Sector) .Nodes.Where(x => x.State == SectorMapNodeFowState.Explored || x.State == SectorMapNodeFowState.Observing) .Select(x => x.Node); PrintLocationName(playerActorSectorNode); PrintLookLegend(); Console.WriteLine(); Console.WriteLine($"{UiResource.NodesLabel}:"); Console.WriteLine(); foreach (var node in fowNodes) { var sb = new StringBuilder(node.ToString()); var poi = false; if (nextMoveNodes.Contains(node)) { poi = true; sb.Append($" {UiResource.NextNodeMarker}"); } if (playerActorSectorNode.Sector.Map.Transitions.TryGetValue(node, out var _)) { poi = true; sb.Append($" {UiResource.TransitionNodeMarker}"); } var undiscoveredNodes = playerActorSectorNode.Sector.Map.GetNext(node) .Where(x => !fowNodesAll.Contains(x)); if (undiscoveredNodes.Any()) { poi = true; sb.Append($" {UiResource.UndiscoveredNextNodeMarker}"); } var monsterInNode = playerActorSectorNode.Sector.ActorManager.Items.SingleOrDefault(x => x.Node == node); if (monsterInNode != null && monsterInNode != uiState.ActiveActor.Actor) { poi = true; sb.Append( $" {UiResource.MonsterNodeMarker} {monsterInNode.Person.Id}:{monsterInNode.Person}"); } var staticObjectInNode = playerActorSectorNode.Sector.StaticObjectManager.Items.SingleOrDefault(x => x.Node == node); if (staticObjectInNode != null) { poi = true; sb.Append( $" {UiResource.StaticObjectNodeMarker} {staticObjectInNode.Id}:{staticObjectInNode.Purpose}"); } if (isDetailed) { Console.WriteLine(sb.ToString()); } else if (poi) { Console.WriteLine(sb.ToString()); } } }
public ShowContainerModalCommand(ISectorModalManager modalManager, ISectorUiState playerState) : base(modalManager) { _playerState = playerState; }
protected ActorCommandBase( ISectorUiState playerState ) { PlayerState = playerState; }
protected SpecialActorCommandBase(IGameLoop gameloop, ISectorManager sectorManager, ISectorUiState playerState) : base(gameloop, sectorManager, playerState) { }
public PropTransferCommand(IGameLoop gameLoop, ISectorManager sectorManager, ISectorUiState playerState) : base(gameLoop, sectorManager, playerState) { }
public PropTransferCommand( ISectorManager sectorManager, ISectorUiState playerState) : base(sectorManager, playerState) { }
private static ICommand SelectCommandBySelectedViewModel(ISelectableViewModel selectedViewModel, ServiceProviderCommandFactory commandFactory, ISectorUiState _uiState) { switch (selectedViewModel) { case IActorViewModel: var activeActor = _uiState.ActiveActor; if (activeActor is null) { throw new InvalidOperationException(); } if (_uiState.TacticalAct is null) { Debug.Fail("Combat act is not selected."); } return(commandFactory.GetCommand <AttackCommand>()); case IMapNodeViewModel: return(commandFactory.GetCommand <MoveCommand>()); default: throw new InvalidOperationException( $"Object of unknown type (${selectedViewModel.GetType()}) was selected."); } }
public SectorTransitionMoveCommand( ISectorManager sectorManager, ISectorUiState playerState) : base(sectorManager, playerState) { }
public ShowInventoryModalCommand(ISectorModalManager modalManager, ISectorUiState playerState) : base(modalManager) { _playerState = playerState; }
private static void HandleAttackCommand(string inputText, IServiceScope serviceScope, ISectorUiState uiState, ISectorNode playerActorSectorNode, ICommandPool commandManager) { var components = inputText.Split(' '); var targetId = int.Parse(components[1], CultureInfo.InvariantCulture); if (components.Length == 3) { var targetMarker = components[2].ToUpper(CultureInfo.InvariantCulture); switch (targetMarker) { case "A": SelectActor(uiState, playerActorSectorNode, targetId); break; case "S": SelectStaticObject(uiState, playerActorSectorNode, targetId); break; default: SelectActor(uiState, playerActorSectorNode, targetId); break; } } else { SelectActor(uiState, playerActorSectorNode, targetId); } var acts = uiState.ActiveActor.Actor.Person.GetModule <ICombatActModule>().GetCurrentCombatActs(); uiState.TacticalAct = acts .OrderBy(x => x.Equipment is null) .First(x => x.Constrains is null); var command = serviceScope.ServiceProvider.GetRequiredService <AttackCommand>(); PushCommandToExecution(commandManager, command); }
public IdleCommand( IPlayer player, ISectorUiState playerState) : base(playerState) { _player = player; }
protected SpecialActorCommandBase( ISectorManager sectorManager, ISectorUiState playerState) : base(sectorManager, playerState) { }
public ShowPerksModalCommand(ISectorModalManager sectorManager, ISectorUiState playerState) : base(sectorManager) { _playerState = playerState; }