Exemplo n.º 1
0
    private async Task InitServicesAsync()
    {
        var sectorNode = _humanPlayer.SectorNode;

        if (sectorNode == null)
        {
            var introLocationScheme = _schemeService.GetScheme <ILocationScheme>("intro");
            var biom = await _biomeInitializer.InitBiomeAsync(introLocationScheme);

            sectorNode = biom.Sectors.Single(x => x.State == SectorNodeState.SectorMaterialized);
        }
        else if (sectorNode.State == SectorNodeState.SchemeKnown)
        {
            await _biomeInitializer.MaterializeLevelAsync(sectorNode);
        }

        _humanPlayer.BindSectorNode(sectorNode);
        await _sectorManager.CreateSectorAsync();

        sectorNode.Sector.ScoreManager = _scoreManager;

        _staticObjectManager = sectorNode.Sector.StaticObjectManager;

        _staticObjectManager.Added   += StaticObjectManager_Added;
        _staticObjectManager.Removed += StaticObjectManager_Removed;

        _playerState.TaskSource = _humanActorTaskSource;

        _sectorManager.CurrentSector.HumanGroupExit += Sector_HumanGroupExit;
    }
Exemplo n.º 2
0
        public async Task <IGlobe> CreateGlobeAsync(string startLocationSchemeSid)
        {
            var globe = new Globe(_globeTransitionHandler);

            var startLocation = _schemeService.GetScheme <ILocationScheme>(startLocationSchemeSid);
            var startBiom     = await _biomeInitializer.InitBiomeAsync(startLocation).ConfigureAwait(false);

            var startSectorNode = startBiom.Sectors.First(x => x.State == SectorNodeState.SectorMaterialized);

            globe.AddSectorNode(startSectorNode);

            // Добавляем стартовых персонажей-пилигримов

            var startPersons = await _personInitializer.CreateStartPersonsAsync(globe).ConfigureAwait(false);

            var sector        = startSectorNode.Sector;
            var personCounter = 0;

            foreach (var person in startPersons)
            {
                var startNode = sector.Map
                                .Nodes
                                .Skip(personCounter)
                                .First();
                var actor = CreateActor(person, startNode, _actorTaskSource);

                sector.ActorManager.Add(actor);
                personCounter++;
            }

            return(globe);
        }
        public async Task CreateSectorAsync()
        {
            if (_humanPlayer.SectorNode is null)
            {
                var scheme = _schemeService.GetScheme <ILocationScheme>(LOCATION_SID);

                var biome = await _biomeInitializer.InitBiomeAsync(scheme).ConfigureAwait(false);

                var sectorNode = biome.Sectors.First();

                _humanPlayer.BindSectorNode(sectorNode);

                CurrentSector = sectorNode.Sector;
            }
            else
            {
                await _biomeInitializer.MaterializeLevelAsync(_humanPlayer.SectorNode).ConfigureAwait(false);

                CurrentSector = _humanPlayer.SectorNode.Sector;
            }
        }