コード例 #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 ShouldReturnRandomBlockType()
 {
     for (int i = 0; i < 100; i++)
     {
         int randomNumber = (int)BlockTypeHelper.GetRandom(new System.Random(100));
         Assert.IsTrue(randomNumber >= 0 && randomNumber < (int)BlockType.AvailableBlocks);
     }
 }