public PuzzleGrid ( PuzzleQuad[] quads ) { if ( quads.Length != 4 ) return; byte index; for ( byte i = 0; i < 4; i++ ) for ( byte j = 0; j < 64; j++ ) { index = (byte)( ( j % 8 ) + ( ( i % 2 ) << 3 ) + ( ( j >> 3 ) << 4 ) + ( ( i >> 1 ) << 7 ) ); foreach ( KeyValuePair<char, Level.Directions> dir in Level.dictDirections ) if ( quads[i][j].IndexOf ( dir.Key ) != -1 ) walls[index] |= (byte)dir.Value; //foreach ( KeyValuePair<string, byte> token in Level.dictTokens ) for ( int k = 0; k < Level.TOKENS.Length; k++ ) if ( quads[i][j].IndexOf ( Level.TOKENS[k] ) != -1 ) tokensPos[k] = index; }; }
private PuzzleGrid CreateGrid ( PuzzleQuad[] shuffled_quads = null ) { int[] rotnumber = new int[4] { 0, 1, 3, 2 }; for ( int i = 0; i < shuffled_quads.Length; i++ ) shuffled_quads[i].Rotate ( rotnumber[i] ); return new PuzzleGrid ( shuffled_quads ); }
public Level ( int seed = 0, PuzzleQuad[] quads = null, byte[] robots = null, string token = null ) { if ( seed == 0 ) { quads = DefaultQuads.hardest; robots = new byte[] { 226, 48, 43, 18 }; token = "BT"; } else { this.rnd = new System.Random ( seed ); } this.grid = CreateGrid ( quads ); this.tokensPos = this.grid.tokensPos; this.robotsPos = PlaceRobots ( robots ); this.token = ChooseToken ( token ); }