Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private int getSpriteSheetIndex(int x, int y) {
- boolean top = this.borderingTileTypes.contains(Game.activeRegion.getTile(x, y - 1));
- boolean topRight = this.borderingTileTypes.contains(Game.activeRegion.getTile(x + 1, y - 1));
- boolean right = this.borderingTileTypes.contains(Game.activeRegion.getTile(x + 1, y));
- boolean bottomRight = this.borderingTileTypes.contains(Game.activeRegion.getTile(x + 1, y + 1));
- boolean bottom = this.borderingTileTypes.contains(Game.activeRegion.getTile(x, y + 1));
- boolean bottomLeft = this.borderingTileTypes.contains(Game.activeRegion.getTile(x - 1, y + 1));
- boolean left = this.borderingTileTypes.contains(Game.activeRegion.getTile(x - 1, y));
- boolean topLeft = this.borderingTileTypes.contains(Game.activeRegion.getTile(x - 1, y - 1));
- String s;
- /* ==================== AT LEAST ONE SIDE ==================== */
- if (top) {
- if (right) {
- if (bottom) {
- if (left) {
- s = "TRBL";
- }
- else {
- s = "TRB";
- }
- }
- else if (left) {
- s = "TRL";
- }
- else if (bottomLeft) {
- s = "TR3";
- }
- else {
- s = "TR";
- }
- }
- else if (bottom) {
- if (left) {
- s = "TBL";
- }
- else {
- s = "TB";
- }
- }
- else if (left) {
- if (bottomRight) {
- s = "TL2";
- }
- else {
- s = "TL";
- }
- }
- else {
- if (bottomRight) {
- if (bottomLeft) {
- s = "T23";
- }
- else {
- s = "T2";
- }
- }
- else if (bottomLeft) {
- s = "T3";
- }
- else {
- s = "T";
- }
- }
- }
- else if (right) {
- if (bottom) {
- if (left) {
- s = "RBL";
- }
- else if (topLeft) {
- s = "RB4";
- }
- else {
- s = "RB";
- }
- }
- else if (left) {
- s = "RL";
- }
- else if (bottomLeft) {
- if (topLeft) {
- s = "R34";
- }
- else {
- s = "R3";
- }
- }
- else if (topLeft) {
- s = "R4";
- }
- else {
- s = "R";
- }
- }
- else if (bottom) {
- if (left) {
- if (topRight) {
- s = "BL1";
- }
- else {
- s = "BL";
- }
- }
- else if (topRight) {
- if (topLeft) {
- s = "B14";
- }
- else {
- s = "B1";
- }
- }
- else if (topLeft) {
- s = "B4";
- }
- else {
- s = "B";
- }
- }
- else if (left) {
- if (topRight) {
- if (bottomRight) {
- s = "L12";
- }
- else {
- s = "L1";
- }
- }
- else if (bottomRight) {
- s = "L2";
- }
- else {
- s = "L";
- }
- }
- /* ==================== CORNERS ONLY ==================== */
- else if (topRight) {
- if (bottomRight) {
- if (bottomLeft) {
- if (topLeft) {
- s = "1234";
- }
- else {
- s = "123";
- }
- }
- else if (topLeft) {
- s = "124";
- }
- else {
- s = "12";
- }
- }
- else if (bottomLeft) {
- if (topLeft) {
- s = "134";
- }
- else {
- s = "13";
- }
- }
- else if (topLeft) {
- s = "14";
- }
- else {
- s = "1";
- }
- }
- else if (bottomRight) {
- if (bottomLeft) {
- if (topLeft) {
- s = "234";
- }
- else {
- s = "23";
- }
- }
- else if (topLeft) {
- s = "24";
- }
- else {
- s = "2";
- }
- }
- else if (bottomLeft) {
- if (topLeft) {
- s = "34";
- }
- else {
- s = "3";
- }
- }
- else if (topLeft) {
- s = "4";
- }
- /* ==================== NOTHING AT ALL ==================== */
- else {
- s = "_";
- }
- return INDICES.indexOf(s);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement