Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void UpdateTileShape(int i, int j){
- if(tiles[i, j] == null) return;
- int hNE = 0;
- int hSE = 0;
- int hSW = 0;
- int hNW = 0;
- if(corners[i+1, j+1] != null)
- hNE = (int)(corners[i+1, j+1].transform.position.y / 1.5F);
- if(corners[i+1, j] != null)
- hSE = (int)(corners[i+1, j].transform.position.y / 1.5F);
- if(corners[i, j] != null)
- hSW = (int)(corners[i, j].transform.position.y / 1.5F);
- if(corners[i, j+1] != null)
- hNW = (int)(corners[i, j+1].transform.position.y / 1.5F);
- byte l = 1;
- if(hNE == hNW & hSE == hSW & (hNE - hSE) == 1){ // slope N
- l = 2;
- }else if(hNE == hSE & hSW == hNW & (hNE - hNW) == 1){ // slope E
- l = 3;
- }else if(hNE == hNW & hSE == hSW & (hSE - hNE) == 1){ // slope S
- l = 4;
- }else if(hNE == hSE & hSW == hNW & (hNW - hNE) == 1){ // slope W
- l = 5;
- }else if((hNE - hSE) == 1 & hSE == hNW & (hNE - hSW) == 2){ // rhombe NE
- l = 6;
- }else if((hSE - hSW) == 1 & hSW == hNE & (hSE - hNW) == 2){ // rhombe SE
- l = 7;
- }else if((hSW - hNW) == 1 & hNW == hSE & (hSW - hNE) == 2){ // rhombe SW
- l = 8;
- }else if((hNW - hSW) == 1 & hSW == hNE & (hNW - hSE) == 2){ // rhombe NW
- l = 9;
- }else if((hNE - hSE) == 1 & hSE == hSW & hSW == hNW){ // skew up NE
- l = 10;
- }else if((hSE - hSW) == 1 & hSW == hNW & hNW == hNE){ // skew up SE
- l = 11;
- }else if((hSW - hNW) == 1 & hNW == hNE & hNE == hSE){ // skew up SW
- l = 12;
- }else if((hNW - hNE) == 1 & hNE == hSE & hSE == hSW){ // skew up NW
- l = 13;
- }else if((hNE - hSE) == -1 & hSE == hSW & hSW == hNW){ // skew down NE
- l = 14;
- }else if((hSE - hSW) == -1 & hSW == hNW & hNW == hNE){ // skew down SE
- l = 15;
- }else if((hSW - hNW) == -1 & hNW == hNE & hNE == hSE){ // skew down SW
- l = 16;
- }else if((hNW - hNE) == -1 & hNE == hSE & hSE == hSW){ // skew down NW
- l = 17;
- }else if(hNE == hSW & hSE == hNW & (hNE - hSE) == 1){ // valley NE-SW
- l = 18;
- }else if(hNE == hSW & hSE == hNW & (hSE - hNE) == 1){ // valley NE-SW
- l = 19;
- }
- tiles[i, j].transform.position = new Vector3(i*3+1.5F, Math.Max(Math.Max(hNE, hSE), Math.Max(hSW, hNW))*1.5F, j*3+1.5F);
- tiles[i, j].GetComponent<Tile>().QN.GetComponent<MeshFilter>().mesh
- = tile_shapes[l].GetComponent<Tile>().QN.GetComponent<MeshFilter>().mesh;
- tiles[i, j].GetComponent<Tile>().QE.GetComponent<MeshFilter>().mesh
- = tile_shapes[l].GetComponent<Tile>().QE.GetComponent<MeshFilter>().mesh;
- tiles[i, j].GetComponent<Tile>().QS.GetComponent<MeshFilter>().mesh
- = tile_shapes[l].GetComponent<Tile>().QS.GetComponent<MeshFilter>().mesh;
- tiles[i, j].GetComponent<Tile>().QW.GetComponent<MeshFilter>().mesh
- = tile_shapes[l].GetComponent<Tile>().QW.GetComponent<MeshFilter>().mesh;
- tiles[i, j].GetComponent<Tile>().QN.transform.localPosition = tile_shapes[l].GetComponent<Tile>().QN.transform.localPosition;
- tiles[i, j].GetComponent<Tile>().QE.transform.localPosition = tile_shapes[l].GetComponent<Tile>().QE.transform.localPosition;
- tiles[i, j].GetComponent<Tile>().QS.transform.localPosition = tile_shapes[l].GetComponent<Tile>().QS.transform.localPosition;
- tiles[i, j].GetComponent<Tile>().QW.transform.localPosition = tile_shapes[l].GetComponent<Tile>().QW.transform.localPosition;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement