示例#1
0
    public IGroup Create(ISetting setting)
    {
        if (_groupPatternList == null || _groupPatternList.Count == 0)
        {
            Debug.Log("Group Pattern List is not to be set!");
            return(null);
        }

        IGroup    group       = new Group(setting);
        Transform groupHolder = null;

        if (setting.IsProduction)
        {
            groupHolder  = new GameObject("Group").transform;
            group.Parent = groupHolder.transform;
            group.Parent.SetParent(setting.Parent, false);
        }

        var           random       = setting.Random;
        IGroupPattern groupPattern = _groupPatternList[random.Next(0, _groupPatternList.Count)];

        for (int i = 0; i < groupPattern.Patterns[0].Length; i++)
        {
            IBlock block = _blockFactory.Create(groupHolder, setting, BlockTypeHelper.GetRandom(setting.Random), groupPattern.Patterns[0][i]);
            group.AddBlock(block);
        }

        group.SetPattern(groupPattern.Patterns);

        return(group);
    }
示例#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 IGroup Create(ISetting setting, IBlockPattern blockPattern, IGroupPattern groupPattern)
    {
        IGroup group = new Group(setting);

        for (int i = 0; i < groupPattern.Patterns[0].Length; i++)
        {
            IBlock block = _blockFactory.Create(setting, blockPattern.Types[i], groupPattern.Patterns[0][i]);
            group.AddBlock(block);
        }

        group.SetPattern(groupPattern.Patterns);

        return(group);
    }
示例#5
0
    public void Init()
    {
        blockPattern  = Substitute.For <IBlockPattern>();
        blockTypeMock = new BlockType[]
        {
            BlockType.Two,
            BlockType.Four,
            BlockType.Seven,
        };
        blockPattern.Types.Returns(blockTypeMock);

        groupPattern = Substitute.For <IGroupPattern>();
        locationMock = new List <Coord[]>()
        {
            new Coord[] {
                new Coord(0, 0),
                new Coord(0, 1),
                new Coord(1, 0),
            },
            new Coord[] {
                new Coord(0, 0),
                new Coord(1, 0),
                new Coord(0, -1),
            },
            new Coord[] {
                new Coord(0, 0),
                new Coord(0, -1),
                new Coord(-1, 0),
            },
            new Coord[] {
                new Coord(0, 0),
                new Coord(-1, 0),
                new Coord(0, 1),
            },
        };
        groupPattern.Patterns.Returns(locationMock);
    }
示例#6
0
    public void Init()
    {
        blockPattern = Substitute.For<IBlockPattern>();
        blockTypeMock = new BlockType[]
        {
            BlockType.Two,
            BlockType.Four,
            BlockType.Seven,
        };
        blockPattern.Types.Returns(blockTypeMock);

        groupPattern = Substitute.For<IGroupPattern>();
        locationMock = new List<Coord[]>() {
            new Coord[] {
                new Coord(0, 0),
                new Coord(0, 1),
                new Coord(1, 0),
            },
            new Coord[] {
                new Coord(0, 0),
                new Coord(1, 0),
                new Coord(0, -1),
            },
            new Coord[] {
                new Coord(0, 0),
                new Coord(0, -1),
                new Coord(-1, 0),
            },
            new Coord[] {
                new Coord(0, 0),
                new Coord(-1, 0),
                new Coord(0, 1),
            },
        };
        groupPattern.Patterns.Returns(locationMock);
    }
示例#7
0
 public IGroup Create(ISetting setting, IBlockPattern blockPattern, IGroupPattern groupPattern)
 {
     throw new System.NotImplementedException();
 }
示例#8
0
 public IGroup Create(ISetting setting, IBlockPattern blockPattern, IGroupPattern groupPattern)
 {
     throw new System.NotImplementedException();
 }
示例#9
0
    public bool AddGroupToTheGrid(IBlockPattern blockPattern, IGroupPattern groupPattern)
    {
        IGroup group = _groupFactory.Create(_setting, blockPattern, groupPattern);

        return(_grid.AddGroup(group));
    }
示例#10
0
 public bool AddGroupToTheGrid(IBlockPattern blockPattern, IGroupPattern groupPattern)
 {
     IGroup group = _groupFactory.Create(_setting, blockPattern, groupPattern);
     return _grid.AddGroup(group);
 }