Example #1
0
    /// <summary>
    /// set all pixels to correct color
    /// </summary>
    public void updateTex()
    {
        GameTexture newTexture = new GameTexture(WIDTH, HEIGHT);

        newTexture.addTexture(baseTex);


        foreach (Node n in positiveNodes)
        {
            newTexture.addTexture(n.GetGameTexture());
        }

        foreach (Node n in negativeNodes)
        {
            newTexture.subTexture(n.GetGameTexture());
        }

        if (flippedHorizontally)
        {
            newTexture = ShapeModifer.flipImageHorizontally(newTexture);
        }

        if (flippedVertically)
        {
            newTexture = ShapeModifer.flipImageVertically(newTexture);
        }

        if (rotation == 1)
        {
            Texture2D rotated = ShapeModifer.rotate(newTexture.getTex(), true);
            newTexture = new GameTexture(rotated);
        }
        else if (rotation == 2)
        {
            Texture2D rotated = ShapeModifer.rotate(newTexture.getTex(), true);
            rotated    = ShapeModifer.rotate(rotated, true);
            newTexture = new GameTexture(rotated);
        }
        else if (rotation == 3)
        {
            Texture2D rotated = ShapeModifer.rotate(newTexture.getTex(), false);
            newTexture = new GameTexture(rotated);
        }

        mainTexture = newTexture;

        foreach (Node child in children)
        {
            child.updateTex();
        }
    }
Example #2
0
    /// <summary>
    /// Create layer with given shapes and gameColors, is automatically an input layer
    /// precondition: shapes and colors must be equal in length
    /// </summary>
    /// <param name="shapes"></param> textures of black shapes to add to nodes
    /// <param name="colors"></param> colors for each node
    /// <param name="xPosition"></param> x position of layer
    /// <param name="startingY"></param> y postition of top node
    public Layer(Texture2D[] shapes, GameColor[] colors, float xPosition, float startingY, int Layernumber)
    {
        nodes = new Node[shapes.Length];
        for (int i = 0; i < nodes.Length; i++)
        {
            Texture2D modifiedShape = ShapeModifer.changeColor(shapes[i], colors[i]);
            nodes[i] = new Node(modifiedShape);
        }

        x             = xPosition;
        isInputLayer  = true;
        isOutPutLayer = false;

        setUpPostions(startingY);

        number = Layernumber;
    }
Example #3
0
    public void setUpNode()
    {
        if (startingTexture != null)
        {
            if (startingColor != null)
            {
                Texture2D modifiedTex = ShapeModifer.changeColor(startingTexture, new GameColor(startingColor));
                node = new Node(modifiedTex);
            }
            else
            {
                node = new Node(startingTexture);
            }
        }
        else
        {
            node = new Node();
        }

        setUpNodeType();
    }
Example #4
0
    // Start is called before the first frame update
    void Start()
    {
        //GameTexture firstLayer = ShapeModifer.changeColor(new GameTexture(startingTexture), new GameColor(startingColor));
        Texture2D firstLayer = ShapeModifer.changeColor(startingTexture, new GameColor(startingColor));
        //Debug.Log(firstLayer);
        Node thisNode = new Node(firstLayer);

        //thisNode.addTex(new GameTexture(addLayers[0]));


        for (int i = 0; i < addLayers.Length; i++)
        {
            Texture2D   thisTex   = addLayers[i];
            GameColor   thisColor = new GameColor(addColors[i]);
            GameTexture newTex    = new GameTexture(ShapeModifer.changeColor(thisTex, thisColor));
            Node        newNode   = new Node(newTex);

            thisNode.addNode(newNode);
        }

        for (int i = 0; i < subLayers.Length; i++)
        {
            GameTexture thisTex   = new GameTexture(subLayers[i]);
            GameColor   thisColor = new GameColor(subColors[i]);
            GameTexture newTex    = ShapeModifer.changeColor(thisTex, thisColor);
            Node        newNode   = new Node(newTex);
            thisNode.subNode(newNode);
        }


        Texture2D tex = thisNode.GetTexture2D();
        //Texture2D tex = firstLayer.getTex();

        Sprite newSprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.one * 0.5f);

        rend.sprite = newSprite;
    }