Ejemplo n.º 1
0
        /// <summary>
        /// Stamp feature on click began.
        /// </summary>
        private void StampFeatureOnClickBegan()
        {
            SetCursorClickSize();

            GameObject stamp = Instantiate(stampPrefab, Vector3.zero, Quaternion.identity) as GameObject;

            //Set the name of stamp
            stamp.name = "Stamp";

            //Set the parent of stamp
            stamp.transform.SetParent(InstantiateImages.drawArray[ImageOrder.imageSet, InstantiateImages.imageNumber].transform);

            //Set the rotation of the stamp
            stamp.transform.rotation = Quaternion.Euler(new Vector3(0, 0, Random.Range(-15, 15)));

            Vector3 tempPos = GetCurrentPlatformClickPosition(drawCamera);

            tempPos.z = 0;

            ///Set rect transform anchored postion 3d
            stamp.transform.position = tempPos;

            //Increase current sorting order
            Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].currentSortingOrder++;
            if (Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].currentSortingOrder <= Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].lastPartSortingOrder)
            {
                Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].currentSortingOrder = Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].lastPartSortingOrder + 1;
            }

            //Add the element to history
            History.Element element = new History.Element();
            element.transform    = stamp.transform;
            element.type         = History.Element.EType.Object;
            element.sortingOrder = Area.shapesDrawingContents [ShapesManager.instance.lastSelectedShape].currentSortingOrder;
            Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].GetComponent <History> ().AddToPool(element);

            //Get sprite renderer component
            SpriteRenderer sr = stamp.GetComponent <SpriteRenderer>();

            if (sr != null)
            {
                if (currentTool.audioClip != null && AudioSources.instance != null)
                {
                    AudioSources.instance.SFXAudioSource().PlayOneShot(currentTool.audioClip);                    //play Tool audio clip
                }
                //Set the sprite of the stamp
                sr.sprite = currentToolContent.GetComponent <Image> ().sprite;

                //Set the first gradient color key for the samp , if apply color flag in on
                if (currentToolContent.applyColor)
                {
                    sr.color = currentToolContent.gradientColor.colorKeys[0].color;
                }

                //Set the sorting order for the stamp sprite renderer
                sr.sortingOrder = Area.shapesDrawingContents [ShapesManager.instance.lastSelectedShape].currentSortingOrder;
            }
        }
Ejemplo n.º 2
0
        private void StampFeatureOnClickBegan()
        {
            SetCursorClickSize();

            GameObject stamp = Instantiate(stampPrefab, Vector3.zero, Quaternion.identity) as GameObject;

            stamp.name = "Stamp";

            stamp.transform.SetParent(Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].transform);

            stamp.transform.rotation = Quaternion.Euler(new Vector3(0, 0, Random.Range(-15, 15)));

            Vector3 tempPos = GetCurrentPlatformClickPosition(drawCamera);

            tempPos.z = 0;

            stamp.transform.position = tempPos;

            Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].currentSortingOrder++;
            if (Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].currentSortingOrder <= Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].lastPartSortingOrder)
            {
                Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].currentSortingOrder = Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].lastPartSortingOrder + 1;
            }

            History.Element element = new History.Element();
            element.transform    = stamp.transform;
            element.type         = History.Element.EType.Object;
            element.sortingOrder = Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].currentSortingOrder;
            Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].GetComponent <History>().AddToPool(element);

            SpriteRenderer sr = stamp.GetComponent <SpriteRenderer>();

            if (sr != null)
            {
                if (currentTool.audioClip != null)
                {
                    CommonUtil.PlayOneShotClipAt(currentTool.audioClip, Vector3.zero, 1);
                }

                sr.sprite = currentToolContent.GetComponent <Image>().sprite;

                if (currentToolContent.applyColor)
                {
                    sr.color = currentToolContent.gradientColor.colorKeys[0].color;
                }

                sr.sortingOrder = Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].currentSortingOrder;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// fill feature on click began.
        /// </summary>
        private void FillFeatureOnClickBegan()
        {
            SetCursorClickSize();

            RaycastHit2D hit2d = Physics2D.Raycast(GetCurrentPlatformClickPosition(drawCamera), Vector2.zero);

            if (hit2d.collider != null)
            {
                ShapePart shapePart = hit2d.collider.GetComponent <ShapePart>(); //get the ShapePart component
                if (shapePart != null)                                           //Shape Part
                {
                    SpriteRenderer spriteRenderer = hit2d.collider.GetComponent <SpriteRenderer>();
                    if (spriteRenderer != null)
                    {
                        if (currentTool.audioClip != null)
                        {
                            CommonUtil.PlayOneShotClipAt(currentTool.audioClip, Vector3.zero, 1);                          //play Tool audio clip
                        }
                        History.Element lastElement = Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].GetComponent <History> ().GetLastElement();

                        bool equalsLastElement = false;
                        if (lastElement != null)
                        {
                            equalsLastElement = lastElement.transform.GetInstanceID() == shapePart.transform.GetInstanceID();
                        }

                        if (shapePart.targetColor != currentToolContent.gradientColor.colorKeys[0].color || !equalsLastElement)
                        {
                            ///Apply and save the attributes (Color,sortingOrder,lastPartSortingOrder)
                            shapePart.SetColor(currentToolContent.gradientColor.colorKeys[0].color);
                            Area.shapesDrawingContents [ShapesManager.instance.lastSelectedShape].shapePartsColors [hit2d.collider.name] = currentToolContent.gradientColor;
                            spriteRenderer.sortingOrder = Area.shapesDrawingContents [ShapesManager.instance.lastSelectedShape].currentSortingOrder + 1;
                            Area.shapesDrawingContents [ShapesManager.instance.lastSelectedShape].shapePartsSortingOrder [hit2d.collider.name] = spriteRenderer.sortingOrder;
                            Area.shapesDrawingContents [ShapesManager.instance.lastSelectedShape].lastPartSortingOrder = spriteRenderer.sortingOrder;

                            ///Add the element to history
                            History.Element element = new History.Element();
                            element.transform    = hit2d.collider.transform;
                            element.type         = History.Element.EType.Color;
                            element.color        = currentToolContent.gradientColor.colorKeys[0].color;
                            element.sortingOrder = spriteRenderer.sortingOrder;
                            Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].GetComponent <History> ().AddToPool(element);
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private void LineFeatureOnClickBegan()
        {
            CursorZoomOutput.enabled = true;

            SetCursorClickSize();
            GameObject line = Instantiate(linePrefab, Vector3.zero, Quaternion.identity) as GameObject;

            line.transform.SetParent(Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].transform);
            line.name   = "Line";
            currentLine = line.GetComponent <Line>();
            linesCount++;
            Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].currentSortingOrder++;
            if (Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].currentSortingOrder <= Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].lastPartSortingOrder)
            {
                Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].currentSortingOrder = Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].lastPartSortingOrder + 1;
            }
            History.Element element = new History.Element();
            element.transform    = line.transform;
            element.type         = History.Element.EType.Object;
            element.sortingOrder = Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].currentSortingOrder;
            Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].GetComponent <History>().AddToPool(element);
            currentLine.SetSortingOrder(Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].currentSortingOrder);

            if (currentTool.repeatedTexture)
            {
                currentLine.SetMaterial(new Material(Shader.Find("Sprites/Default")));
                currentLine.material.mainTexture        = currentToolContent.sprite.texture;
                currentLine.lineRenderer.numCapVertices = 0;
            }
            else
            {
                currentLine.SetMaterial(currentTool.drawMaterial);
            }
            currentLine.createPaintLines = currentTool.createPaintLines;
            if (currentToolContent != null && currentToolContent.applyColor)
            {
                currentLine.SetColor(currentToolContent.gradientColor);
            }

            if (currentThickness != null)
            {
                currentLine.SetWidth(currentThickness.value * currentTool.lineThicknessFactor, currentThickness.value * currentTool.lineThicknessFactor);
            }
            currentLine.lineRenderer.textureMode = currentTool.lineTextureMode;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Line feature on click began.
        /// </summary>
        private void LineFeatureOnClickBegan()
        {
            //Enable Cursor Zoom Output
            CursorZoomOutput.enabled = true;

            SetCursorClickSize();

            //Create new line gameobject
            GameObject line = Instantiate(linePrefab, Vector3.zero, Quaternion.identity) as GameObject;

            //Set the parent of line
            //line.transform.SetParent(Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].transform);
            line.transform.SetParent(InstantiateImages.drawArray[ImageOrder.imageSet, InstantiateImages.imageNumber].transform);

            //Set the name of the line
            line.name = "Line";

            //Get the Line component
            currentLine = line.GetComponent <Line> ();

            //Increase linesCount by 1
            linesCount++;

            //Increase current sorting order
            Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].currentSortingOrder++;
            if (Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].currentSortingOrder <= Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].lastPartSortingOrder)
            {
                Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].currentSortingOrder = Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].lastPartSortingOrder + 1;
            }

            //Add the element to history
            History.Element element = new History.Element();
            element.transform    = line.transform;
            element.type         = History.Element.EType.Object;
            element.sortingOrder = Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].currentSortingOrder;
            Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].GetComponent <History> ().AddToPool(element);

            //Set the sorting order of the line (last line must be on the top)
            currentLine.SetSortingOrder(Area.shapesDrawingContents[ShapesManager.instance.lastSelectedShape].currentSortingOrder);

            if (currentTool.repeatedTexture)
            {
                //Set the material of the line
                currentLine.SetMaterial(new Material(Shader.Find("Sprites/Default")));
                currentLine.material.mainTexture        = currentToolContent.sprite.texture;
                currentLine.lineRenderer.numCapVertices = 0;
            }
            else
            {
                currentLine.SetMaterial(currentTool.drawMaterial);
            }

            //Set whether to create paint lines
            currentLine.createPaintLines = currentTool.createPaintLines;

            //Set the color of the line, if apply color flag in on
            if (currentToolContent != null && currentToolContent.applyColor)
            {
                currentLine.SetColor(currentToolContent.gradientColor);
            }

            if (currentThickness != null)
            {
                currentLine.SetWidth(currentThickness.value * currentTool.lineThicknessFactor, currentThickness.value * currentTool.lineThicknessFactor);
            }

            //Set the line texture mode
            currentLine.lineRenderer.textureMode = currentTool.lineTextureMode;
        }