Пример #1
0
    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;
    }
Пример #2
0
    void InitGrid()
    {
        _plane_collider = new LibFever.Plane(_spriteRender);

        float largeur = _plane_collider.lenght.x;
        float hauteur = _plane_collider.lenght.y;



        _grille = new LibFever.Grid(_plane_collider, _nb_tiles_largeur, _nb_tiles_hauteur);
        Debug.Log("grille exactSeting min " + _grille.plane.min + " max " + _grille.plane.max + "_nb_tiles_hauteur " + _nb_tiles_hauteur + "nb_tiles_largeur" + _nb_tiles_largeur);
    }