1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2020 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Magic Cube. //
|
5
|
// //
|
6
|
// Magic Cube is proprietary software licensed under an EULA which you should have received //
|
7
|
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html //
|
8
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
9
|
|
10
|
package org.distorted.objectlib.main;
|
11
|
|
12
|
import java.io.InputStream;
|
13
|
import java.lang.reflect.Constructor;
|
14
|
import java.lang.reflect.InvocationTargetException;
|
15
|
|
16
|
import org.distorted.library.type.Static3D;
|
17
|
import org.distorted.library.type.Static4D;
|
18
|
|
19
|
import org.distorted.objectlib.R;
|
20
|
import org.distorted.objectlib.objects.*;
|
21
|
|
22
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
23
|
|
24
|
public enum ObjectType
|
25
|
{
|
26
|
CUBE_2 ( TwistyCuboid.class , 12, R.drawable.cube_2, true, 0, new InitData(new int[] {2,2,2})),
|
27
|
CUBE_3 ( TwistyCuboid.class , 17, R.drawable.cube_3, true, 0, new InitData(new int[] {3,3,3})),
|
28
|
CUBE_4 ( TwistyCuboid.class , 24, R.drawable.cube_4, true, 50, new InitData(new int[] {4,4,4})),
|
29
|
CUBE_5 ( TwistyCuboid.class , 28, R.drawable.cube_5, true, 60, new InitData(new int[] {5,5,5})),
|
30
|
CUBE_6 ( TwistyCuboid.class , 35, R.drawable.cube_6, true, 70, new InitData(new int[] {6,6,6})),
|
31
|
|
32
|
CUBE_7 ( TwistyCuboid.class , 42, R.drawable.cube_7, true, 100, new InitData(new int[] {7,7,7})),
|
33
|
BAN1_3 ( TwistyBandagedCuboid.class , 16, R.drawable.ban1_3, true, 0, new InitData(new int[] {3,3,3}, TwistyBandagedCuboid.POS_1)),
|
34
|
BAN2_3 ( TwistyBandagedCuboid.class , 20, R.drawable.ban2_3, true, 50, new InitData(new int[] {3,3,3}, TwistyBandagedCuboid.POS_2)),
|
35
|
BAN3_3 ( TwistyBandagedCuboid.class , 16, R.drawable.ban3_3, true, 50, new InitData(new int[] {3,3,3}, TwistyBandagedCuboid.POS_3)),
|
36
|
BAN4_3 ( TwistyBandagedCuboid.class , 22, R.drawable.ban4_3, true, 60, new InitData(new int[] {3,3,3}, TwistyBandagedCuboid.POS_4)),
|
37
|
|
38
|
CU_323 ( TwistyCuboid.class , 15, R.drawable.cu_323, true, 40, new InitData(new int[] {3,2,3})),
|
39
|
CU_232 ( TwistyCuboid.class , 16, R.drawable.cu_232, true, 0, new InitData(new int[] {2,3,2})),
|
40
|
CU_343 ( TwistyCuboid.class , 23, R.drawable.cu_343, true, 50, new InitData(new int[] {3,4,3})),
|
41
|
SQU1_3 ( TwistySquare1.class , 24, R.drawable.squ1_3, true, 70, new InitData(new int[] {3,2,3})),
|
42
|
SQU2_3 ( TwistySquare2.class , 24, R.drawable.squ2_3, true, 70, new InitData(new int[] {3,2,3})),
|
43
|
|
44
|
MORP_2 ( TwistyMorphix.class , 12, R.drawable.morp_2, true, 0, new InitData(new int[] {2,2,2})),
|
45
|
MORP_3 ( TwistyMorphix.class , 17, R.drawable.morp_3, true , 60, new InitData(new int[] {3,3,3})),
|
46
|
MORP_4 ( TwistyMorphix.class , 24, R.drawable.morp_4, true , 70, new InitData(new int[] {4,4,4})),
|
47
|
JING_2 ( TwistyJing.class , 11, R.drawable.jing_2, true, 50, new InitData(new int[] {2,2,2,2})),
|
48
|
PYRA_3 ( TwistyPyraminx.class , 10, R.drawable.pyra_3, true, 0, new InitData(new int[] {3,3,3,3})),
|
49
|
|
50
|
PYRA_4 ( TwistyPyraminx.class , 17, R.drawable.pyra_4, true, 50, new InitData(new int[] {4,4,4,4})),
|
51
|
PYRA_5 ( TwistyPyraminx.class , 23, R.drawable.pyra_5, true, 70, new InitData(new int[] {5,5,5,5})),
|
52
|
CRYS_3 ( TwistyCrystal.class , 27, R.drawable.crys_3, true, 70, new InitData(new int[] {3,3,3,3,3,3})),
|
53
|
STAR_3 ( TwistyStarminx.class , 27, R.drawable.star_3, true, 80, new InitData(new int[] {3,3,3,3,3,3})),
|
54
|
PENT_2 ( TwistyPentultimate.class , 21, R.drawable.pent_2, true, 80, new InitData(new int[] {2,2,2,2,2,2})),
|
55
|
|
56
|
ULTI_2 ( TwistyUltimate.class , 18, R.drawable.ulti_2, true, 70, new InitData(new int[] {2,2,2,2})),
|
57
|
KILO_3 ( TwistyKilominx.class , 18, R.drawable.kilo_3, true, 50, new InitData(new int[] {3,3,3,3,3,3})),
|
58
|
MEGA_3 ( TwistyMegaminx.class , 21, R.drawable.mega_3, true, 0, new InitData(new int[] {3,3,3,3,3,3})),
|
59
|
KILO_5 ( TwistyKilominx.class , 33, R.drawable.kilo_5, true, 80, new InitData(new int[] {5,5,5,5,5,5})),
|
60
|
MEGA_5 ( TwistyMegaminx.class , 37, R.drawable.mega_5, true, 100, new InitData(new int[] {5,5,5,5,5,5})),
|
61
|
|
62
|
TRAJ_3 ( TwistyTrajber.class , 17, R.drawable.traj_3, true, 50, new InitData(new int[] {3,3,3})),
|
63
|
TRAJ_4 ( TwistyTrajber.class , 24, R.drawable.traj_4, true, 60, new InitData(new int[] {4,4,4})),
|
64
|
DIAM_2 ( TwistyDiamond.class , 12, R.drawable.diam_2, true, 0, new InitData(new int[] {2,2,2,2})),
|
65
|
DIAM_3 ( TwistyDiamond.class , 24, R.drawable.diam_3, true, 60, new InitData(new int[] {3,3,3,3})),
|
66
|
DIAM_4 ( TwistyDiamond.class , 32, R.drawable.diam_4, true, 80, new InitData(new int[] {4,4,4,4})),
|
67
|
|
68
|
CRA1_2 ( TwistyCrazy2x2.class , 16, R.drawable.cra1_2, true , 50, new InitData(new int[] {2,2,2})),
|
69
|
CRA1_3 ( TwistyCrazy3x3.class , 22, R.drawable.cra1_3, true , 50, new InitData(new int[] {3,3,3}, TwistyCrazy3x3.CRAZY )),
|
70
|
CRA2_3 ( TwistyCrazy3x3.class , 22, R.drawable.cra2_3, true , 80, new InitData(new int[] {3,3,3}, TwistyCrazy3x3.MERCURY)),
|
71
|
CRA3_3 ( TwistyCrazy3x3.class , 22, R.drawable.cra3_3, true , 80, new InitData(new int[] {3,3,3}, TwistyCrazy3x3.VENUS )),
|
72
|
CRA4_3 ( TwistyCrazy3x3.class , 22, R.drawable.cra4_3, true , 80, new InitData(new int[] {3,3,3}, TwistyCrazy3x3.EARTH )),
|
73
|
|
74
|
CRA5_3 ( TwistyCrazy3x3.class , 22, R.drawable.cra5_3, true , 80, new InitData(new int[] {3,3,3}, TwistyCrazy3x3.MARS )),
|
75
|
CRA6_3 ( TwistyCrazy3x3.class , 22, R.drawable.cra6_3, true , 60, new InitData(new int[] {3,3,3}, TwistyCrazy3x3.JUPITER)),
|
76
|
CRA7_3 ( TwistyCrazy3x3.class , 22, R.drawable.cra7_3, true , 80, new InitData(new int[] {3,3,3}, TwistyCrazy3x3.SATURN )),
|
77
|
CRA8_3 ( TwistyCrazy3x3.class , 22, R.drawable.cra8_3, true , 60, new InitData(new int[] {3,3,3}, TwistyCrazy3x3.URANUS )),
|
78
|
CRA9_3 ( TwistyCrazy3x3.class , 22, R.drawable.cra9_3, true , 80, new InitData(new int[] {3,3,3}, TwistyCrazy3x3.NEPTUNE)),
|
79
|
|
80
|
MIRR_2 ( TwistyMirror.class , 12, R.drawable.mirr_2, true, 0, new InitData(new int[] {2,2,2})),
|
81
|
MIRR_3 ( TwistyMirror.class , 17, R.drawable.mirr_3, true, 50, new InitData(new int[] {3,3,3})),
|
82
|
MIRR_4 ( TwistyMirror.class , 24, R.drawable.mirr_4, true, 60, new InitData(new int[] {4,4,4})),
|
83
|
IVY_2 ( TwistyIvy.class , 9, R.drawable.ivy_2 , true, 0, new InitData(new int[] {2,2,2,2})),
|
84
|
REX_3 ( TwistyRex.class , 19, R.drawable.rex_3 , true, 70, new InitData(new int[] {3,3,3,3})),
|
85
|
|
86
|
REDI_3 ( TwistyRedi.class , 16, R.drawable.redi_3, true, 0, new InitData(new int[] {3,3,3,3})),
|
87
|
HELI_3 ( TwistyHelicopter.class , 20, R.drawable.heli_3, true, 80, new InitData(new int[] {3,3,3,3,3,3})),
|
88
|
SKEW_2 ( TwistySkewb.class , 11, R.drawable.skew_2, true, 0, new InitData(new int[] {2,2,2,2})),
|
89
|
SKEW_3 ( TwistySkewb.class , 21, R.drawable.skew_3, true, 70, new InitData(new int[] {3,3,3,3})),
|
90
|
CONT_2 ( TwistyContainer.class , 12, R.drawable.cont_2, true, 40, new InitData(new int[] {2,2,2,2})),
|
91
|
|
92
|
FISH_3 ( TwistyFisher.class , 24, R.drawable.fish_3, true, 50, new InitData(new int[] {3,3,3})),
|
93
|
WIND_3 ( TwistyWindmill.class , 24, R.drawable.wind_3, true, 50, new InitData(new int[] {3,3,3})),
|
94
|
AXIS_3 ( TwistyAxis.class , 24, R.drawable.axis_3, true, 60, new InitData(new int[] {3,3,3})),
|
95
|
VOID_3 ( TwistyVoid.class , 17, R.drawable.void_3, true, 70, new InitData(new int[] {3,3,3})),
|
96
|
MIXU_3 ( TwistyMixup3x3.class , 24, R.drawable.mixu_3, true, 70, new InitData(new int[] {3,3,3})),
|
97
|
|
98
|
MIXP_3 ( TwistyMixup3x3Plus.class , 28, R.drawable.mixp_3, true, 70, new InitData(new int[] {3,3,3})),
|
99
|
DINO_3 ( TwistyDino6.class , 10, R.drawable.dino_3, true, 0, new InitData(new int[] {3,3,3,3})),
|
100
|
DIN4_3 ( TwistyDino4.class , 9, R.drawable.din4_3, true, 30, new InitData(new int[] {3,3,3,3})),
|
101
|
|
102
|
BAN5_4 ( TwistyBandagedCuboid.class , 48, R.drawable.ban5_4, false, 50, new InitData(new int[] {4,4,4}, TwistyBandagedCuboid.POS_5)),
|
103
|
CA_333 ( TwistyCamouflage.class , 32, R.drawable.ca_333, false, 50, new InitData(new int[] {4,4,4}, TwistyCamouflage.CAM_333)),
|
104
|
|
105
|
PDUO_2 ( TwistyPyraminxDuo.class , 4, R.drawable.pduo_2, false, 0, new InitData(new int[] {2,2,2,2})),
|
106
|
PDIA_3 ( TwistyPyraminxDiamond.class, 12, R.drawable.pdia_3, false, 40, new InitData(new int[] {3,3,3})),
|
107
|
BALL_4 ( TwistyMasterball.class , 28, R.drawable.ball_4, false, 70, new InitData(new int[] {4,2,2,2,2})),
|
108
|
|
109
|
;
|
110
|
|
111
|
public static int NUM_OBJECTS;
|
112
|
public static final int DEFAULT_PRICE_OF_OLD_OBJECTS = 50;
|
113
|
public static final int MAX_SCRAMBLES = 42; // max scrambles at the time we switched from
|
114
|
// remembering the records the old way
|
115
|
private static final ObjectType[] objects;
|
116
|
|
117
|
private final InitData mInitData;
|
118
|
private final int mNumScrambles;
|
119
|
private final int mIcon;
|
120
|
private final boolean mExportToApp;
|
121
|
private final int mPrice;
|
122
|
private final Class<? extends TwistyObject> mClass;
|
123
|
|
124
|
static
|
125
|
{
|
126
|
NUM_OBJECTS = 0;
|
127
|
for(ObjectType object: ObjectType.values()) if( object.mExportToApp ) NUM_OBJECTS++;
|
128
|
|
129
|
int i = 0;
|
130
|
objects = new ObjectType[NUM_OBJECTS];
|
131
|
for(ObjectType object: ObjectType.values()) if( object.mExportToApp ) objects[i++] = object;
|
132
|
}
|
133
|
|
134
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
135
|
|
136
|
ObjectType(Class<? extends TwistyObject> clazz, int scrambles, int icon, boolean export, int price, InitData data)
|
137
|
{
|
138
|
mClass = clazz;
|
139
|
mInitData = data;
|
140
|
mNumScrambles= scrambles;
|
141
|
mIcon = icon;
|
142
|
mExportToApp = export;
|
143
|
mPrice = price;
|
144
|
}
|
145
|
|
146
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
147
|
// PUBLIC API
|
148
|
|
149
|
public static ObjectType getObject(int ordinal)
|
150
|
{
|
151
|
return ordinal>=0 && ordinal<NUM_OBJECTS ? objects[ordinal] : CUBE_3;
|
152
|
}
|
153
|
|
154
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
155
|
|
156
|
public static int getOrdinal(String name)
|
157
|
{
|
158
|
for(int i=0; i<NUM_OBJECTS; i++)
|
159
|
{
|
160
|
if( objects[i].name().equals(name) ) return i;
|
161
|
}
|
162
|
|
163
|
return -1;
|
164
|
}
|
165
|
|
166
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
167
|
|
168
|
public int getIconID()
|
169
|
{
|
170
|
return mIcon;
|
171
|
}
|
172
|
|
173
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
174
|
|
175
|
public int getNumScramble()
|
176
|
{
|
177
|
return mNumScrambles;
|
178
|
}
|
179
|
|
180
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
181
|
|
182
|
public int getPrice()
|
183
|
{
|
184
|
return mPrice;
|
185
|
}
|
186
|
|
187
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
188
|
|
189
|
public static TwistyObject create(int ordinal, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream meshStream)
|
190
|
{
|
191
|
/*
|
192
|
if( ordinal==MORP_2.ordinal() )
|
193
|
{
|
194
|
return new TwistyMorphix(objects[ordinal].mInitData,meshState,iconMode,quat,move,scale,meshStream);
|
195
|
}
|
196
|
*/
|
197
|
Class<? extends TwistyObject> clazz = objects[ordinal].mClass;
|
198
|
|
199
|
try
|
200
|
{
|
201
|
Constructor<?>[] cons = clazz.getConstructors();
|
202
|
|
203
|
if( cons.length==1 )
|
204
|
{
|
205
|
InitData data = objects[ordinal].mInitData;
|
206
|
Object[] parameters = new Object[] { data,meshState,iconMode,quat,move,scale,meshStream };
|
207
|
return (TwistyObject)cons[0].newInstance(parameters);
|
208
|
}
|
209
|
else
|
210
|
{
|
211
|
android.util.Log.e("ObjectType", "ERROR! number of TwistyObject constructors="+cons.length);
|
212
|
}
|
213
|
}
|
214
|
catch(IllegalAccessException iae)
|
215
|
{
|
216
|
android.util.Log.e("ObjectType", "Illegal Access Exception: "+iae.getMessage());
|
217
|
}
|
218
|
catch(InstantiationException ie)
|
219
|
{
|
220
|
android.util.Log.e("ObjectType", "Instantiation Exception: "+ie.getMessage());
|
221
|
}
|
222
|
catch(InvocationTargetException ite)
|
223
|
{
|
224
|
android.util.Log.e("ObjectType", "Invocation Target Exception: "+ite.getMessage());
|
225
|
}
|
226
|
|
227
|
return null;
|
228
|
}
|
229
|
}
|