Advertisement
Naitenne

Untitled

Mar 3rd, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.21 KB | None | 0 0
  1. public void UpdateTileShape(int i, int j){
  2.         if(tiles[i, j] == null) return;
  3.         int hNE = 0;
  4.         int hSE = 0;
  5.         int hSW = 0;
  6.         int hNW = 0;
  7.         if(corners[i+1, j+1] != null)
  8.             hNE = (int)(corners[i+1, j+1].transform.position.y / 1.5F);
  9.         if(corners[i+1, j] != null)
  10.             hSE = (int)(corners[i+1, j].transform.position.y / 1.5F);
  11.         if(corners[i, j] != null)
  12.             hSW = (int)(corners[i, j].transform.position.y / 1.5F);
  13.         if(corners[i, j+1] != null)
  14.             hNW = (int)(corners[i, j+1].transform.position.y / 1.5F);
  15.         byte l = 1;
  16.         if(hNE == hNW & hSE == hSW & (hNE - hSE) == 1){ // slope N
  17.             l = 2;
  18.         }else if(hNE == hSE & hSW == hNW & (hNE - hNW) == 1){ // slope E
  19.             l = 3;
  20.         }else if(hNE == hNW & hSE == hSW & (hSE - hNE) == 1){ // slope S
  21.             l = 4;
  22.         }else if(hNE == hSE & hSW == hNW & (hNW - hNE) == 1){ // slope W
  23.             l = 5;
  24.         }else if((hNE - hSE) == 1 & hSE == hNW & (hNE - hSW) == 2){ // rhombe NE
  25.             l = 6;
  26.         }else if((hSE - hSW) == 1 & hSW == hNE & (hSE - hNW) == 2){ // rhombe SE
  27.             l = 7;
  28.         }else if((hSW - hNW) == 1 & hNW == hSE & (hSW - hNE) == 2){ // rhombe SW
  29.             l = 8;
  30.         }else if((hNW - hSW) == 1 & hSW == hNE & (hNW - hSE) == 2){ // rhombe NW
  31.             l = 9;
  32.         }else if((hNE - hSE) == 1 & hSE == hSW & hSW == hNW){ // skew up NE
  33.             l = 10;
  34.         }else if((hSE - hSW) == 1 & hSW == hNW & hNW == hNE){ // skew up SE
  35.             l = 11;
  36.         }else if((hSW - hNW) == 1 & hNW == hNE & hNE == hSE){ // skew up SW
  37.             l = 12;
  38.         }else if((hNW - hNE) == 1 & hNE == hSE & hSE == hSW){ // skew up NW
  39.             l = 13;
  40.         }else if((hNE - hSE) == -1 & hSE == hSW & hSW == hNW){ // skew down NE
  41.             l = 14;
  42.         }else if((hSE - hSW) == -1 & hSW == hNW & hNW == hNE){ // skew down SE
  43.             l = 15;
  44.         }else if((hSW - hNW) == -1 & hNW == hNE & hNE == hSE){ // skew down SW
  45.             l = 16;
  46.         }else if((hNW - hNE) == -1 & hNE == hSE & hSE == hSW){ // skew down NW
  47.             l = 17;
  48.         }else if(hNE == hSW & hSE == hNW & (hNE - hSE) == 1){ // valley NE-SW
  49.             l = 18;
  50.         }else if(hNE == hSW & hSE == hNW & (hSE - hNE) == 1){ // valley NE-SW
  51.             l = 19;
  52.         }
  53.         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);
  54.         tiles[i, j].GetComponent<Tile>().QN.GetComponent<MeshFilter>().mesh
  55.             = tile_shapes[l].GetComponent<Tile>().QN.GetComponent<MeshFilter>().mesh;
  56.         tiles[i, j].GetComponent<Tile>().QE.GetComponent<MeshFilter>().mesh
  57.             = tile_shapes[l].GetComponent<Tile>().QE.GetComponent<MeshFilter>().mesh;
  58.         tiles[i, j].GetComponent<Tile>().QS.GetComponent<MeshFilter>().mesh
  59.             = tile_shapes[l].GetComponent<Tile>().QS.GetComponent<MeshFilter>().mesh;
  60.         tiles[i, j].GetComponent<Tile>().QW.GetComponent<MeshFilter>().mesh
  61.             = tile_shapes[l].GetComponent<Tile>().QW.GetComponent<MeshFilter>().mesh;
  62.         tiles[i, j].GetComponent<Tile>().QN.transform.localPosition = tile_shapes[l].GetComponent<Tile>().QN.transform.localPosition;
  63.         tiles[i, j].GetComponent<Tile>().QE.transform.localPosition = tile_shapes[l].GetComponent<Tile>().QE.transform.localPosition;
  64.         tiles[i, j].GetComponent<Tile>().QS.transform.localPosition = tile_shapes[l].GetComponent<Tile>().QS.transform.localPosition;
  65.         tiles[i, j].GetComponent<Tile>().QW.transform.localPosition = tile_shapes[l].GetComponent<Tile>().QW.transform.localPosition;
  66.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement