Пример #1
0
        /// <summary>
        /// Обновление эффекта модуля выживания.
        /// </summary>
        /// <param name="currentEffects"> Текущий список эффектов. </param>
        /// <param name="stat"> Характеристика, на которую влияет эффект. </param>
        /// <param name="keySegments">
        /// Ключевые сегменты, которые были пересечены при изменении характеристики.
        /// <param name="survivalRandomSource"> Источник рандома выживания. </param>
        public static void UpdateSurvivalEffect(
            [NotNull] IEffectsModule currentEffects,
            [NotNull] SurvivalStat stat,
            [NotNull][ItemNotNull] SurvivalStatKeySegment[] keySegments,
            [NotNull] ISurvivalRandomSource survivalRandomSource,
            [NotNull] IPlayerEventLogService playerEventLogService)
        {
            ThrowExceptionIfArgumentsInvalid(currentEffects, stat, keySegments, survivalRandomSource);

            // Эффект выставляем на основе текущего ключевого сегмента, в которое попадает значение характеристики выживания.
            // Если текущее значение не попадает ни в один сегмент, то эффект сбрасывается.

            var currentSegments = keySegments.CalcIntersectedSegments(stat.ValueShare);

            // Если попадаем на стык с двумя сегментами, просто берём первый.
            // Иногда это будет давать более сильный штрафной эффект,
            // но пока не понятно, как по другому сделать отрезки.
            var currentSegment = currentSegments.FirstOrDefault();

            var statType          = stat.Type;
            var currentTypeEffect = GetCurrentEffect(currentEffects, statType);

            if (currentTypeEffect != null)
            {
                // Эффект уже существует. Изменим его уровень.
                // Или удалим, если текущее значение не попадает ни в один из сегментов.
                if (currentSegment == null)
                {
                    currentEffects.Remove(currentTypeEffect);
                }
                else
                {
                    currentTypeEffect.Level = currentSegment.Level;
                }
            }
            else
            {
                if (currentSegment != null)
                {
                    // Создаём эффект
                    var newEffect = new SurvivalStatHazardEffect(
                        statType,
                        currentSegment.Level,
                        survivalRandomSource)
                    {
                        PlayerEventLogService = playerEventLogService
                    };

                    currentEffects.Add(newEffect);
                }
            }
        }
Пример #2
0
        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;
        }
Пример #3
0
        private static IActor CreateHumanActor(HumanPlayer humanPlayer,
                                               IPerson humanPerson,
                                               ISectorManager sectorManager,
                                               IPlayerEventLogService playerEventLogService)
        {
            var playerActorStartNode = sectorManager.CurrentSector.Map.Regions
                                       .SingleOrDefault(x => x.IsStart)
                                       .Nodes
                                       .First();

            humanPlayer.MainPerson = humanPerson;

            var actor = new Actor(humanPerson, humanPlayer, playerActorStartNode);

            playerEventLogService.Actor = actor;

            sectorManager.CurrentSector.ActorManager.Add(actor);

            return(actor);
        }
Пример #4
0
        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>();
            _commandPool             = serviceScope.GetRequiredService <ICommandPool>();
            _commandFactory          = new ServiceProviderCommandFactory(((LivGame)game).ServiceProvider);
            var uiSoundStorage = serviceScope.GetRequiredService <IUiSoundStorage>();

            _uiContentStorage = serviceScope.GetRequiredService <IUiContentStorage>();

            var soundtrackManager = serviceScope.GetRequiredService <SoundtrackManager>();

            _camera             = new Camera();
            _personEffectsPanel =
                new PersonConditionsPanel(_uiState, screenX: game.GraphicsDevice.Viewport.Bounds.Center.X, screenY: 8,
                                          _uiContentStorage, uiSoundStorage,
                                          soundtrackManager, Game.GraphicsDevice);

            _personEquipmentModal = new PersonPropsModalDialog(
                _uiContentStorage,
                game.GraphicsDevice,
                _uiState,
                ((LivGame)game).ServiceProvider);

            _personStatsModal = new PersonStatsModalDialog(
                _uiContentStorage,
                game.GraphicsDevice,
                _uiState);

            _personTraitsModal = new PersonTraitsModalDialog(
                _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.");
            }

            _logService = serviceScope.GetRequiredService <IPlayerEventLogService>();

            _bottomMenu = new BottomMenuPanel(
                humanActorTaskSource,
                mainPerson.GetModule <ICombatActModule>(),
                _uiContentStorage,
                mainPerson.GetModule <IEquipmentModule>(),
                _uiState,
                _commandPool,
                _commandFactory,
                serviceScope.GetRequiredService <ICommandLoopContext>(),
                _logService);
            _bottomMenu.PropButtonClicked   += BottomMenu_PropButtonClicked;
            _bottomMenu.StatButtonClicked   += BottomMenu_StatButtonClicked;
            _bottomMenu.TraitsButtonClicked += BottomMenu_TraitsButtonClicked;

            _scoreManager = serviceScope.GetRequiredService <IScoreManager>();
        }