Exemple #1
0
    void GenerateFogOfWar(GameEvent e)
    {
        if (e.type == GameEvent.GENERATE_FOW)
        {
            Events.instance.RemoveListener <GameEvent>(GenerateFogOfWar);

            _plane          = new CustomPlane(e.width * e.gridSize, e.height * e.gridSize, (e.width * 8 / 512));
            _mesh.vertices  = _plane.getVertices();
            _mesh.triangles = _plane.getTriangles();
            _mesh.uv        = _plane.getUVs();
            _mesh.colors32  = _plane.getColors();

            gameObject.transform.Translate(new Vector3(-_plane.width / 2, 0, -_plane.height / 2));
            MeshCollider collider = gameObject.AddComponent <MeshCollider>();
            collider.sharedMesh = _mesh;

            _lastExploredIndex = new TVec2 <int>(-1, -1);
        }
    }
Exemple #2
0
    // Use this for initialization
    void Start()
    {
        gameObject.AddComponent <MeshFilter>();
        gameObject.AddComponent <MeshRenderer>();
        Mesh mesh = GetComponent <MeshFilter>().mesh;

        mesh.Clear();

        CustomPlane plane = new CustomPlane(512, 512, 16, 200, 0);

        mesh.vertices  = plane.getVertices();
        mesh.triangles = plane.getTriangles();
        mesh.uv        = plane.getUVs();
        mesh.colors32  = plane.getColors();

        Renderer renderer = gameObject.GetComponent <Renderer>();
        Shader   shader   = Shader.Find("Custom/VertexAlphaFow");

        renderer.material = new Material(shader);
    }
Exemple #3
0
    public void GenerateFOW(int width, int height, int gridSize, float yPos)
    {
        _mesh = GetComponent <MeshFilter>().mesh;
        _mesh.Clear();

        _plane             = new CustomPlane(width * gridSize, height * gridSize, gridSize, startAlpha, endAlpha);
        _mesh.vertices     = _plane.getVertices();
        _mesh.triangles    = _plane.getTriangles();
        _mesh.uv           = _plane.getUVs();
        _mesh.colors32     = _plane.getColors();
        transform.position = new Vector3(0.0f, yPos, 0.0f);

//        MeshCollider collider = gameObject.AddComponent<MeshCollider>();
//        collider.sharedMesh = _mesh;

        _lastExploredIndex = new TVec2 <int>(-1, -1);
        this.rayHeight     = yPos * 2;

        canUpdate = true;
    }
    public void GenerateNavFloor(int width, int height, int gridSize)
    {
        _meshFilter = gameObject.AddComponent <MeshFilter>();
        _meshFilter.mesh.Clear();

        CustomPlane plane = new CustomPlane(width, height, gridSize, 255, 0);

        _meshFilter.mesh.vertices  = plane.getVertices();
        _meshFilter.mesh.triangles = plane.getTriangles();
        _meshFilter.mesh.uv        = plane.getUVs();
        _meshFilter.mesh.colors32  = plane.getColors();
        _meshFilter.mesh.RecalculateNormals();

        BoxCollider collider = gameObject.AddComponent <BoxCollider>();

        collider.material.dynamicFriction = 1f;
        collider.material.staticFriction  = 1f;

        gameObject.transform.position = new Vector3(0.0f, 5.0f, 0.0f);
    }