Ejemplo n.º 1
0
    public System.Enum RandSubType(BaseBlockType baseType)
    {
        int subEnumLength;
        int subRand;

        switch (baseType)
        {
        case BaseBlockType.Animals:
            subEnumLength = System.Enum.GetValues(typeof(AnimalType)).Length;
            subRand       = Random.Range(0, subEnumLength);
            return((AnimalType)subRand);

        case BaseBlockType.Geometry:
            subEnumLength = System.Enum.GetValues(typeof(GeometaryType)).Length;
            subRand       = Random.Range(0, subEnumLength);
            return((GeometaryType)subRand);

        case BaseBlockType.Letters:
            subEnumLength = System.Enum.GetValues(typeof(LetterBlockType)).Length;
            subRand       = Random.Range(0, subEnumLength);
            return((LetterBlockType)subRand);

        default:
            Debug.WriteLine("Block Sub Type Selection not working");
            return(null);
        }
    }
Ejemplo n.º 2
0
 public BlockType(BaseBlockType baseT)
 {
     //Set base type
     baseType = baseT;
     //Set sub type
     subType = RandSubType(baseType);
 }
Ejemplo n.º 3
0
 public BlockType(BaseBlockType baseT, System.Enum subT)
 {
     //Set base type
     baseType = baseT;
     //Set sub type
     subType = subT;
     //possibly need to perform checks that sub-type is acceptable
 }
Ejemplo n.º 4
0
 public BlockType(bool random)
 {
     if (random)
     {
         //Set base type
         int enumLength = System.Enum.GetValues(typeof(BaseBlockType)).Length;
         int rand       = Random.Range(0, enumLength);
         baseType = (BaseBlockType)rand;
         //Set sub type
         subType = RandSubType(baseType);
     }
 }