Beispiel #1
0
        public FieldRepository(
            GameStage gameStage,
            ITemplateRepository <FieldTemplate> fieldTemplates,
            ITickerManager tickerManager
            )
        {
            _gameStage      = gameStage;
            _fieldTemplates = fieldTemplates;

            tickerManager.Schedule(this, TimeSpan.FromSeconds(1));
        }
Beispiel #2
0
        // TODO: Better physicalspace2d handling
        public Field(GameStage stage, FieldTemplate template)
        {
            _stage = stage;

            _template  = template;
            _footholds = new PhysicalLineGrid2D <FieldFootholdTemplate>(_template.Bounds, new Size2D(ScreenWidthOffset / 3, ScreenHeightOffset / 3));
            _footholds.Insert(_template.Footholds.Values);

            _objectLock = new object();
            _pools      = new Dictionary <FieldObjType, IFieldPool>();

            var splitRowCount = (template.Bounds.Size.Height + (ScreenHeightOffset - 1)) / ScreenHeightOffset;
            var splitColCount = (template.Bounds.Size.Width + (ScreenWidthOffset - 1)) / ScreenWidthOffset;

            _splits = new IFieldSplit[splitRowCount, splitColCount];

            for (var row = 0; row < splitRowCount; row++)
            {
                for (var col = 0; col < splitColCount; col++)
                {
                    _splits[row, col] = new FieldSplit(row, col);
                }
            }

            Generators = new List <IFieldGenerator>();

            template.Life.ForEach(l =>
                                  Generators.Add(l.Type switch
            {
                FieldLifeType.NPC => new FieldNPCGenerator(l, stage.NPCTemplates.Retrieve(l.TemplateID).Result),
                FieldLifeType.Monster =>
                l.MobTime > 0
                            ? new FieldMobTimedGenerator(l, stage.MobTemplates.Retrieve(l.TemplateID).Result)
                            : new FieldMobNormalGenerator(l, stage.MobTemplates.Retrieve(l.TemplateID).Result),
                _ => throw new NotImplementedException()
            })