void MakeBoardTexture() { _plane_texture = new LibFever.Plane(0, 0, _textu.width, _textu.height); for (int y = 1; y <= _textu.height; y++) { for (int x = 1; x <= _textu.width; x++) { Point current_case = Grid.getCaseIndex(new LibFever.Grid(_plane_collider, _nb_tiles_largeur, _nb_tiles_hauteur), LibFever.Plane.posPlanInOther(_plane_texture, new Vector2(x, y), _plane_collider)); //Mathf.Floor(Mathf.Abs(textu.width - x) / tile_largeur); bool case_paire_x = ((current_case.x + 1) % 2) == 0; bool case_paire_y = ((current_case.y + 1) % 2) == 0; if (case_paire_x ^ case_paire_y) { _textu.SetPixel(x - 1, y - 1, _couleur_paire); } else { _textu.SetPixel(x - 1, y - 1, _couleur_impaire); } } } _textu.Apply(); byte[] bytes = _textu.EncodeToPNG(); File.WriteAllBytes(Application.dataPath + "/" + "texture_grid.png", bytes); _gride_material.mainTexture = _textu; _spriteRender.material = _gride_material; }
void DrawBoard() { listLinesBoard = new List <LineRenderer>(); GameObject go = GameObject.Instantiate(lineHolder, this.transform); go.transform.position = go.transform.position + new Vector3(0f, 0f, linedistanceFromBoard); LineRenderer line = go.GetComponent <LineRenderer>(); //go.transform.parent = this.transform; line.loop = true; line.startWidth = lineBordureWidth; line.SetVertexCount(4); line.SetPosition(0, Grid.GetPosInWorld(_grille, new Point(0, 0))); line.SetPosition(1, Grid.GetPosInWorld(_grille, new Point(0, _nb_tiles_hauteur - 1))); line.SetPosition(2, Grid.GetPosInWorld(_grille, new Point(_nb_tiles_largeur - 1, _nb_tiles_hauteur - 1))); line.SetPosition(3, Grid.GetPosInWorld(_grille, new Point(_nb_tiles_largeur - 1, 0))); listLinesBoard.Add(line); for (int y = 1; y < _nb_tiles_hauteur; y++) { LineRenderer l = new LineRenderer(); go = GameObject.Instantiate(lineHolder, this.transform); go.transform.position = go.transform.position + new Vector3(0f, 0f, linedistanceFromBoard); line = go.GetComponent <LineRenderer>(); listLinesBoard.Add(line); line.startWidth = lineInsideWidth; line.SetPosition(0, Grid.GetPosInWorld(_grille, new Point(0, y))); line.SetPosition(1, Grid.GetPosInWorld(_grille, new Point(_nb_tiles_largeur - 1, y))); } for (int x = 1; x < _nb_tiles_largeur; x++) { LineRenderer l = new LineRenderer(); go = GameObject.Instantiate(lineHolder, this.transform); go.transform.position = go.transform.position + new Vector3(0f, 0f, linedistanceFromBoard); line = go.GetComponent <LineRenderer>(); line.startWidth = lineInsideWidth; listLinesBoard.Add(line); line.SetPosition(0, Grid.GetPosInWorld(_grille, new Point(x, 0))); line.SetPosition(1, Grid.GetPosInWorld(_grille, new Point(x, _nb_tiles_hauteur - 1))); } }
public void Teleport(Transform tran, Point p, float z) { Vector3 center = Grid.GetPosInWorld(_grille, new Point(p.x, p.y), z); tran.position = center; }