Пример #1
0
        public PhysicalLineGrid2D(Rect2D bounds, Size2D gridSize)
        {
            _bounds   = bounds;
            _gridSize = gridSize;

            var rowCount = (_bounds.Size.Height + (_gridSize.Height - 1)) / _gridSize.Height;
            var colCount = (_bounds.Size.Width + (_gridSize.Width - 1)) / _gridSize.Width;

            _objects = new PhysicalLineSet2D <TObject>();
            _grid    = new PhysicalLineSet2D <TObject> [rowCount, colCount];

            for (var row = 0; row < rowCount; row++)
            {
                for (var col = 0; col < colCount; col++)
                {
                    _grid[row, col] = new PhysicalLineSet2D <TObject>();
                }
            }
        }
Пример #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()
            })