| 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 |
ecf3d6e3
|
Leszek Koltunski
|
import org.distorted.library.type.Static3D;
|
| 28 |
29b82486
|
Leszek Koltunski
|
import org.distorted.library.type.Static4D;
|
| 29 |
ad9f5cae
|
Leszek Koltunski
|
|
| 30 |
29b82486
|
Leszek Koltunski
|
import org.distorted.objectlib.R;
|
| 31 |
ad9f5cae
|
Leszek Koltunski
|
import org.distorted.objectlib.objects.*;
|
| 32 |
29b82486
|
Leszek Koltunski
|
|
| 33 |
61aa85e4
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 34 |
|
|
|
| 35 |
8005e762
|
Leszek Koltunski
|
public enum ObjectType
|
| 36 |
29b82486
|
Leszek Koltunski
|
{
|
| 37 |
8592461c
|
Leszek Koltunski
|
CUBE_2 ( 2, 12, R.drawable.s_cube_2, R.drawable.m_cube_2, R.drawable.b_cube_2, R.drawable.h_cube_2),
|
| 38 |
|
|
CUBE_3 ( 3, 17, R.drawable.s_cube_3, R.drawable.m_cube_3, R.drawable.b_cube_3, R.drawable.h_cube_3),
|
| 39 |
|
|
CUBE_4 ( 4, 24, R.drawable.s_cube_4, R.drawable.m_cube_4, R.drawable.b_cube_4, R.drawable.h_cube_4),
|
| 40 |
|
|
CUBE_5 ( 5, 28, R.drawable.s_cube_5, R.drawable.m_cube_5, R.drawable.b_cube_5, R.drawable.h_cube_5),
|
| 41 |
|
|
JING_2 ( 2, 11, R.drawable.s_jing_2, R.drawable.m_jing_2, R.drawable.b_jing_2, R.drawable.h_jing_2),
|
| 42 |
|
|
PYRA_3 ( 3, 10, R.drawable.s_pyra_3, R.drawable.m_pyra_3, R.drawable.b_pyra_3, R.drawable.h_pyra_3),
|
| 43 |
|
|
PYRA_4 ( 4, 17, R.drawable.s_pyra_4, R.drawable.m_pyra_4, R.drawable.b_pyra_4, R.drawable.h_pyra_4),
|
| 44 |
|
|
PYRA_5 ( 5, 23, R.drawable.s_pyra_5, R.drawable.m_pyra_5, R.drawable.b_pyra_5, R.drawable.h_pyra_5),
|
| 45 |
|
|
KILO_3 ( 3, 18, R.drawable.s_kilo_3, R.drawable.m_kilo_3, R.drawable.b_kilo_3, R.drawable.h_kilo_3),
|
| 46 |
|
|
KILO_5 ( 5, 33, R.drawable.s_kilo_5, R.drawable.m_kilo_5, R.drawable.b_kilo_5, R.drawable.h_kilo_5),
|
| 47 |
|
|
MEGA_3 ( 3, 21, R.drawable.s_mega_3, R.drawable.m_mega_3, R.drawable.b_mega_3, R.drawable.h_mega_3),
|
| 48 |
|
|
MEGA_5 ( 5, 37, R.drawable.s_mega_5, R.drawable.m_mega_5, R.drawable.b_mega_5, R.drawable.h_mega_5),
|
| 49 |
|
|
ULTI_2 ( 2, 18, R.drawable.s_ulti_2, R.drawable.m_ulti_2, R.drawable.b_ulti_2, R.drawable.h_ulti_2),
|
| 50 |
|
|
DIAM_2 ( 2, 12, R.drawable.s_diam_2, R.drawable.m_diam_2, R.drawable.b_diam_2, R.drawable.h_diam_2),
|
| 51 |
|
|
DIAM_3 ( 3, 24, R.drawable.s_diam_3, R.drawable.m_diam_3, R.drawable.b_diam_3, R.drawable.h_diam_3),
|
| 52 |
|
|
DIAM_4 ( 4, 32, R.drawable.s_diam_4, R.drawable.m_diam_4, R.drawable.b_diam_4, R.drawable.h_diam_4),
|
| 53 |
|
|
DINO_3 ( 3, 10, R.drawable.s_dino_3, R.drawable.m_dino_3, R.drawable.b_dino_3, R.drawable.h_dino_3),
|
| 54 |
|
|
DIN4_3 ( 3, 7, R.drawable.s_din4_3, R.drawable.m_din4_3, R.drawable.b_din4_3, R.drawable.h_din4_3),
|
| 55 |
|
|
REDI_3 ( 3, 16, R.drawable.s_redi_3, R.drawable.m_redi_3, R.drawable.b_redi_3, R.drawable.h_redi_3),
|
| 56 |
|
|
HELI_3 ( 3, 20, R.drawable.s_heli_3, R.drawable.m_heli_3, R.drawable.b_heli_3, R.drawable.h_heli_3),
|
| 57 |
|
|
SKEW_2 ( 2, 11, R.drawable.s_skew_2, R.drawable.m_skew_2, R.drawable.b_skew_2, R.drawable.h_skew_2),
|
| 58 |
|
|
SKEW_3 ( 3, 21, R.drawable.s_skew_3, R.drawable.m_skew_3, R.drawable.b_skew_3, R.drawable.h_skew_3),
|
| 59 |
|
|
IVY_2 ( 2, 8, R.drawable.s_ivy_2 , R.drawable.m_ivy_2 , R.drawable.b_ivy_2 , R.drawable.h_ivy_2 ),
|
| 60 |
|
|
REX_3 ( 3, 19, R.drawable.s_rex_3 , R.drawable.m_rex_3 , R.drawable.b_rex_3 , R.drawable.h_rex_3 ),
|
| 61 |
|
|
BAN1_3 ( 3, 16, R.drawable.s_ban1_3, R.drawable.m_ban1_3, R.drawable.b_ban1_3, R.drawable.h_ban1_3),
|
| 62 |
|
|
BAN2_3 ( 3, 16, R.drawable.s_ban2_3, R.drawable.m_ban2_3, R.drawable.b_ban2_3, R.drawable.h_ban2_3),
|
| 63 |
|
|
BAN3_3 ( 3, 16, R.drawable.s_ban3_3, R.drawable.m_ban3_3, R.drawable.b_ban3_3, R.drawable.h_ban3_3),
|
| 64 |
|
|
BAN4_3 ( 3, 16, R.drawable.s_ban4_3, R.drawable.m_ban4_3, R.drawable.b_ban4_3, R.drawable.h_ban4_3),
|
| 65 |
|
|
SQU1_3 ( 3, 24, R.drawable.s_squ1_3, R.drawable.m_squ1_3, R.drawable.b_squ1_3, R.drawable.h_squ1_3),
|
| 66 |
|
|
SQU2_3 ( 3, 24, R.drawable.s_squ2_3, R.drawable.m_squ2_3, R.drawable.b_squ2_3, R.drawable.h_squ2_3),
|
| 67 |
|
|
MIRR_2 ( 2, 12, R.drawable.s_mirr_2, R.drawable.m_mirr_2, R.drawable.b_mirr_2, R.drawable.h_mirr_2),
|
| 68 |
|
|
MIRR_3 ( 3, 17, R.drawable.s_mirr_3, R.drawable.m_mirr_3, R.drawable.b_mirr_3, R.drawable.h_mirr_3),
|
| 69 |
29b82486
|
Leszek Koltunski
|
;
|
| 70 |
|
|
|
| 71 |
|
|
public static final int NUM_OBJECTS = values().length;
|
| 72 |
046104f5
|
Leszek Koltunski
|
public static final int MAX_SCRAMBLE,MAX_OBJECT_SIZE;
|
| 73 |
29b82486
|
Leszek Koltunski
|
|
| 74 |
046104f5
|
Leszek Koltunski
|
private final int mSize, mNumScrambles;
|
| 75 |
ad9f5cae
|
Leszek Koltunski
|
private final int mSmallIcon, mMediumIcon, mBigIcon, mHugeIcon;
|
| 76 |
29b82486
|
Leszek Koltunski
|
|
| 77 |
8005e762
|
Leszek Koltunski
|
private static final ObjectType[] objects;
|
| 78 |
29b82486
|
Leszek Koltunski
|
|
| 79 |
|
|
static
|
| 80 |
|
|
{
|
| 81 |
61aa85e4
|
Leszek Koltunski
|
int i = 0;
|
| 82 |
8005e762
|
Leszek Koltunski
|
objects = new ObjectType[NUM_OBJECTS];
|
| 83 |
29b82486
|
Leszek Koltunski
|
int maxScramble= Integer.MIN_VALUE;
|
| 84 |
|
|
int maxSize = Integer.MIN_VALUE;
|
| 85 |
|
|
|
| 86 |
8005e762
|
Leszek Koltunski
|
for(ObjectType object: ObjectType.values())
|
| 87 |
29b82486
|
Leszek Koltunski
|
{
|
| 88 |
61aa85e4
|
Leszek Koltunski
|
objects[i++] = object;
|
| 89 |
|
|
|
| 90 |
|
|
if( object.mNumScrambles> maxScramble ) maxScramble= object.mNumScrambles;
|
| 91 |
|
|
if( object.mSize > maxSize ) maxSize = object.mSize;
|
| 92 |
29b82486
|
Leszek Koltunski
|
}
|
| 93 |
|
|
|
| 94 |
|
|
MAX_SCRAMBLE = maxScramble;
|
| 95 |
|
|
MAX_OBJECT_SIZE = maxSize;
|
| 96 |
|
|
}
|
| 97 |
|
|
|
| 98 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 99 |
|
|
|
| 100 |
8005e762
|
Leszek Koltunski
|
public static ObjectType getObject(int ordinal)
|
| 101 |
29b82486
|
Leszek Koltunski
|
{
|
| 102 |
61aa85e4
|
Leszek Koltunski
|
return ordinal>=0 && ordinal<NUM_OBJECTS ? objects[ordinal] : CUBE_3;
|
| 103 |
29b82486
|
Leszek Koltunski
|
}
|
| 104 |
|
|
|
| 105 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 106 |
|
|
|
| 107 |
61aa85e4
|
Leszek Koltunski
|
public static int getOrdinal(String name)
|
| 108 |
29b82486
|
Leszek Koltunski
|
{
|
| 109 |
|
|
for(int i=0; i<NUM_OBJECTS; i++)
|
| 110 |
|
|
{
|
| 111 |
61aa85e4
|
Leszek Koltunski
|
if( objects[i].name().equals(name) ) return i;
|
| 112 |
29b82486
|
Leszek Koltunski
|
}
|
| 113 |
|
|
|
| 114 |
|
|
return -1;
|
| 115 |
|
|
}
|
| 116 |
|
|
|
| 117 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 118 |
|
|
|
| 119 |
61aa85e4
|
Leszek Koltunski
|
public static int getNumScramble(int ordinal)
|
| 120 |
29b82486
|
Leszek Koltunski
|
{
|
| 121 |
61aa85e4
|
Leszek Koltunski
|
return ordinal>=0 && ordinal<NUM_OBJECTS ? objects[ordinal].mNumScrambles : 0;
|
| 122 |
29b82486
|
Leszek Koltunski
|
}
|
| 123 |
|
|
|
| 124 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 125 |
|
|
|
| 126 |
046104f5
|
Leszek Koltunski
|
ObjectType(int size, int scrambles, int sIcon, int mIcon, int bIcon, int hIcon)
|
| 127 |
29b82486
|
Leszek Koltunski
|
{
|
| 128 |
61aa85e4
|
Leszek Koltunski
|
mSize = size;
|
| 129 |
|
|
mNumScrambles= scrambles;
|
| 130 |
ad9f5cae
|
Leszek Koltunski
|
mSmallIcon = sIcon;
|
| 131 |
|
|
mMediumIcon = mIcon;
|
| 132 |
|
|
mBigIcon = bIcon;
|
| 133 |
|
|
mHugeIcon = hIcon;
|
| 134 |
29b82486
|
Leszek Koltunski
|
}
|
| 135 |
|
|
|
| 136 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 137 |
|
|
|
| 138 |
61aa85e4
|
Leszek Koltunski
|
public int getIconID(int size)
|
| 139 |
29b82486
|
Leszek Koltunski
|
{
|
| 140 |
|
|
switch(size)
|
| 141 |
|
|
{
|
| 142 |
ad9f5cae
|
Leszek Koltunski
|
case 0: return mSmallIcon;
|
| 143 |
|
|
case 1: return mMediumIcon;
|
| 144 |
|
|
case 2: return mBigIcon;
|
| 145 |
|
|
case 3: return mHugeIcon;
|
| 146 |
29b82486
|
Leszek Koltunski
|
}
|
| 147 |
|
|
|
| 148 |
ad9f5cae
|
Leszek Koltunski
|
return mSmallIcon;
|
| 149 |
29b82486
|
Leszek Koltunski
|
}
|
| 150 |
|
|
|
| 151 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 152 |
|
|
|
| 153 |
ecf3d6e3
|
Leszek Koltunski
|
public TwistyObject create(Static4D quat, Static3D move, Resources res, int scrWidth)
|
| 154 |
29b82486
|
Leszek Koltunski
|
{
|
| 155 |
|
|
DistortedTexture texture = new DistortedTexture();
|
| 156 |
|
|
DistortedEffects effects = new DistortedEffects();
|
| 157 |
|
|
MeshSquare mesh = new MeshSquare(20,20); // mesh of the node, not of the cubits
|
| 158 |
|
|
|
| 159 |
ad9f5cae
|
Leszek Koltunski
|
int ord = ordinal();
|
| 160 |
|
|
int size= objects[ord].mSize;
|
| 161 |
|
|
|
| 162 |
|
|
switch(ord)
|
| 163 |
29b82486
|
Leszek Koltunski
|
{
|
| 164 |
ad9f5cae
|
Leszek Koltunski
|
case 0:
|
| 165 |
|
|
case 1:
|
| 166 |
|
|
case 2:
|
| 167 |
ecf3d6e3
|
Leszek Koltunski
|
case 3: return new TwistyCube (size, quat, move, texture, mesh, effects, res, scrWidth);
|
| 168 |
|
|
case 4: return new TwistyJing (size, quat, move, texture, mesh, effects, res, scrWidth);
|
| 169 |
ad9f5cae
|
Leszek Koltunski
|
case 5:
|
| 170 |
|
|
case 6:
|
| 171 |
ecf3d6e3
|
Leszek Koltunski
|
case 7: return new TwistyPyraminx (size, quat, move, texture, mesh, effects, res, scrWidth);
|
| 172 |
ad9f5cae
|
Leszek Koltunski
|
case 8:
|
| 173 |
ecf3d6e3
|
Leszek Koltunski
|
case 9: return new TwistyKilominx (size, quat, move, texture, mesh, effects, res, scrWidth);
|
| 174 |
ad9f5cae
|
Leszek Koltunski
|
case 10:
|
| 175 |
ecf3d6e3
|
Leszek Koltunski
|
case 11: return new TwistyMegaminx (size, quat, move, texture, mesh, effects, res, scrWidth);
|
| 176 |
|
|
case 12: return new TwistyUltimate (size, quat, move, texture, mesh, effects, res, scrWidth);
|
| 177 |
ad9f5cae
|
Leszek Koltunski
|
case 13:
|
| 178 |
|
|
case 14:
|
| 179 |
ecf3d6e3
|
Leszek Koltunski
|
case 15: return new TwistyDiamond (size, quat, move, texture, mesh, effects, res, scrWidth);
|
| 180 |
|
|
case 16: return new TwistyDino6 (size, quat, move, texture, mesh, effects, res, scrWidth);
|
| 181 |
|
|
case 17: return new TwistyDino4 (size, quat, move, texture, mesh, effects, res, scrWidth);
|
| 182 |
|
|
case 18: return new TwistyRedi (size, quat, move, texture, mesh, effects, res, scrWidth);
|
| 183 |
|
|
case 19: return new TwistyHelicopter (size, quat, move, texture, mesh, effects, res, scrWidth);
|
| 184 |
ad9f5cae
|
Leszek Koltunski
|
case 20:
|
| 185 |
ecf3d6e3
|
Leszek Koltunski
|
case 21: return new TwistySkewb (size, quat, move, texture, mesh, effects, res, scrWidth);
|
| 186 |
|
|
case 22: return new TwistyIvy (size, quat, move, texture, mesh, effects, res, scrWidth);
|
| 187 |
|
|
case 23: return new TwistyRex (size, quat, move, texture, mesh, effects, res, scrWidth);
|
| 188 |
|
|
case 24: return new TwistyBandagedFused (size, quat, move, texture, mesh, effects, res, scrWidth);
|
| 189 |
|
|
case 25: return new TwistyBandaged2Bar (size, quat, move, texture, mesh, effects, res, scrWidth);
|
| 190 |
|
|
case 26: return new TwistyBandaged3Plate(size, quat, move, texture, mesh, effects, res, scrWidth);
|
| 191 |
|
|
case 27: return new TwistyBandagedEvil (size, quat, move, texture, mesh, effects, res, scrWidth);
|
| 192 |
|
|
case 28: return new TwistySquare1 (size, quat, move, texture, mesh, effects, res, scrWidth);
|
| 193 |
|
|
case 29: return new TwistySquare2 (size, quat, move, texture, mesh, effects, res, scrWidth);
|
| 194 |
ad9f5cae
|
Leszek Koltunski
|
case 30:
|
| 195 |
ecf3d6e3
|
Leszek Koltunski
|
case 31: return new TwistyMirror (size, quat, move, texture, mesh, effects, res, scrWidth);
|
| 196 |
29b82486
|
Leszek Koltunski
|
}
|
| 197 |
|
|
|
| 198 |
|
|
return null;
|
| 199 |
|
|
}
|
| 200 |
|
|
}
|