Esempio n. 1
0
    void Draw(Map map)
    {
        IList<Room> rooms = map.GetRooms ();
        Texture2D tex = new Texture2D (map.CellCount, map.CellCount, TextureFormat.RGB24, false, true);
        Renderer rend = GetComponent<Renderer> ();
        rend.enabled = true;
        tex.filterMode = FilterMode.Point;
        tex.wrapMode = TextureWrapMode.Clamp;
        tex.DrawFilledRectangle (new Rect (0, 0, map.CellCount, map.CellCount), Color.black);

        /*foreach (Room room in rooms) {
            int height = room.GetHeight();
            int width = room.GetWidth();
            int x = room.GetX();
            int y = room.GetY();

            tex.DrawFilledRectangle (new Rect (x, y, width, height), Color.white);
        }*/

        /*
        foreach (Room room in rooms) {
            Vertex2 c = room.GetCenterPoint();
            float x = (float)scale (c.x);
            float y = (float)scale (c.y);
            tex.DrawFilledRectangle(new Rect(x, y, 3, 3), Color.cyan);
        }

        foreach(Edge e in map.allEdges) {
            //if(!map.edges.Contains(e)) tex.DrawLine(scale((int)e.start.x), scale((int)e.start.y), scale((int)e.end.x), scale((int)e.end.y), Color.blue);
        }
        */
        foreach(Edge e in map.edges) {
            //tex.DrawLine(e.start.x, e.start.y, e.end.x, e.end.y, new Color(0.5f, 0.5f, 0.5f, 0.1f));
        }

        int[,] tiles = map.ptiles;
        int h = tiles.GetLength(0);
        int w = tiles.GetLength (0);

        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                int cell = tiles[h-i-1, w-j-1];
                if(cell == PathGenerator.OPEN_ENDPOINT) {
                    tex.SetPixel(map.CellCount - j, i, Color.green);
                } else if(cell == PathGenerator.BUFFER) {
                    tex.SetPixel(map.CellCount - j, i, Color.red);
                }

            }
        }

        tex.Apply ();
        rend.material.mainTexture = tex;
    }
		void Start()
		{
			_staticRectTexture = new Texture2D( sizeX, sizeY);
			_staticRectTexture.DrawFilledRectangle(new Rect(0,0,_staticRectTexture.width, _staticRectTexture.height), Color.black);

			_newStaticRectTexture = new Texture2D( sizeX, sizeY);
			_staticRectStyle = new GUIStyle();

			onUpdate = new GraphDebugEventManager.GraphDebugEvent (OnUpdate);
			GraphDebugEventManager.UpdateSpectrum += onUpdate;
		}
    void Start()
    {
        Material material = renderer.material;
        Texture2D texture = new Texture2D(512,512, TextureFormat.RGB24, false);
        texture.wrapMode = TextureWrapMode.Clamp;
        material.SetTexture(0, texture);

        texture.DrawFilledRectangle(new Rect(0, 0, 120, 120), Color.green);

        texture.DrawRectangle(new Rect(0, 0, 120, 60), Color.red);

        texture.DrawCircle(256, 256, 100, Color.cyan);
        texture.DrawFilledCircle(256, 256, 50, Color.grey);

        texture.DrawCircle(0, 0, 512, Color.red);

        texture.DrawLine(new Vector2(120, 60), new Vector2(256, 256), Color.black);

        texture.Apply();
    }