Project

General

Profile

Download (20.7 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / objects / ObjectList.java @ 925ed78f

1 27a70eae Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19
20 1f9772f3 Leszek Koltunski
package org.distorted.objects;
21 27a70eae Leszek Koltunski
22 ccf9fec5 Leszek Koltunski
import android.content.res.Resources;
23
24 27a70eae Leszek Koltunski
import org.distorted.library.main.DistortedEffects;
25
import org.distorted.library.main.DistortedTexture;
26 efa8aa48 Leszek Koltunski
import org.distorted.library.mesh.MeshSquare;
27 27a70eae Leszek Koltunski
import org.distorted.library.type.Static4D;
28 1f9772f3 Leszek Koltunski
import org.distorted.main.R;
29 f6a9c538 Leszek Koltunski
import org.distorted.main.RubikActivity;
30 27a70eae Leszek Koltunski
31 20931cf6 Leszek Koltunski
import java.lang.reflect.Field;
32
33 27a70eae Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
34
35 9c2f0c91 Leszek Koltunski
public enum ObjectList
36 27a70eae Leszek Koltunski
  {
37 4c0cd600 Leszek Koltunski
  CUBE (
38
         new int[][] {
39 31a9f38d Leszek Koltunski
                       {2 , 12, R.raw.cube2, R.drawable.ui_small_cube2, R.drawable.ui_medium_cube2, R.drawable.ui_big_cube2, R.drawable.ui_huge_cube2} ,
40
                       {3 , 16, R.raw.cube3, R.drawable.ui_small_cube3, R.drawable.ui_medium_cube3, R.drawable.ui_big_cube3, R.drawable.ui_huge_cube3} ,
41
                       {4 , 20, R.raw.cube4, R.drawable.ui_small_cube4, R.drawable.ui_medium_cube4, R.drawable.ui_big_cube4, R.drawable.ui_huge_cube4} ,
42
                       {5 , 24, R.raw.cube5, R.drawable.ui_small_cube5, R.drawable.ui_medium_cube5, R.drawable.ui_big_cube5, R.drawable.ui_huge_cube5}
43 4c0cd600 Leszek Koltunski
                     },
44 9c2f0c91 Leszek Koltunski
         TwistyCube.class,
45 ca3300c3 Leszek Koltunski
         new MovementCube(),
46 db875721 Leszek Koltunski
         0,
47
         60
48 4c0cd600 Leszek Koltunski
       ),
49
50
  PYRA (
51
         new int[][] {
52 31a9f38d Leszek Koltunski
                       {3 , 10, R.raw.pyra3, R.drawable.ui_small_pyra3, R.drawable.ui_medium_pyra3, R.drawable.ui_big_pyra3, R.drawable.ui_huge_pyra3} ,
53
                       {4 , 15, R.raw.pyra4, R.drawable.ui_small_pyra4, R.drawable.ui_medium_pyra4, R.drawable.ui_big_pyra4, R.drawable.ui_huge_pyra4} ,
54
                       {5 , 20, R.raw.pyra5, R.drawable.ui_small_pyra5, R.drawable.ui_medium_pyra5, R.drawable.ui_big_pyra5, R.drawable.ui_huge_pyra5}
55 4c0cd600 Leszek Koltunski
                     },
56 9c2f0c91 Leszek Koltunski
         TwistyPyraminx.class,
57 ca3300c3 Leszek Koltunski
         new MovementPyraminx(),
58 db875721 Leszek Koltunski
         1,
59
         30
60 4c0cd600 Leszek Koltunski
       ),
61 418aa554 Leszek Koltunski
62 bc649d9a Leszek Koltunski
  ULTI (
63 ece1b58d Leszek Koltunski
         new int[][] {
64 2f0986b1 Leszek Koltunski
                       {2 , 18, R.raw.ulti, R.drawable.ui_small_ulti, R.drawable.ui_medium_ulti, R.drawable.ui_big_ulti, R.drawable.ui_huge_ulti} ,
65 ece1b58d Leszek Koltunski
                     },
66 bc649d9a Leszek Koltunski
         TwistyUltimate.class,
67
         new MovementUltimate(),
68 db875721 Leszek Koltunski
         1,
69 bc649d9a Leszek Koltunski
         30
70 ece1b58d Leszek Koltunski
       ),
71
72 a207be5b Leszek Koltunski
  KILO (
73
         new int[][] {
74
                       {3 , 18, R.raw.kilo3, R.drawable.ui_small_kilo3, R.drawable.ui_medium_kilo3, R.drawable.ui_big_kilo3, R.drawable.ui_huge_kilo3} ,
75
                       {5 , 33, R.raw.kilo5, R.drawable.ui_small_kilo5, R.drawable.ui_medium_kilo5, R.drawable.ui_big_kilo5, R.drawable.ui_huge_kilo5} ,
76
                     },
77
         TwistyKilominx.class,
78
         new MovementMinx(),
79
         2,
80
         30
81
       ),
82
83
  MEGA (
84
         new int[][] {
85
                       {3 , 21, R.raw.mega3, R.drawable.ui_small_mega3, R.drawable.ui_medium_mega3, R.drawable.ui_big_mega3, R.drawable.ui_huge_mega3} ,
86
                       {5 , 35, R.raw.mega5, R.drawable.ui_small_mega5, R.drawable.ui_medium_mega5, R.drawable.ui_big_mega5, R.drawable.ui_huge_mega5} ,
87
                     },
88
         TwistyMegaminx.class,
89
         new MovementMinx(),
90
         2,
91
         30
92
       ),
93
94 418aa554 Leszek Koltunski
  DINO (
95
         new int[][] {
96 e50d4668 Leszek Koltunski
                       {3 , 10, R.raw.dino, R.drawable.ui_small_dino, R.drawable.ui_medium_dino, R.drawable.ui_big_dino, R.drawable.ui_huge_dino} ,
97 418aa554 Leszek Koltunski
                     },
98 9c2f0c91 Leszek Koltunski
         TwistyDino6.class,
99 ca3300c3 Leszek Koltunski
         new MovementDino(),
100 a207be5b Leszek Koltunski
         3,
101 db875721 Leszek Koltunski
         60
102 eaee1ddc Leszek Koltunski
       ),
103
104
  DIN4 (
105
         new int[][] {
106
                       {3 ,  7, R.raw.dino, R.drawable.ui_small_din4, R.drawable.ui_medium_din4, R.drawable.ui_big_din4, R.drawable.ui_huge_din4} ,
107
                     },
108 9c2f0c91 Leszek Koltunski
         TwistyDino4.class,
109 ca3300c3 Leszek Koltunski
         new MovementDino(),
110 a207be5b Leszek Koltunski
         3,
111 db875721 Leszek Koltunski
         60
112 418aa554 Leszek Koltunski
       ),
113 fb52fae9 Leszek Koltunski
114 b96a79ff Leszek Koltunski
  REDI (
115 ee35e63c Leszek Koltunski
         new int[][] {
116 e50d4668 Leszek Koltunski
                       {3 , 14, R.raw.redi, R.drawable.ui_small_redi, R.drawable.ui_medium_redi, R.drawable.ui_big_redi, R.drawable.ui_huge_redi} ,
117 ee35e63c Leszek Koltunski
                     },
118 b96a79ff Leszek Koltunski
         TwistyRedi.class,
119
         new MovementRedi(),
120 a207be5b Leszek Koltunski
         3,
121 db875721 Leszek Koltunski
         60
122 ee35e63c Leszek Koltunski
       ),
123 68f6046c Leszek Koltunski
124 b96a79ff Leszek Koltunski
  HELI (
125 68f6046c Leszek Koltunski
         new int[][] {
126 e50d4668 Leszek Koltunski
                       {3 , 18, R.raw.heli, R.drawable.ui_small_heli, R.drawable.ui_medium_heli, R.drawable.ui_big_heli, R.drawable.ui_huge_heli} ,
127 68f6046c Leszek Koltunski
                     },
128 b96a79ff Leszek Koltunski
         TwistyHelicopter.class,
129
         new MovementHelicopter(),
130 a207be5b Leszek Koltunski
         3,
131 db875721 Leszek Koltunski
         60
132 3f3ff476 Leszek Koltunski
       ),
133
134
  SKEW (
135
         new int[][] {
136 67b2d57b Leszek Koltunski
                       {2 , 11, R.raw.skew2, R.drawable.ui_small_skewb, R.drawable.ui_medium_skewb, R.drawable.ui_big_skewb, R.drawable.ui_huge_skewb} ,
137
                       {3 , 17, R.raw.skew3, R.drawable.ui_small_skewm, R.drawable.ui_medium_skewm, R.drawable.ui_big_skewm, R.drawable.ui_huge_skewm} ,
138 3f3ff476 Leszek Koltunski
                     },
139
         TwistySkewb.class,
140
         new MovementSkewb(),
141 a207be5b Leszek Koltunski
         4,
142 db875721 Leszek Koltunski
         60
143 68f6046c Leszek Koltunski
       ),
144 49cd8581 Leszek Koltunski
145 bbc6da6c Leszek Koltunski
  IVY  (
146 49cd8581 Leszek Koltunski
         new int[][] {
147 d73de3db Leszek Koltunski
                       {2 , 8, R.raw.ivy, R.drawable.ui_small_ivy, R.drawable.ui_medium_ivy, R.drawable.ui_big_ivy, R.drawable.ui_huge_ivy} ,
148 49cd8581 Leszek Koltunski
                     },
149
         TwistyIvy.class,
150
         new MovementIvy(),
151 a207be5b Leszek Koltunski
         4,
152 db875721 Leszek Koltunski
         60
153 49cd8581 Leszek Koltunski
       ),
154 59b87d56 Leszek Koltunski
155 bbc6da6c Leszek Koltunski
  REX  (
156 59b87d56 Leszek Koltunski
         new int[][] {
157 e50d4668 Leszek Koltunski
                       {3 , 16, R.raw.rex, R.drawable.ui_small_rex, R.drawable.ui_medium_rex, R.drawable.ui_big_rex, R.drawable.ui_huge_rex} ,
158 59b87d56 Leszek Koltunski
                     },
159
         TwistyRex.class,
160
         new MovementRex(),
161 db875721 Leszek Koltunski
         4,
162 a207be5b Leszek Koltunski
         60
163 bbc6da6c Leszek Koltunski
       ),
164 4c0a6d97 Leszek Koltunski
165
  BAN1 (
166
         new int[][] {
167 4da63d67 Leszek Koltunski
                       {3 , 16, R.raw.ban1, R.drawable.ui_small_ban1, R.drawable.ui_medium_ban1, R.drawable.ui_big_ban1, R.drawable.ui_huge_ban1} ,
168 4c0a6d97 Leszek Koltunski
                     },
169
         TwistyBandagedFused.class,
170
         new MovementCube(),
171
         5,
172
         60
173
       ),
174 538ee7a6 Leszek Koltunski
175
  BAN2 (
176
         new int[][] {
177 4da63d67 Leszek Koltunski
                       {3 , 16, R.raw.ban2, R.drawable.ui_small_ban2, R.drawable.ui_medium_ban2, R.drawable.ui_big_ban2, R.drawable.ui_huge_ban2} ,
178 538ee7a6 Leszek Koltunski
                     },
179
         TwistyBandaged2Bar.class,
180
         new MovementCube(),
181
         5,
182
         60
183
       ),
184
185
  BAN3 (
186
         new int[][] {
187 4da63d67 Leszek Koltunski
                       {3 , 16, R.raw.ban3, R.drawable.ui_small_ban3, R.drawable.ui_medium_ban3, R.drawable.ui_big_ban3, R.drawable.ui_huge_ban3} ,
188 538ee7a6 Leszek Koltunski
                     },
189
         TwistyBandaged3Plate.class,
190
         new MovementCube(),
191
         5,
192
         60
193
       ),
194
195
  BAN4 (
196
         new int[][] {
197 4da63d67 Leszek Koltunski
                       {3 , 16, R.raw.ban4, R.drawable.ui_small_ban4, R.drawable.ui_medium_ban4, R.drawable.ui_big_ban4, R.drawable.ui_huge_ban4} ,
198 538ee7a6 Leszek Koltunski
                     },
199
         TwistyBandagedEvil.class,
200
         new MovementCube(),
201
         5,
202
         60
203
       ),
204 bc649d9a Leszek Koltunski
205
  DIAM (
206
         new int[][] {
207 7ecb58db Leszek Koltunski
                       {2 , 10, R.raw.diam2, R.drawable.ui_small_diam2, R.drawable.ui_medium_diam2, R.drawable.ui_big_diam2, R.drawable.ui_huge_diam2} ,
208
                       {3 , 18, R.raw.diam3, R.drawable.ui_small_diam3, R.drawable.ui_medium_diam3, R.drawable.ui_big_diam3, R.drawable.ui_huge_diam3} ,
209 bc649d9a Leszek Koltunski
                     },
210
         TwistyDiamond.class,
211
         new MovementDiamond(),
212
         6,
213
         60
214
       ),
215 834b2618 Leszek Koltunski
216
  SQU1 (
217
         new int[][] {
218
                       {2 , 18, 0, R.drawable.ui_small_diam2, R.drawable.ui_medium_diam2, R.drawable.ui_big_diam2, R.drawable.ui_huge_diam2} ,
219
                     },
220
         TwistySquare1.class,
221
         new MovementSquare(),
222
         6,
223
         60
224
       ),
225 27a70eae Leszek Koltunski
  ;
226
227 4888e97c Leszek Koltunski
  public static final int NUM_OBJECTS = values().length;
228 8cccfb10 Leszek Koltunski
  public static final int MAX_NUM_OBJECTS;
229 8e3898c8 Leszek Koltunski
  public static final int MAX_LEVEL;
230 8cccfb10 Leszek Koltunski
  public static final int MAX_OBJECT_SIZE;
231 4888e97c Leszek Koltunski
232 31a9f38d Leszek Koltunski
  private final int[] mObjectSizes, mMaxLevels, mSmallIconIDs, mMediumIconIDs, mBigIconIDs, mHugeIconIDs, mResourceIDs;
233 9c2f0c91 Leszek Koltunski
  private final Class<? extends TwistyObject> mObjectClass;
234 ca3300c3 Leszek Koltunski
  private final Movement mObjectMovementClass;
235 0501a4b8 Leszek Koltunski
  private final int mRow, mNumSizes;
236 db875721 Leszek Koltunski
  private final int mFOV;
237 fa679111 Leszek Koltunski
238 9c2f0c91 Leszek Koltunski
  private static final ObjectList[] objects;
239 4888e97c Leszek Koltunski
  private static int mNumAll;
240 e07c48a2 Leszek Koltunski
  private static int[] mIndices;
241 fa679111 Leszek Koltunski
  private static int mColCount, mRowCount;
242 27a70eae Leszek Koltunski
243
  static
244
    {
245 4888e97c Leszek Koltunski
    mNumAll = 0;
246 8cccfb10 Leszek Koltunski
    int num, i = 0;
247 9c2f0c91 Leszek Koltunski
    objects = new ObjectList[NUM_OBJECTS];
248 8cccfb10 Leszek Koltunski
    int maxNum  = Integer.MIN_VALUE;
249
    int maxLevel= Integer.MIN_VALUE;
250
    int maxSize = Integer.MIN_VALUE;
251 27a70eae Leszek Koltunski
252 9c2f0c91 Leszek Koltunski
    for(ObjectList object: ObjectList.values())
253 27a70eae Leszek Koltunski
      {
254 4888e97c Leszek Koltunski
      objects[i] = object;
255 27a70eae Leszek Koltunski
      i++;
256 8cccfb10 Leszek Koltunski
      num = object.mObjectSizes.length;
257
      mNumAll += num;
258
      if( num> maxNum ) maxNum = num;
259 8e3898c8 Leszek Koltunski
260 8cccfb10 Leszek Koltunski
      for(int j=0; j<num; j++)
261 8e3898c8 Leszek Koltunski
        {
262
        if( object.mMaxLevels[j] > maxLevel ) maxLevel = object.mMaxLevels[j];
263 8cccfb10 Leszek Koltunski
        if( object.mObjectSizes[j] > maxSize) maxSize  = object.mObjectSizes[j];
264 8e3898c8 Leszek Koltunski
        }
265 27a70eae Leszek Koltunski
      }
266 4888e97c Leszek Koltunski
267 8cccfb10 Leszek Koltunski
    MAX_NUM_OBJECTS = maxNum;
268
    MAX_LEVEL       = maxLevel;
269
    MAX_OBJECT_SIZE = maxSize;
270 27a70eae Leszek Koltunski
    }
271
272 e07c48a2 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
273 fa679111 Leszek Koltunski
274
  private static void setUpColAndRow()
275
    {
276
    mIndices = new int[NUM_OBJECTS];
277 0501a4b8 Leszek Koltunski
    mRowCount= 0;
278 fa679111 Leszek Koltunski
279
    for(int obj=0; obj<NUM_OBJECTS; obj++)
280
      {
281 0501a4b8 Leszek Koltunski
      mIndices[obj] = objects[obj].mRow;
282
      if( mIndices[obj]>=mRowCount ) mRowCount = mIndices[obj]+1;
283 fa679111 Leszek Koltunski
      }
284
285 0501a4b8 Leszek Koltunski
    mColCount = 0;
286 fa679111 Leszek Koltunski
287 0501a4b8 Leszek Koltunski
    for(int row=0; row<mRowCount; row++)
288 fa679111 Leszek Koltunski
      {
289 0501a4b8 Leszek Koltunski
      int numObjects = computeNumObjectsInRow(row);
290
      if( numObjects>mColCount ) mColCount = numObjects;
291 fa679111 Leszek Koltunski
      }
292
    }
293
294
///////////////////////////////////////////////////////////////////////////////////////////////////
295
296 0501a4b8 Leszek Koltunski
  private static int computeNumObjectsInRow(int row)
297 fa679111 Leszek Koltunski
    {
298
    int num=0;
299
300
    for(int object=0; object<NUM_OBJECTS; object++)
301
      {
302 0501a4b8 Leszek Koltunski
      if( objects[object].mRow == row )
303 fa679111 Leszek Koltunski
        {
304
        num += objects[object].mNumSizes;
305
        }
306
      }
307
308
    return num;
309
    }
310
311
///////////////////////////////////////////////////////////////////////////////////////////////////
312
313 e07c48a2 Leszek Koltunski
  public static int getColumnCount()
314
    {
315 fa679111 Leszek Koltunski
    if( mIndices==null ) setUpColAndRow();
316
317
    return mColCount;
318 e07c48a2 Leszek Koltunski
    }
319
320
///////////////////////////////////////////////////////////////////////////////////////////////////
321 fa679111 Leszek Koltunski
322 e07c48a2 Leszek Koltunski
  public static int getRowCount()
323
    {
324 fa679111 Leszek Koltunski
    if( mIndices==null ) setUpColAndRow();
325
326
    return mRowCount;
327 e07c48a2 Leszek Koltunski
    }
328
329
///////////////////////////////////////////////////////////////////////////////////////////////////
330 fa679111 Leszek Koltunski
331 e07c48a2 Leszek Koltunski
  public static int[] getIndices()
332
    {
333 fa679111 Leszek Koltunski
    if( mIndices==null ) setUpColAndRow();
334
335 e07c48a2 Leszek Koltunski
    return mIndices;
336
    }
337
338 27a70eae Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
339
340 9c2f0c91 Leszek Koltunski
  public static ObjectList getObject(int ordinal)
341 27a70eae Leszek Koltunski
    {
342 7ec268b1 Leszek Koltunski
    return ordinal>=0 && ordinal<NUM_OBJECTS ? objects[ordinal] : CUBE;
343 27a70eae Leszek Koltunski
    }
344
345
///////////////////////////////////////////////////////////////////////////////////////////////////
346
347 b498f3f6 Leszek Koltunski
  public static int pack(int object, int sizeIndex)
348 4888e97c Leszek Koltunski
    {
349
    int ret = 0;
350
    for(int i=0; i<object; i++) ret += objects[i].mObjectSizes.length;
351
352 b498f3f6 Leszek Koltunski
    return ret+sizeIndex;
353 4888e97c Leszek Koltunski
    }
354
355
///////////////////////////////////////////////////////////////////////////////////////////////////
356
357 8e3898c8 Leszek Koltunski
  public static int unpackSizeIndex(int number)
358 4888e97c Leszek Koltunski
    {
359
    int num;
360
361
    for(int i=0; i<NUM_OBJECTS; i++)
362
      {
363
      num = objects[i].mObjectSizes.length;
364
      if( number<num ) return number;
365
      number -= num;
366
      }
367
368
    return -1;
369
    }
370
371
///////////////////////////////////////////////////////////////////////////////////////////////////
372
373
  public static int unpackObject(int number)
374 27a70eae Leszek Koltunski
    {
375 4888e97c Leszek Koltunski
    int num;
376
377
    for(int i=0; i<NUM_OBJECTS; i++)
378
      {
379
      num = objects[i].mObjectSizes.length;
380
      if( number<num ) return i;
381
      number -= num;
382
      }
383
384
    return -1;
385
    }
386
387 286d73ae Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
388
389
  public static int unpackObjectFromString(String obj)
390
    {
391
    int u = obj.indexOf('_');
392
    int l = obj.length();
393
394
    if( u>0 )
395
      {
396
      String name = obj.substring(0,u);
397
      int size = Integer.parseInt( obj.substring(u+1,l) );
398
399
      for(int i=0; i<NUM_OBJECTS; i++)
400
        {
401
        if( objects[i].name().equals(name) )
402
          {
403 53f23b64 Leszek Koltunski
          int sizeIndex = getSizeIndex(i,size);
404
          return pack(i,sizeIndex);
405 286d73ae Leszek Koltunski
          }
406
        }
407
      }
408
409
    return -1;
410
    }
411
412
///////////////////////////////////////////////////////////////////////////////////////////////////
413
414
  public static String getObjectList()
415
    {
416
    String name;
417
    StringBuilder list = new StringBuilder();
418
    int len;
419
    int[] sizes;
420
421
    for(int i=0; i<NUM_OBJECTS; i++)
422
      {
423
      sizes = objects[i].mObjectSizes;
424
      len   = sizes.length;
425
      name  = objects[i].name();
426
427
      for(int j=0; j<len; j++)
428
        {
429
        if( i>0 || j>0 ) list.append(',');
430
        list.append(name);
431
        list.append('_');
432
        list.append(sizes[j]);
433
        }
434
      }
435
436
    return list.toString();
437
    }
438
439 4888e97c Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
440
441
  public static int getTotal()
442
    {
443
    return mNumAll;
444
    }
445
446 8e3898c8 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
447
448
  public static int getMaxLevel(int ordinal, int sizeIndex)
449
    {
450
    if( ordinal>=0 && ordinal<NUM_OBJECTS )
451
      {
452
      int num = objects[ordinal].mObjectSizes.length;
453
      return sizeIndex>=0 && sizeIndex<num ? objects[ordinal].mMaxLevels[sizeIndex] : 0;
454
      }
455
456
    return 0;
457
    }
458
459 c86f9f1f Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
460
461
  public static int getOrdinal(String name)
462
    {
463
    for(int i=0; i<NUM_OBJECTS; i++)
464
      {
465
      if(objects[i].name().equals(name)) return i;
466
      }
467
468
    return -1;
469
    }
470
471
///////////////////////////////////////////////////////////////////////////////////////////////////
472
473 53f23b64 Leszek Koltunski
  public static int getSizeIndex(int ordinal, int size)
474 c86f9f1f Leszek Koltunski
    {
475 7ec268b1 Leszek Koltunski
    if( ordinal>=0 && ordinal<NUM_OBJECTS )
476 c86f9f1f Leszek Koltunski
      {
477 7ec268b1 Leszek Koltunski
      int[] sizes = objects[ordinal].getSizes();
478
      int len = sizes.length;
479
480
      for(int i=0; i<len; i++)
481
        {
482
        if( sizes[i]==size ) return i;
483
        }
484 c86f9f1f Leszek Koltunski
      }
485
486
    return -1;
487
    }
488
489 4888e97c Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
490
491 9c2f0c91 Leszek Koltunski
  public static int[] retFaceColors(ObjectList object)
492 20931cf6 Leszek Koltunski
    {
493
    Field field;
494
    int[] faceColors=null;
495
496
    try
497
      {
498
      field = object.mObjectClass.getDeclaredField("FACE_COLORS");
499
      field.setAccessible(true);
500
      Object obj = field.get(null);
501
      faceColors = (int[]) obj;
502
      }
503
    catch(NoSuchFieldException ex)
504
      {
505
      android.util.Log.e("RubikObjectList", object.mObjectClass.getSimpleName()+": no such field exception getting field: "+ex.getMessage());
506
      }
507
    catch(IllegalAccessException ex)
508
      {
509
      android.util.Log.e("RubikObjectList", object.mObjectClass.getSimpleName()+": illegal access exception getting field: "+ex.getMessage());
510
      }
511
512
    return faceColors;
513
    }
514
515
///////////////////////////////////////////////////////////////////////////////////////////////////
516
517 0501a4b8 Leszek Koltunski
  ObjectList(int[][] info, Class<? extends TwistyObject> object , Movement movement, int row, int fov)
518 4888e97c Leszek Koltunski
    {
519 fa679111 Leszek Koltunski
    mNumSizes = info.length;
520 ea6ee91b Leszek Koltunski
521 fa679111 Leszek Koltunski
    mObjectSizes  = new int[mNumSizes];
522
    mMaxLevels    = new int[mNumSizes];
523
    mResourceIDs  = new int[mNumSizes];
524
    mSmallIconIDs = new int[mNumSizes];
525
    mMediumIconIDs= new int[mNumSizes];
526
    mBigIconIDs   = new int[mNumSizes];
527
    mHugeIconIDs  = new int[mNumSizes];
528 ea6ee91b Leszek Koltunski
529 fa679111 Leszek Koltunski
    for(int i=0; i<mNumSizes; i++)
530 ea6ee91b Leszek Koltunski
      {
531 f6a9c538 Leszek Koltunski
      mObjectSizes[i]  = info[i][0];
532
      mMaxLevels[i]    = info[i][1];
533
      mResourceIDs[i]  = info[i][2];
534
      mSmallIconIDs[i] = info[i][3];
535
      mMediumIconIDs[i]= info[i][4];
536
      mBigIconIDs[i]   = info[i][5];
537 31a9f38d Leszek Koltunski
      mHugeIconIDs[i]  = info[i][6];
538 ea6ee91b Leszek Koltunski
      }
539
540 20931cf6 Leszek Koltunski
    mObjectClass         = object;
541 27a70eae Leszek Koltunski
    mObjectMovementClass = movement;
542 0501a4b8 Leszek Koltunski
    mRow                 = row;
543 db875721 Leszek Koltunski
    mFOV                 = fov;
544 27a70eae Leszek Koltunski
    }
545
546
///////////////////////////////////////////////////////////////////////////////////////////////////
547
548 8e3898c8 Leszek Koltunski
  public int[] getSizes()
549 27a70eae Leszek Koltunski
    {
550 8e3898c8 Leszek Koltunski
    return mObjectSizes;
551 27a70eae Leszek Koltunski
    }
552
553
///////////////////////////////////////////////////////////////////////////////////////////////////
554
555 8e3898c8 Leszek Koltunski
  public int[] getMaxLevels()
556 4888e97c Leszek Koltunski
    {
557 8e3898c8 Leszek Koltunski
    return mMaxLevels;
558
    }
559
560 db875721 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
561
562
  public int getFOV()
563
    {
564
    return mFOV;
565
    }
566
567 8e3898c8 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
568
569
  public int[] getIconIDs()
570
    {
571 f6a9c538 Leszek Koltunski
    int size = RubikActivity.getDrawableSize();
572
573
    switch(size)
574
      {
575
      case 0 : return mSmallIconIDs;
576
      case 1 : return mMediumIconIDs;
577 31a9f38d Leszek Koltunski
      case 2 : return mBigIconIDs;
578
      default: return mHugeIconIDs;
579 f6a9c538 Leszek Koltunski
      }
580 4888e97c Leszek Koltunski
    }
581
582
///////////////////////////////////////////////////////////////////////////////////////////////////
583
584 ccf9fec5 Leszek Koltunski
  public int[] getResourceIDs()
585
    {
586
    return mResourceIDs;
587
    }
588
589 fbca0033 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
590
591
  public int getNumVariants()
592
    {
593
    return mObjectSizes.length;
594
    }
595
596 ccf9fec5 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
597
598 9c2f0c91 Leszek Koltunski
  public TwistyObject create(int size, Static4D quat, int[][] moves, Resources res, int scrWidth)
599 27a70eae Leszek Koltunski
    {
600 5974d2ae Leszek Koltunski
    DistortedTexture texture = new DistortedTexture();
601 36273130 Leszek Koltunski
    DistortedEffects effects = new DistortedEffects();
602 fb52fae9 Leszek Koltunski
    MeshSquare mesh          = new MeshSquare(20,20);   // mesh of the node, not of the cubits
603 74686c71 Leszek Koltunski
604 4888e97c Leszek Koltunski
    switch(ordinal())
605
      {
606 538ee7a6 Leszek Koltunski
      case  0: return new TwistyCube          (size, quat, texture, mesh, effects, moves, res, scrWidth);
607
      case  1: return new TwistyPyraminx      (size, quat, texture, mesh, effects, moves, res, scrWidth);
608 bc649d9a Leszek Koltunski
      case  2: return new TwistyUltimate      (size, quat, texture, mesh, effects, moves, res, scrWidth);
609 53e7de7e Leszek Koltunski
      case  3: return new TwistyKilominx      (size, quat, texture, mesh, effects, moves, res, scrWidth);
610
      case  4: return new TwistyMegaminx      (size, quat, texture, mesh, effects, moves, res, scrWidth);
611
      case  5: return new TwistyDino6         (size, quat, texture, mesh, effects, moves, res, scrWidth);
612
      case  6: return new TwistyDino4         (size, quat, texture, mesh, effects, moves, res, scrWidth);
613
      case  7: return new TwistyRedi          (size, quat, texture, mesh, effects, moves, res, scrWidth);
614
      case  8: return new TwistyHelicopter    (size, quat, texture, mesh, effects, moves, res, scrWidth);
615
      case  9: return new TwistySkewb         (size, quat, texture, mesh, effects, moves, res, scrWidth);
616
      case 10: return new TwistyIvy           (size, quat, texture, mesh, effects, moves, res, scrWidth);
617
      case 11: return new TwistyRex           (size, quat, texture, mesh, effects, moves, res, scrWidth);
618 538ee7a6 Leszek Koltunski
      case 12: return new TwistyBandagedFused (size, quat, texture, mesh, effects, moves, res, scrWidth);
619 bc649d9a Leszek Koltunski
      case 13: return new TwistyBandaged2Bar  (size, quat, texture, mesh, effects, moves, res, scrWidth);
620 538ee7a6 Leszek Koltunski
      case 14: return new TwistyBandaged3Plate(size, quat, texture, mesh, effects, moves, res, scrWidth);
621
      case 15: return new TwistyBandagedEvil  (size, quat, texture, mesh, effects, moves, res, scrWidth);
622 bc649d9a Leszek Koltunski
      case 16: return new TwistyDiamond       (size, quat, texture, mesh, effects, moves, res, scrWidth);
623 834b2618 Leszek Koltunski
      case 17: return new TwistySquare1       (size, quat, texture, mesh, effects, moves, res, scrWidth);
624 4888e97c Leszek Koltunski
      }
625
626
    return null;
627 27a70eae Leszek Koltunski
    }
628
629
///////////////////////////////////////////////////////////////////////////////////////////////////
630
631 ca3300c3 Leszek Koltunski
  public Movement getObjectMovementClass()
632 27a70eae Leszek Koltunski
    {
633 4888e97c Leszek Koltunski
    return mObjectMovementClass;
634 27a70eae Leszek Koltunski
    }
635
  }