示例#1
0
 public ImageController(IImageFactory fac, IGridFactory gridFac)
 {
     _factory     = fac;
     _gridFactory = gridFac;
     //This can be created from request params
     _grid = _gridFactory.CreateGrid(60, 60, 10);
 }
示例#2
0
    public void InitializeGrid()
    {
        groupPattern = Substitute.For <IGroupPattern>();
        rotationMock = new List <Coord[]>()
        {
            new Coord[] {
                new Coord(0, 0),
                new Coord(0, -1),
                new Coord(1, 0),
                new Coord(-1, 0),
            },
            new Coord[] {
                new Coord(0, 0),
                new Coord(-1, 0),
                new Coord(0, -1),
                new Coord(0, 1),
            },
            new Coord[] {
                new Coord(0, 0),
                new Coord(0, 1),
                new Coord(-1, 0),
                new Coord(1, 0),
            },
            new Coord[] {
                new Coord(0, 0),
                new Coord(1, 0),
                new Coord(0, 1),
                new Coord(0, -1),
            },
        };
        groupPattern.Patterns.Returns(rotationMock);

        groupPatternList = new List <IGroupPattern>();
        groupPatternList.Add(groupPattern);

        groupFactory = new GroupFactory(blockFactory, groupPatternList);

        gridFactory = new GridFactory(setting, groupFactory);

        // create grid
        grid = gridFactory.Create();
        grid.NewGame();

        blockPattern  = Substitute.For <IBlockPattern>();
        blockTypeMock = new BlockType[]
        {
            BlockType.One,
            BlockType.Six,
            BlockType.Three,
            BlockType.Five,
        };
        blockPattern.Types.Returns(blockTypeMock);

        group = groupFactory.Create(setting, blockPattern, groupPattern);
    }
示例#3
0
    public void InitializeGrid()
    {
        groupPattern = Substitute.For<IGroupPattern>();
        rotationMock = new List<Coord[]>() {
            new Coord[] {
                new Coord(0, 0),
                new Coord(0, -1),
                new Coord(1, 0),
                new Coord(-1, 0),
            },
            new Coord[] {
                new Coord(0, 0),
                new Coord(-1, 0),
                new Coord(0, -1),
                new Coord(0, 1),
            },
            new Coord[] {
                new Coord(0, 0),
                new Coord(0, 1),
                new Coord(-1, 0),
                new Coord(1, 0),
            },
            new Coord[] {
                new Coord(0, 0),
                new Coord(1, 0),
                new Coord(0, 1),
                new Coord(0, -1),
            },
        };
        groupPattern.Patterns.Returns(rotationMock);

        groupPatternList = new List<IGroupPattern>();
        groupPatternList.Add(groupPattern);

        groupFactory = new GroupFactory(blockFactory, groupPatternList);

        gridFactory = new GridFactory(setting, groupFactory);

        // create grid
        grid = gridFactory.Create();
        grid.NewGame();

        blockPattern = Substitute.For<IBlockPattern>();
        blockTypeMock = new BlockType[]
        {
            BlockType.One,
            BlockType.Six,
            BlockType.Three,
            BlockType.Five,
        };
        blockPattern.Types.Returns(blockTypeMock);

        group = groupFactory.Create(setting, blockPattern, groupPattern);
    }
示例#4
0
    public void Init()
    {
        testSetting = TestSetting.Get();
        game = new Game(testSetting);
        cameraManager = Substitute.For<ICameraManager>();
        backgroundFactory = Substitute.For<IBackgroundFactory>();
        gridFactory = Substitute.For<IGridFactory>();
        groupFactory = Substitute.For<IGroupFactory>();

        game.CameraManager = cameraManager;
        game.BackgroundFactory = backgroundFactory;
        game.GridFactory = gridFactory;
        game.GroupFactory = groupFactory;
    }
        /// <summary>
        /// Initializes a new instance based on the specified <paramref name="json"/> object, <paramref name="grid"/> model and <paramref name="factory"/>.
        /// </summary>
        /// <param name="json">An instance of <see cref="JObject"/> representing the section.</param>
        /// <param name="grid">The parent grid model.</param>
        /// <param name="factory">The factory used for parsing subsequent parts of the grid.</param>
        public GridSection(JObject json, GridDataModel grid, IGridFactory factory) : base(json)
        {
            Model = grid;
            Grid  = json.GetInt32("grid");
            Name  = grid.Name;
            Rows  = json.GetArray("rows", x => factory.CreateGridRow(x, this)) ?? new GridRow[0];

            // Update "PreviousRow" and "NextRow" properties
            for (int i = 1; i < Rows.Length; i++)
            {
                Rows[i - 1].NextRow = Rows[i];
                Rows[i].PreviousRow = Rows[i - 1];
            }
        }
示例#6
0
        /// <summary>
        /// Initializes a new instance based on the specified <paramref name="json"/> object, <paramref name="row"/> and <paramref name="factory"/>.
        /// </summary>
        /// <param name="json">An instance of <see cref="JObject"/> representing the section.</param>
        /// <param name="row">The parent row.</param>
        /// <param name="factory">The factory used for parsing subsequent parts of the grid.</param>
        public GridArea(JObject json, GridRow row, IGridFactory factory) : base(json)
        {
            Row      = row;
            Grid     = json.GetInt32("grid");
            AllowAll = json.GetBoolean("allowAll");
            Allowed  = json.GetStringArray("allowed");
            Controls = json.GetArray("controls", x => factory.CreateGridControl(x, this)) ?? new GridControl[0];

            // Update "PreviousControl" and "NextControl" properties
            for (int i = 1; i < Controls.Length; i++)
            {
                Controls[i - 1].NextControl = Controls[i];
                Controls[i].PreviousControl = Controls[i - 1];
            }
        }
        /// <summary>
        /// Initializes a new instance based on the specified <paramref name="json"/> object, <paramref name="section"/> and <paramref name="factory"/>.
        /// </summary>
        /// <param name="json">An instance of <see cref="JObject"/> representing the section.</param>
        /// <param name="section">The parent section.</param>
        /// <param name="factory">The factory used for parsing subsequent parts of the grid.</param>
        public GridRow(JObject json, GridSection section, IGridFactory factory) : base(json)
        {
            Section = section;
            Id      = json.GetString("id");
            Label   = json.GetString("label");
            Name    = json.GetString("name");

            Areas = json.GetArray("areas", x => factory.CreateGridArea(x, this)) ?? new GridArea[0];

            // Update "PreviousArea" and "NextArea" properties
            for (int i = 1; i < Areas.Length; i++)
            {
                Areas[i - 1].NextArea = Areas[i];
                Areas[i].PreviousArea = Areas[i - 1];
            }
        }
示例#8
0
        // ReSharper restore InconsistentNaming

        #endregion

        #endregion

        #region Constructors

        /// <summary>
        /// Initializes a new instance based on the specified <paramref name="json"/> object.
        ///
        /// <paramref name="owner"/> and <paramref name="propertyType"/> may be specified if the grid value comes directly from a property value. If either aren't available, it's fine to specify <c>null</c> for both of them.
        /// </summary>
        /// <param name="owner">An instance of <see cref="IPublishedElement"/> representing the owner holding the grid value.</param>
        /// <param name="propertyType">An instance of <see cref="IPublishedPropertyType"/> representing the property holding the grid value.</param>
        /// <param name="json">An instance of <see cref="JObject"/> representing the grid model.</param>
        /// <param name="factory">The factory used for parsing subsequent parts of the grid.</param>
        public GridDataModel(IPublishedElement owner, IPublishedPropertyType propertyType, JObject json, IGridFactory factory) : base(json)
        {
            Owner        = owner;
            PropertyType = propertyType;
            Name         = json.GetString("name");
            Sections     = json.GetArray("sections", x => factory.CreateGridSection(x, this)) ?? Array.Empty <GridSection>();
        }
 public GridMenuItem(IGridFactory gridFactory)
 {
     GridFactory = gridFactory;
 }
 public MinefieldFactory(IGridFactory grid_factory, IMinePlanterFactory mine_planter_factory, IMineClearer mine_clearer)
 {
     _grid_factory = grid_factory;
     _mine_planter_factory = mine_planter_factory;
     _mine_clearer = mine_clearer;
 }
 public GridValueConverter(IGridFactory factory)
 {
     _factory = factory;
 }
 public MinefieldFactory(IGridFactory grid_factory, IMinePlanterFactory mine_planter_factory, IMineClearer mine_clearer)
 {
     _grid_factory         = grid_factory;
     _mine_planter_factory = mine_planter_factory;
     _mine_clearer         = mine_clearer;
 }