Пример #1
0
    private void Sector_HumanGroupExit(object sender, SectorExitEventArgs e)
    {
        // Персонаж игрока выходит из сектора.
        var actor = _playerState.ActiveActor.Actor;

        _humanPlayer.SectorNode.Sector.ActorManager.Remove(actor);

        // Отписываемся от событий в этом секторе
        UnscribeSectorDependentEvents();

        _interuptCommands = true;
        _commandBlockerService.DropBlockers();

        var activeActor    = _humanActorTaskSource.ActiveActor;
        var survivalModule = activeActor.Person.GetModule <ISurvivalModule>();

        survivalModule.Dead -= HumanPersonSurvival_Dead;

        _playerState.ActiveActor       = null;
        _playerState.SelectedViewModel = null;
        _playerState.HoverViewModel    = null;
        _humanActorTaskSource.SwitchActiveActor(null);

        var nextSectorNode = e.Transition.SectorNode;

        _humanPlayer.BindSectorNode(nextSectorNode);

        StartLoadScene();
    }
Пример #2
0
    private void FixedUpdate()
    {
        if (SectorViewModel.IsInitialized)
        {
            _humanPlayer.MainPerson = _humanPersonFactory.Create("human-person");

            var playerActorViewModel = SelectNodeAndCreateHumanPersonViewModelFromMainPerson();

            ActorsViewModel.ActorViewModels.Add(playerActorViewModel);

            _playerState.ActiveActor = playerActorViewModel;
            _humanActorTaskSource.SwitchActiveActor(playerActorViewModel.Actor);

            Destroy(gameObject);
        }
    }
Пример #3
0
    public ActorViewModel InitPlayerActor(IEnumerable <MapNodeVM> nodeViewModels, List <ActorViewModel> ActorViewModels)
    {
        var personScheme = _schemeService.GetScheme <IPersonScheme>("human-person");

        var playerActorStartNode = _sectorManager.CurrentSector.Map.Regions
                                   .Single(x => x.IsStart).Nodes
                                   .First();

        var playerActorViewModel = CreateHumanActorViewModel(
            _humanPlayer,
            _humanPlayer.SectorNode.Sector.ActorManager,
            _perkResolver,
            playerActorStartNode,
            nodeViewModels);

        //Лучше централизовать переключение текущего актёра только в playerState
        _playerState.ActiveActor = playerActorViewModel;
        _humanActorTaskSource.SwitchActiveActor(_playerState.ActiveActor.Actor);

        ActorViewModels.Add(playerActorViewModel);

        return(playerActorViewModel);
    }