Skip to content

Instantly share code, notes, and snippets.

@Katadeus
Created June 5, 2018 17:10
Show Gist options
  • Save Katadeus/913ce4a9f10854dbdc78de5b9cc85995 to your computer and use it in GitHub Desktop.
Save Katadeus/913ce4a9f10854dbdc78de5b9cc85995 to your computer and use it in GitHub Desktop.
A script I wrote to test how to adaptively set tiles. Super gross.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;
using System.IO;
public class TileMapper : MonoBehaviour {
public tileBit[][] tiles;
public string path = "Assets/TextFiles/ClassicBoard.txt";
public string currLine;
public int width;
public int height;
public Tilemap Top;
public TileBase Blank;
public TileBase DarkSquare;
public TileBase EdgeE1;
public TileBase EdgeE2;
public TileBase EdgeE3;
public TileBase EdgeN1;
public TileBase EdgeN2;
public TileBase EdgeN3;
public TileBase EdgeS1;
public TileBase EdgeS2;
public TileBase EdgeS3;
public TileBase EdgeW1;
public TileBase EdgeW2;
public TileBase EdgeW3;
public TileBase InvNE;
public TileBase InvNW;
public TileBase InvSE;
public TileBase InvSW;
public TileBase LightSquare;
public TileBase NECorner;
public TileBase NWCorner;
public TileBase SECorner;
public TileBase SWCorner;
public TileBase StraightE;
public TileBase StraightN;
public TileBase StraightS;
public TileBase StraightW;
public TileBase UpEnd1;
public TileBase UpEnd2;
public TileBase RightEnd1;
public TileBase RightEnd2;
public TileBase DownEnd1;
public TileBase DownEnd2;
public TileBase LeftEnd1;
public TileBase LeftEnd2;
public class tileBit
{
public char Val;
public int Direction = -1; // Direction not yet known.
public TileBase id; // The id decides which tile to display, and should only be calculated/used once.
// The information necessary to calculate the id:
// - The type
// - The Direction
// - Which sides border on corners
// X and Y values are derived from the list "tiles" and will not be duplicated here unless absolutely necessary.
public int Group = -1;
// Okay, now we need data on the sides that have corners.
// Let's reuse the type guide for that.
public int leftCorner = 0;
public int rightCorner = 0;
public int upCorner = 0;
public int downCorner = 0;
// Types:
// -1: Unassigned/Unworkable
// 0: Vertical Edge
// 1: Horizontal Edge
// 2: Up End
// 3: Right End
// 4: Down End
// 5: Left End
// 6: UpRight Corner
// 7: DownRight Corner
// 8: DownLeft Corner
// 9: UpLeft Corner
// 10: Playable board
public int type = -1;
public tileBit(char v)
{
Val = v;
}
public void print()
{
Debug.Log(Val.ToString()+", "+Group.ToString());
}
public int typeset(int vert, int horiz)
{
int x = -1;
// Debug.Log(vert.ToString() + ", " + horiz.ToString());
int sum = vert + horiz;
char one = '1';
if (Val == one)
{
// Debug.Log("BAAAAAAAAAA");
if(sum > 20)
{
// Debug.Log("SUM: " + sum.ToString());
// Corner or edge or other
switch(sum)
{
case 21:
// UpRight corner
x = 6;
break;
case 22:
// Vertical edge
x = 0;
break;
case 23:
// DownRight corner
x = 7;
break;
case 25:
// UpLeft corner
x = 9;
break;
case 26:
// Horizontal edge
x = 1;
break;
case 27:
// DownLeft corner
x = 8;
break;
}
}
else
{
// Ends
switch(sum)
{
case 10:
// Up End
x = 2;
break;
case 11:
// Right End
x = 3;
break;
case 12:
// Down End
x = 4;
break;
case 15:
// Left End
x = 5;
break;
}
}
// Debug.Log(x);
}
// Debug.Log(x);
return x;
}
}
// When the game first starts, there are several steps that must be taken.
// 1. Create an array of chars representing each letter or number in rows.
// This array must be populated from the text document.
// 2. Find all continuous areas of border represented by "1"s.
// 3. For each continuous area, choose one edge tile and orient the ring
// around this by assigning each adjacent border tile one that matches.
// This will be how we set the Direction variable.
// 4. From the information determined so far, generate the correct tile numbers that should display
// The board squares should be determined by (x+y)%2.
// 5. Set all tiles on the actual tilemap to the correct tile.
// 6. Place pieces
void Start () {
// Do a pre-read to get the size.
StreamReader reader = new StreamReader(path);
int y = 0;
int x = 0;
while ((currLine = reader.ReadLine()) != null) { if(y > 0) { x = currLine.Length; } y++; }
Debug.Log(x);
Debug.Log(y);
Debug.Log("AAAAAA");
tiles = new tileBit[y][];
for (int i=0; i < y; i++)
{
tiles[i] = new tileBit[x];
}
height = y;
width = x;
y = 0;
x = 0;
reader = new StreamReader(path); // reread
while ( (currLine = reader.ReadLine()) != null) // Take in each line and check if it ain't nothin'.
{
foreach (char c in currLine)
{
// Debug.Log(c);
tiles[y][x] = new tileBit(c);
x++;
}
x = 0;
y++;
}
// Okay, so now we have everything organized. All that we have to do is process that information and display it.
// Heh.
// Find all groups of ones.
char one = '1';
char space = ' ';
x = 0;
y = 0;
int currGroupNum = 0;
foreach (tileBit[] line in tiles)
{
foreach (tileBit bit in line)
{
if (bit.Val == one && bit.Group == -1) // If it's the right shit but not in a group yet...
{
currGroupNum++;
// Debug.Log("GroupNum is now " + currGroupNum.ToString());
bit.Group = currGroupNum;
// Debug.Log(bit.Group.ToString());
// print("Tile at [" + x.ToString() + ", " + y.ToString() + "] is a member of group " + currGroupNum.ToString());
GroupHunt(y, x, currGroupNum); // Recursive function to seek out all contiguous available squares.
}
else if (bit.Val != space && bit.Group == -1)
{
Debug.Log("Hello!");
tiles[y][x].type = 10;
}
x++;
}
x = 0;
y++;
// print("New line");
}
// Now there are groups of values 1 through currGroupNum in a grid with the specified width and height.
// Classify each piece.
x = 0;
y = 0;
int newX = 0;
int newY = 0;
int vert = 0;
int horiz = 0;
foreach(tileBit[] line in tiles)
{
foreach(tileBit bit in line)
{
// Code based on GroupHunt function
vert = 0;
horiz = 0;
// Check above
if (y > 0)
{
newY = y - 1;
if (tiles[newY][x].Val == one && tiles[newY][x].Group > 0)
{
vert = vert + 10;
}
}
// Check to the right
if (x < width - 1)
{
newX = x + 1;
// Debug.Log("The width is " + width.ToString() + " and the newX is " + newX.ToString() + ", so this shouldn't bug out. However, the y is currently " + y.ToString() + " for some reason.");
if (tiles[y][newX].Val == one && tiles[y][newX].Group > 0)
{
horiz = horiz + 11;
}
}
// Check below
if (y < height - 1)
{
newY = y + 1;
if (tiles[newY][x].Val == one && tiles[newY][x].Group > 0)
{
vert = vert + 12;
}
}
// Check to the left
if (x > 0)
{
newX = x - 1;
if (tiles[y][newX].Val == one && tiles[y][newX].Group > 0)
{
horiz = horiz + 15;
}
}
// okay, so now we have some information.
if (bit.type == -1)
{ bit.type = bit.typeset(vert, horiz); }// Set the general kind of tile
// Debug.Log(bit.type);
// Nothing more yet - we have to finish this step before moving forward. (imo)
x++;
}
x = 0;
y++;
}
// OKAY SO WE HAVE THE GENERAL TYPES
// NOW LET'S WORK ON GETTING SPECIFIC
// ORIENTATION
// There should be 8 orientations
//
// N
// NW 1 NE
// 8 | 2
// W 7 ->o<- 3 E
// 6 | 4
// SW 5 SE
// S
//
// BEAUTIFUL COMPASS ROSE, RIGHT???? I MADE IT IN 2 MINUTES!!!!!!1
// List form because that's not a very good infographic (but a great philosophical explicator)
//
// DIRECTION INDICES
// 1 North
// 2 North-East
// 3 East
// 4 South-East
// 5 South
// 6 South-West
// 7 West
// 8 North-West
//
// AXIOMS
// 1. When two edges are directly adjacent, their orientations should be equal.
// 2. When an edge is adjacent to a corner, the edge's orientation should be either one above or below the corner's orientation. Whichever is possible.
// 3. When a corner is adjacent to an edge, the corner's orientation should be either one above or below the edge's orientation. Whichever is possible.
// 4. When two opposite corners are adjacent, the new corner's orientation should be identical
// 5. When two non-opposite corners are adjacent, the new corner's orientation should be two more or two less than that of the first.
// 6. When an orientation value exceeds 8, it should be subjected to modulo 8.
// 7. A horizontal edge's orientation may be 1 or 5.
// 8. A vertical edge's orientation may be 3 or 7.
// 9. A corner's orientation may be 2, 4, 6, or 8, but the context of its surroundings will limit it to multiples of four or non-multiples of four.
// 10. When a border's orientation is greater than -1, it should not be changed.
// 11. If a border's orientation cannot be established, it should be set to 0.
//
// That's a pretty good list tbh. Programming this is gonna be easy now.
for (int i = 1; i <= currGroupNum; i++)
{
DistributeDirectionality(i);
}
// okay that looks like a lot less work from here.
// it was pretty hard
// Display loop
x = 0;
y = 0;
foreach (tileBit[] line in tiles)
{
foreach (tileBit bit in line)
{
identify(bit, y, x);
// Debug.Log(bit.id);
Top.SetTile(new Vector3Int(x - width / 2, height / 2 - y, 0), bit.id);
x++;
}
x = 0;
y++;
}
}
// Update is called once per frame
void Update () {
}
void GroupHunt (int y, int x, int GroupNum)
{
print("Tile at [" + x.ToString() + ", " + y.ToString() + "] is a member of group " + GroupNum.ToString());
// tiles[y][x].print();
char one = '1';
int newX;
int newY;
// Check above
if (y > 0)
{
newY = y - 1;
if (tiles[newY][x].Val == one && tiles[newY][x].Group == -1)
{
tiles[newY][x].Group = GroupNum;
GroupHunt(newY, x, GroupNum);
}
}
// Check to the right
if (x < width - 1)
{
newX = x + 1;
if (tiles[y][newX].Val == one && tiles[y][newX].Group == -1)
{
tiles[y][newX].Group = GroupNum;
GroupHunt(y, newX, GroupNum);
}
}
// Check below
if (y < height - 1)
{
newY = y + 1;
if (tiles[newY][x].Val == one && tiles[newY][x].Group == -1)
{
tiles[newY][x].Group = GroupNum;
GroupHunt(newY, x, GroupNum);
}
}
// Check to the left
if (x > 0)
{
newX = x - 1;
if (tiles[y][newX].Val == one && tiles[y][newX].Group == -1)
{
tiles[y][newX].Group = GroupNum;
GroupHunt(y, newX, GroupNum);
}
}
// BUGS FOUND:
// All Found Fixed
}
void DistributeDirectionality(int GroupNum)
{
// What needs to happen here is somewhat simple. The tiles each need to know which way to face. Each border tile category has exactly two possible orientations.
// These orientations do not always radiate perfectly from the center of the board, although they very often do.
// Each border group must be addressed separately, but the whole group should be addressed at once.
// Once one piece of a border is assigned its direction, the rest can be determined from that piece alone.
// The challenge, therefore, lies in selecting the orientation that makes most sense for the seed border orientation.
// One possibility is to reference a corner that lies on the diagonal. However, this does not work for non-square boards.
// Another is to use any piece that is adjacent to the edge of the board, because it is clear that that piece should face inward. However, insulated groups suffer.
// Another is to simply take the first border piece of the group seen by the program and make it face toward the center. This is not perfectly reliable, though.
// A more complex solution would involve having several points around which directions radiate. This works perfectly, but it much more complicated in setup/implementation.
// A hybrid method may make the most sense.
// 1. Iterate through the group and check if any are at the edge of the board.
// If any are at the edge, use one of them as the seed.
// 2. This failing, check if any fall on the diagonal or on the center axis. If so, orient inward along these.
// 3. If none of these work, just take the first one seen and orient it toward the center. For some it'll look nicer if this step orients it away from the center though.
//
// If you are proceeding through sequentially, if the group is a continuous loop, the first thing you encounter will be a DownRight corner.
// If you are proceeding through sequentially, if the group is not continuous, the first thing you encounter can be a down end, a right end, or a DownRight corner.
Debug.Log("Started distributing directionality to Group " + GroupNum);
// HOWEVER, this function cannot be the recursive one because it also needs to go through the whole board several times. There must be a second function.
int y = 0;
int x = 0;
int centerX = width / 2;
int centerY = height / 2;
bool started = false;
foreach(tileBit[] line in tiles)
{
foreach(tileBit bit in line)
{
if(bit.Group == GroupNum && started == false) // If it's a border of the correct group and it's on the edge or on a diagonal.
{
if(bit.type == 4) // Down
{
if(x < centerX)
{ bit.Direction = 5; }
else
{ bit.Direction = 1; }
}
else if(bit.type == 6) // Right
{
if(y < centerY)
{ bit.Direction = 7; }
else
{ bit.Direction = 3; }
}
else // DownRight
{
bit.Direction = 8;
}
started = true;
Debug.Log("Suitable tile found for Group " + GroupNum + ". Starting FloodDir.");
FloodDir(y, x, GroupNum);
}
x++;
}
x = 0;
y++;
}
}
void FloodDir(int y, int x, int GroupNum)
{
// Recurse thyself, away away!
// Establish your own direction
int dir = tiles[y][x].Direction;
// Find thy neighbors
int newX;
int newY;
// Check above
if (y > 0)
{
newY = y - 1;
// Storing corners here guarantees that even the seed edge is accounted for.
tiles[y][x].upCorner = BtI(tiles[newY][x].type >= 6);
// Debug.Log("Above check yields type " + tiles[newY][x].type);
if (tiles[newY][x].Group == GroupNum && tiles[newY][x].Direction == -1)
{
// Do the direction match
tiles[newY][x].Direction = DirMatch(dir, tiles[newY][x].type, false, tiles[y][x].type);
// Debug.Log("Starting a new FloodDir at [" + x + ", " + newY + "].");
FloodDir(newY, x, GroupNum);
}
}
// Check to the right
if (x < width - 1)
{
newX = x + 1;
// Store corner before checking if the group and direction are correct.
tiles[y][x].rightCorner = BtI(tiles[y][newX].type >= 6);
// Debug.Log("Right check yields type " + tiles[y][newX].type);
if (tiles[y][newX].Group == GroupNum && tiles[y][newX].Direction == -1)
{
// Do the direction match
tiles[y][newX].Direction = DirMatch(dir, tiles[y][newX].type, true, tiles[y][x].type);
// Debug.Log("Starting a new FloodDir at [" + newX + ", " + y + "].");
FloodDir(y, newX, GroupNum);
}
}
// Check below
// Debug.Log(y.ToString() + " is less than " + height.ToString() + " - 1");
if (y < height - 1)
{
newY = y + 1;
// Store corner before checking if the group and direction are correct.
tiles[y][x].downCorner = BtI(tiles[newY][x].type >= 6);
// Debug.Log("Below check yields type " + tiles[newY][x].type);
if (tiles[newY][x].Group == GroupNum && tiles[newY][x].Direction == -1)
{
// Do the direction match
tiles[newY][x].Direction = DirMatch(dir, tiles[newY][x].type, false, tiles[y][x].type);
// Debug.Log("Starting a new FloodDir at [" + x + ", " + newY + "].");
FloodDir(newY, x, GroupNum);
}
}
// Check to the left
if (x > 0)
{
newX = x - 1;
// Store corner before checking if the group and direction are correct.
tiles[y][x].leftCorner = BtI(tiles[y][newX].type >= 6);
// Debug.Log("Left check yields type " + tiles[y][newX].type);
if (tiles[y][newX].Group == GroupNum && tiles[y][newX].Direction == -1)
{
// Do the direction match
tiles[y][newX].Direction = DirMatch(dir, tiles[y][newX].type, true, tiles[y][x].type);
// Debug.Log("Starting a new FloodDir at [" + newX + ", " + y + "].");
FloodDir(y, newX, GroupNum);
}
}
// Debug.Log("Corners at [" + x.ToString() + ", " + y.ToString() + "] are [" + tiles[y][x].upCorner.ToString() + ", " + tiles[y][x].rightCorner.ToString() + ", " + tiles[y][x].downCorner.ToString() + ", " + tiles[y][x].leftCorner.ToString() + "].");
}
int DirMatch(int dir, int type, bool axis, int oldType) // AXIS: The way the two pieces are adjacent. If they are vertically adjacent, it is false. If they are horizontally, it is true.
{
switch(type)
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
Debug.Log("Case: " + type.ToString());
if(dir%2 == 1) // Axiom 1
{
Debug.Log("Both are straight segments");
return dir;
}
else
{
Debug.Log("Coming out of a corner of direction " + dir.ToString() + " and type " + oldType.ToString());
// for 0, 2, and 4: possible outcomes are 3 or 7
// for 1, 3, and 5: possible outcomes are 5 or 1
int possible = 1 + ((type % 2) + 1) * 2; // but could also be this + 4, mod 8.
// Debug.Log("Possible is " + possible + " and dir is " + dir);
if (Mathf.Abs(dir - possible) == 1)
{
return possible;
}
else
{
return (possible + 4) % 8;
}
}
break; // Unreachable, but it's a good convention.
case 6: // UpRight
case 7: // DownRight
case 8: // DownLeft
case 9: // UpLeft
// If 6 or 8, 2 or 6
// If 7 or 9, 4 or 8
if (dir%2 == 0) // If they're both corners - Axioms 4 and 5
{ // This problem is the sole reason that axis is passed in as an argument.
Debug.Log("Both Corners");
// The first thing - the easiest thing - is when there is a "stairs" arrangement - direction remains consistent.
// DIR 2 & Type 8 - Return 2
// DIR 4 & Type 9 - Return 4
// DIR 6 & Type 6 - Return 6
// DIR 8 & Type 7 - Return 8
// So DIR/2 yields 1 2 3 4
// Type-5 yields 3 4 1 2
// Type-4 yields 4 5 2 3
// (Type-4)%4 yields 0 1 2 3
// (Type-4)%4+1 yields 1 2 3 4
// ((Type-4)%4+1)*2 yields 2 4 6 8
// if(((type-4)%4+1)*2 == dir) // This isn't happening enough. This condition is not handled properly.
if(Mathf.Abs(oldType-type) == 2)
{
Debug.Log("DOES THIS EVER HAPPEN?");
return dir;
}
// Otherwise we gotta get real dirty.
// 6: UpRight Corner
// 7: DownRight Corner
// 8: DownLeft Corner
// 9: UpLeft Corner
// 2: UPRIGHT DIR DOWNLEFT INV DIR
// 4: DOWNRIGHT DIR UPLEFT INV DIR
// 6: DOWNLEFT DIR UPRIGHT INV DIR
// 8: UPLEFT DIR DOWNRIGHT INV DIR
// This is where the axis comes in.
// POSSIBLE NON-OPPOSED HORIZONTAL CORNER CONNECTIONS:
// UPLEFT - UPRIGHT dir: 8 type: 6 Axis: 1 RETURN: 2
// UPRIGHT - UPLEFT dir: 2 type: 9 Axis: 1 RETURN: 8
// UPLEFT (inv) - UPRIGHT (inv) dir: 4 type: 6 Axis: 1 RETURN: 6
// UPRIGHT (inv) - UPLEFT (inv) dir: 6 type: 9 Axis: 1 RETURN: 4
// DOWNLEFT - DOWNRIGHT dir: 6 type: 7 Axis: 1 RETURN: 4
// DOWNRIGHT - DOWNLEFT dir: 4 type: 8 Axis: 1 RETURN: 6
// DOWNLEFT (inv) - DOWNRIGHT (inv) dir: 2 type: 7 Axis: 1 RETURN: 8
// DOWNRIGHT (inv) - DOWNLEFT (inv) dir: 8 type: 8 Axis: 1 RETURN: 2
// Vertical also has 8 possibilities.
// UPLEFT - DOWNLEFT dir: 8 type: 8 Axis: 0 RETURN: 6
// DOWNLEFT - UPLEFT dir: 6 type: 9 Axis: 0 RETURN: 8
// UPLEFT (inv) - DOWNLEFT (inv) dir: 4 type: 8 Axis: 0 RETURN: 2
// DOWNLEFT (inv) - UPLEFT (inv) dir: 2 type: 9 Axis: 0 RETURN: 4
// UPRIGHT - DOWNRIGHT dir: 2 type: 7 Axis: 0 RETURN: 4
// DOWNRIGHT - UPRIGHT dir: 4 type: 6 Axis: 0 RETURN: 2
// UPRIGHT (inv) - DOWNRIGHT (inv) dir: 6 type: 7 Axis: 0 RETURN: 8
// DOWNRIGHT (inv) - UPRIGHT (inv) dir: 8 type: 6 Axis: 0 RETURN: 6
// Okay, so I need to uninvert the inverted ones
// What does that mean?
// UPLEFT (inv) - UPRIGHT (inv) dir: 8 type: 6 Axis: 1 RETURN:
switch(dir)
{
case 2:
return 4 * (1 + BtI(axis));
break;
case 4:
return (2 + 4 * BtI(axis)) % 8;
break;
case 6:
return 4 * (2 - BtI(axis));
break;
case 8:
return (6 + 4 * BtI(axis)) % 8;
break;
}
// That ended up suitably compact, but exceedingly arcane. Thankfully we have the helpful chart!
// Okay, so now we have all possible corner to corner combinations accounted for, since identical corners cannot connect.
// HOWEVER, WE STILL NEED TO DO EDGE TO CORNER CONNECTIONS
// IDIOT
}
else // If straight into corner
{
// for 6 and 8, possible outcomes are 2 and 6
// for 7 and 9, possible outcomes are 4 and 8
int possible = 2 + (type % 2 * 2); // possibly + 4, no modulo involved.
if(Mathf.Abs(dir - possible) == 1)
{
return possible;
}
else
{
return possible+4;
}
}
break;
}
// If none of these worked out, then just
return 0;
}
int BtI(bool tf)
{
if(tf)
{
return 1;
}
else
{
return 0;
}
}
public void identify(tileBit bit, int y, int x)
{
// Our target
// Debug.Log(bit.type);
switch (bit.type)
{
case -1: // INVALID
bit.id = Blank;
break;
case 0: // BEGIN EDGES
// Vertical
// Debug.Log(bit.Direction);
if(bit.Direction == 7) // Facing East (IDK WHY THIS IS BACKWARDS)
{
// Debug.Log("On this vertical east-facing thing, the bit.downcorner is " + bit.downCorner.ToString() + " and the upcorner is " + bit.upCorner.ToString());
switch (3 * bit.downCorner - 2 * bit.upCorner)
{
case -2:
bit.id = EdgeW2;
break;
case 0:
bit.id = StraightW;
break;
case 1:
bit.id = EdgeW3;
break;
case 3:
bit.id = EdgeW1;
break;
}
}
else // If it's facing west instead
{
// Debug.Log("Really?");
switch (3 * bit.upCorner - 2 * bit.downCorner)
{
case -2:
bit.id = EdgeE2;
break;
case 0:
bit.id = StraightE;
break;
case 1:
bit.id = EdgeE3;
break;
case 3:
bit.id = EdgeE1;
break;
}
}
break;
case 1:
// Horizontal
if (bit.Direction == 5) // Facing North (IDK WHY THIS IS BACKWARDS)
{
switch (3 * bit.leftCorner - 2 * bit.rightCorner)
{
case -2:
bit.id = EdgeS1;
break;
case 0:
bit.id = StraightS;
break;
case 1:
bit.id = EdgeS3;
break;
case 3:
bit.id = EdgeS2;
break;
}
}
else
switch(3 * bit.rightCorner - 2 * bit.leftCorner)
{
case -2:
bit.id = EdgeN1;
break;
case 0:
bit.id = StraightN;
break;
case 1:
bit.id = EdgeN3;
break;
case 3:
bit.id = EdgeN2;
break;
}
break;
case 2: // BEGIN ENDS
if(bit.Direction == 3) // UpEnd
{ bit.id = UpEnd1; }
else
{ bit.id = UpEnd2; }
break;
case 3:
if(bit.Direction == 1) // RightEnd
{ bit.id = RightEnd2; }
else
{ bit.id = RightEnd1; }
break;
case 4:
if(bit.Direction == 5) // DownEnd
{ bit.id = DownEnd1; }
else
{ bit.id = DownEnd2; }
break;
case 5:
if(bit.Direction == 7) // LeftEnd
{ bit.id = LeftEnd2; }
else
{ bit.id = LeftEnd1; }
break;
case 6: // BEGIN CORNERS
if(bit.Direction == 6)
{ bit.id = SWCorner; }
else
{ bit.id = InvNE; }
break;
case 7:
if (bit.Direction == 8)
{ bit.id = NWCorner; }
else
{ bit.id = InvSE; }
break;
case 8:
if (bit.Direction == 2)
{ bit.id = NECorner; }
else
{ bit.id = InvSW; }
break;
case 9:
if (bit.Direction == 4)
{ bit.id = SECorner; }
else
{ bit.id = InvNW; }
break;
case 10: // BEGIN BOARD
// Debug.Log("Does this do?");
if ((x + y)%2 == 0)
{ bit.id = LightSquare; }
else
{ bit.id = DarkSquare; }
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment