1 |
29b82486
|
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 |
|
|
package org.distorted.objectlib.main;
|
21 |
|
|
|
22 |
|
|
import android.content.res.Resources;
|
23 |
|
|
|
24 |
|
|
import org.distorted.library.main.DistortedEffects;
|
25 |
|
|
import org.distorted.library.main.DistortedTexture;
|
26 |
|
|
import org.distorted.library.mesh.MeshSquare;
|
27 |
|
|
import org.distorted.library.type.Static4D;
|
28 |
ad9f5cae
|
Leszek Koltunski
|
|
29 |
29b82486
|
Leszek Koltunski
|
import org.distorted.objectlib.R;
|
30 |
ad9f5cae
|
Leszek Koltunski
|
import org.distorted.objectlib.objects.*;
|
31 |
29b82486
|
Leszek Koltunski
|
|
32 |
61aa85e4
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
33 |
|
|
|
34 |
8005e762
|
Leszek Koltunski
|
public enum ObjectType
|
35 |
29b82486
|
Leszek Koltunski
|
{
|
36 |
046104f5
|
Leszek Koltunski
|
CUBE_2 ( 2, 12, R.drawable.small_cube2, R.drawable.medium_cube2, R.drawable.big_cube2, R.drawable.huge_cube2),
|
37 |
|
|
CUBE_3 ( 3, 17, R.drawable.small_cube3, R.drawable.medium_cube3, R.drawable.big_cube3, R.drawable.huge_cube3),
|
38 |
|
|
CUBE_4 ( 4, 24, R.drawable.small_cube4, R.drawable.medium_cube4, R.drawable.big_cube4, R.drawable.huge_cube4),
|
39 |
|
|
CUBE_5 ( 5, 28, R.drawable.small_cube5, R.drawable.medium_cube5, R.drawable.big_cube5, R.drawable.huge_cube5),
|
40 |
|
|
JING_2 ( 2, 11, R.drawable.small_jing2, R.drawable.medium_jing2, R.drawable.big_jing2, R.drawable.huge_jing2),
|
41 |
|
|
PYRA_3 ( 3, 10, R.drawable.small_pyra3, R.drawable.medium_pyra3, R.drawable.big_pyra3, R.drawable.huge_pyra3),
|
42 |
|
|
PYRA_4 ( 4, 17, R.drawable.small_pyra4, R.drawable.medium_pyra4, R.drawable.big_pyra4, R.drawable.huge_pyra4),
|
43 |
|
|
PYRA_5 ( 5, 23, R.drawable.small_pyra5, R.drawable.medium_pyra5, R.drawable.big_pyra5, R.drawable.huge_pyra5),
|
44 |
|
|
KILO_3 ( 3, 18, R.drawable.small_kilo3, R.drawable.medium_kilo3, R.drawable.big_kilo3, R.drawable.huge_kilo3),
|
45 |
|
|
KILO_5 ( 5, 33, R.drawable.small_kilo5, R.drawable.medium_kilo5, R.drawable.big_kilo5, R.drawable.huge_kilo5),
|
46 |
|
|
MEGA_3 ( 3, 21, R.drawable.small_mega3, R.drawable.medium_mega3, R.drawable.big_mega3, R.drawable.huge_mega3),
|
47 |
|
|
MEGA_5 ( 5, 37, R.drawable.small_mega5, R.drawable.medium_mega5, R.drawable.big_mega5, R.drawable.huge_mega5),
|
48 |
|
|
ULTI_2 ( 2, 18, R.drawable.small_ulti , R.drawable.medium_ulti , R.drawable.big_ulti , R.drawable.huge_ulti ),
|
49 |
|
|
DIAM_2 ( 2, 12, R.drawable.small_diam2, R.drawable.medium_diam2, R.drawable.big_diam2, R.drawable.huge_diam2),
|
50 |
|
|
DIAM_3 ( 3, 24, R.drawable.small_diam3, R.drawable.medium_diam3, R.drawable.big_diam3, R.drawable.huge_diam3),
|
51 |
|
|
DIAM_4 ( 4, 32, R.drawable.small_diam4, R.drawable.medium_diam4, R.drawable.big_diam4, R.drawable.huge_diam4),
|
52 |
|
|
DINO_3 ( 3, 10, R.drawable.small_dino , R.drawable.medium_dino , R.drawable.big_dino , R.drawable.huge_dino ),
|
53 |
|
|
DIN4_3 ( 3, 7, R.drawable.small_din4 , R.drawable.medium_din4 , R.drawable.big_din4 , R.drawable.huge_din4 ),
|
54 |
|
|
REDI_3 ( 3, 16, R.drawable.small_redi , R.drawable.medium_redi , R.drawable.big_redi , R.drawable.huge_redi ),
|
55 |
|
|
HELI_3 ( 3, 20, R.drawable.small_heli , R.drawable.medium_heli , R.drawable.big_heli , R.drawable.huge_heli ),
|
56 |
|
|
SKEW_2 ( 2, 11, R.drawable.small_skew2, R.drawable.medium_skew2, R.drawable.big_skew2, R.drawable.huge_skew2),
|
57 |
|
|
SKEW_3 ( 3, 21, R.drawable.small_skew3, R.drawable.medium_skew3, R.drawable.big_skew3, R.drawable.huge_skew3),
|
58 |
|
|
IVY_2 ( 2, 8, R.drawable.small_ivy , R.drawable.medium_ivy , R.drawable.big_ivy , R.drawable.huge_ivy ),
|
59 |
|
|
REX_3 ( 3, 19, R.drawable.small_rex , R.drawable.medium_rex , R.drawable.big_rex , R.drawable.huge_rex ),
|
60 |
|
|
BAN1_3 ( 3, 16, R.drawable.small_ban1 , R.drawable.medium_ban1 , R.drawable.big_ban1 , R.drawable.huge_ban1 ),
|
61 |
|
|
BAN2_3 ( 3, 16, R.drawable.small_ban2 , R.drawable.medium_ban2 , R.drawable.big_ban2 , R.drawable.huge_ban2 ),
|
62 |
|
|
BAN3_3 ( 3, 16, R.drawable.small_ban3 , R.drawable.medium_ban3 , R.drawable.big_ban3 , R.drawable.huge_ban3 ),
|
63 |
|
|
BAN4_3 ( 3, 16, R.drawable.small_ban4 , R.drawable.medium_ban4 , R.drawable.big_ban4 , R.drawable.huge_ban4 ),
|
64 |
|
|
SQU1_3 ( 3, 24, R.drawable.small_squa1, R.drawable.medium_squa1, R.drawable.big_squa1, R.drawable.huge_squa1),
|
65 |
|
|
SQU2_3 ( 3, 24, R.drawable.small_squa2, R.drawable.medium_squa2, R.drawable.big_squa2, R.drawable.huge_squa2),
|
66 |
|
|
MIRR_2 ( 2, 12, R.drawable.small_mirr2, R.drawable.medium_mirr2, R.drawable.big_mirr2, R.drawable.huge_mirr2),
|
67 |
|
|
MIRR_3 ( 3, 17, R.drawable.small_mirr3, R.drawable.medium_mirr3, R.drawable.big_mirr3, R.drawable.huge_mirr3),
|
68 |
29b82486
|
Leszek Koltunski
|
;
|
69 |
|
|
|
70 |
|
|
public static final int NUM_OBJECTS = values().length;
|
71 |
046104f5
|
Leszek Koltunski
|
public static final int MAX_SCRAMBLE,MAX_OBJECT_SIZE;
|
72 |
29b82486
|
Leszek Koltunski
|
|
73 |
046104f5
|
Leszek Koltunski
|
private final int mSize, mNumScrambles;
|
74 |
ad9f5cae
|
Leszek Koltunski
|
private final int mSmallIcon, mMediumIcon, mBigIcon, mHugeIcon;
|
75 |
29b82486
|
Leszek Koltunski
|
|
76 |
8005e762
|
Leszek Koltunski
|
private static final ObjectType[] objects;
|
77 |
29b82486
|
Leszek Koltunski
|
|
78 |
|
|
static
|
79 |
|
|
{
|
80 |
61aa85e4
|
Leszek Koltunski
|
int i = 0;
|
81 |
8005e762
|
Leszek Koltunski
|
objects = new ObjectType[NUM_OBJECTS];
|
82 |
29b82486
|
Leszek Koltunski
|
int maxScramble= Integer.MIN_VALUE;
|
83 |
|
|
int maxSize = Integer.MIN_VALUE;
|
84 |
|
|
|
85 |
8005e762
|
Leszek Koltunski
|
for(ObjectType object: ObjectType.values())
|
86 |
29b82486
|
Leszek Koltunski
|
{
|
87 |
61aa85e4
|
Leszek Koltunski
|
objects[i++] = object;
|
88 |
|
|
|
89 |
|
|
if( object.mNumScrambles> maxScramble ) maxScramble= object.mNumScrambles;
|
90 |
|
|
if( object.mSize > maxSize ) maxSize = object.mSize;
|
91 |
29b82486
|
Leszek Koltunski
|
}
|
92 |
|
|
|
93 |
|
|
MAX_SCRAMBLE = maxScramble;
|
94 |
|
|
MAX_OBJECT_SIZE = maxSize;
|
95 |
|
|
}
|
96 |
|
|
|
97 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
98 |
|
|
|
99 |
8005e762
|
Leszek Koltunski
|
public static ObjectType getObject(int ordinal)
|
100 |
29b82486
|
Leszek Koltunski
|
{
|
101 |
61aa85e4
|
Leszek Koltunski
|
return ordinal>=0 && ordinal<NUM_OBJECTS ? objects[ordinal] : CUBE_3;
|
102 |
29b82486
|
Leszek Koltunski
|
}
|
103 |
|
|
|
104 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
105 |
|
|
|
106 |
61aa85e4
|
Leszek Koltunski
|
public static int getOrdinal(String name)
|
107 |
29b82486
|
Leszek Koltunski
|
{
|
108 |
|
|
for(int i=0; i<NUM_OBJECTS; i++)
|
109 |
|
|
{
|
110 |
61aa85e4
|
Leszek Koltunski
|
if( objects[i].name().equals(name) ) return i;
|
111 |
29b82486
|
Leszek Koltunski
|
}
|
112 |
|
|
|
113 |
|
|
return -1;
|
114 |
|
|
}
|
115 |
|
|
|
116 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
117 |
|
|
|
118 |
61aa85e4
|
Leszek Koltunski
|
public static int getNumScramble(int ordinal)
|
119 |
29b82486
|
Leszek Koltunski
|
{
|
120 |
61aa85e4
|
Leszek Koltunski
|
return ordinal>=0 && ordinal<NUM_OBJECTS ? objects[ordinal].mNumScrambles : 0;
|
121 |
29b82486
|
Leszek Koltunski
|
}
|
122 |
|
|
|
123 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
124 |
|
|
|
125 |
046104f5
|
Leszek Koltunski
|
ObjectType(int size, int scrambles, int sIcon, int mIcon, int bIcon, int hIcon)
|
126 |
29b82486
|
Leszek Koltunski
|
{
|
127 |
61aa85e4
|
Leszek Koltunski
|
mSize = size;
|
128 |
|
|
mNumScrambles= scrambles;
|
129 |
ad9f5cae
|
Leszek Koltunski
|
mSmallIcon = sIcon;
|
130 |
|
|
mMediumIcon = mIcon;
|
131 |
|
|
mBigIcon = bIcon;
|
132 |
|
|
mHugeIcon = hIcon;
|
133 |
29b82486
|
Leszek Koltunski
|
}
|
134 |
|
|
|
135 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
136 |
|
|
|
137 |
61aa85e4
|
Leszek Koltunski
|
public int getIconID(int size)
|
138 |
29b82486
|
Leszek Koltunski
|
{
|
139 |
|
|
switch(size)
|
140 |
|
|
{
|
141 |
ad9f5cae
|
Leszek Koltunski
|
case 0: return mSmallIcon;
|
142 |
|
|
case 1: return mMediumIcon;
|
143 |
|
|
case 2: return mBigIcon;
|
144 |
|
|
case 3: return mHugeIcon;
|
145 |
29b82486
|
Leszek Koltunski
|
}
|
146 |
|
|
|
147 |
ad9f5cae
|
Leszek Koltunski
|
return mSmallIcon;
|
148 |
29b82486
|
Leszek Koltunski
|
}
|
149 |
|
|
|
150 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
151 |
|
|
|
152 |
61aa85e4
|
Leszek Koltunski
|
public TwistyObject create(Static4D quat, int[][] moves, Resources res, int scrWidth)
|
153 |
29b82486
|
Leszek Koltunski
|
{
|
154 |
|
|
DistortedTexture texture = new DistortedTexture();
|
155 |
|
|
DistortedEffects effects = new DistortedEffects();
|
156 |
|
|
MeshSquare mesh = new MeshSquare(20,20); // mesh of the node, not of the cubits
|
157 |
|
|
|
158 |
ad9f5cae
|
Leszek Koltunski
|
int ord = ordinal();
|
159 |
|
|
int size= objects[ord].mSize;
|
160 |
|
|
|
161 |
|
|
switch(ord)
|
162 |
29b82486
|
Leszek Koltunski
|
{
|
163 |
ad9f5cae
|
Leszek Koltunski
|
case 0:
|
164 |
|
|
case 1:
|
165 |
|
|
case 2:
|
166 |
|
|
case 3: return new TwistyCube (size, quat, texture, mesh, effects, moves, res, scrWidth);
|
167 |
|
|
case 4: return new TwistyJing (size, quat, texture, mesh, effects, moves, res, scrWidth);
|
168 |
|
|
case 5:
|
169 |
|
|
case 6:
|
170 |
|
|
case 7: return new TwistyPyraminx (size, quat, texture, mesh, effects, moves, res, scrWidth);
|
171 |
|
|
case 8:
|
172 |
|
|
case 9: return new TwistyKilominx (size, quat, texture, mesh, effects, moves, res, scrWidth);
|
173 |
|
|
case 10:
|
174 |
|
|
case 11: return new TwistyMegaminx (size, quat, texture, mesh, effects, moves, res, scrWidth);
|
175 |
|
|
case 12: return new TwistyUltimate (size, quat, texture, mesh, effects, moves, res, scrWidth);
|
176 |
|
|
case 13:
|
177 |
|
|
case 14:
|
178 |
|
|
case 15: return new TwistyDiamond (size, quat, texture, mesh, effects, moves, res, scrWidth);
|
179 |
|
|
case 16: return new TwistyDino6 (size, quat, texture, mesh, effects, moves, res, scrWidth);
|
180 |
|
|
case 17: return new TwistyDino4 (size, quat, texture, mesh, effects, moves, res, scrWidth);
|
181 |
|
|
case 18: return new TwistyRedi (size, quat, texture, mesh, effects, moves, res, scrWidth);
|
182 |
|
|
case 19: return new TwistyHelicopter (size, quat, texture, mesh, effects, moves, res, scrWidth);
|
183 |
|
|
case 20:
|
184 |
|
|
case 21: return new TwistySkewb (size, quat, texture, mesh, effects, moves, res, scrWidth);
|
185 |
|
|
case 22: return new TwistyIvy (size, quat, texture, mesh, effects, moves, res, scrWidth);
|
186 |
|
|
case 23: return new TwistyRex (size, quat, texture, mesh, effects, moves, res, scrWidth);
|
187 |
|
|
case 24: return new TwistyBandagedFused (size, quat, texture, mesh, effects, moves, res, scrWidth);
|
188 |
|
|
case 25: return new TwistyBandaged2Bar (size, quat, texture, mesh, effects, moves, res, scrWidth);
|
189 |
|
|
case 26: return new TwistyBandaged3Plate(size, quat, texture, mesh, effects, moves, res, scrWidth);
|
190 |
|
|
case 27: return new TwistyBandagedEvil (size, quat, texture, mesh, effects, moves, res, scrWidth);
|
191 |
|
|
case 28: return new TwistySquare1 (size, quat, texture, mesh, effects, moves, res, scrWidth);
|
192 |
|
|
case 29: return new TwistySquare2 (size, quat, texture, mesh, effects, moves, res, scrWidth);
|
193 |
|
|
case 30:
|
194 |
|
|
case 31: return new TwistyMirror (size, quat, texture, mesh, effects, moves, res, scrWidth);
|
195 |
29b82486
|
Leszek Koltunski
|
}
|
196 |
|
|
|
197 |
|
|
return null;
|
198 |
|
|
}
|
199 |
|
|
}
|