Esempio 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;
            }
        }
Esempio 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;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Select the content of the current tool.
        /// </summary>
        /// <param name="content">Content.</param>
        public void SelectToolContent(ToolContent content)
        {
            if (content == null)
            {
                return;
            }

            currentToolContent.DisableSelection();

            currentToolContent = content;
            if (!currentTool.useAsCursor)
            {
                currentCursorSprite = content.GetComponent <Image> ().sprite;
            }

            for (int i = 0; i < currentTool.contents.Count; i++)
            {
                if (currentTool.contents [i] == null)
                {
                    continue;
                }

                if (currentTool.contents [i].name == content.transform.name)
                {
                    Tool.selectedContentIndex = i;

                    foreach (Tool tool in tools)
                    {
                        // if (tool.GetInstanceID() != currentTool.GetInstanceID()) continue;

                        if (tool.contents.Count != 0 && !tool.useAsCursor && (i >= 0 && i < tool.contents.Count))
                        {
                            if (tool.contents [i] != null)
                            {
                                tool.GetComponent <Image> ().sprite = tool.contents [i].GetComponent <Image> ().sprite;
                            }
                        }
                    }
                    break;
                }
            }

            SetShapeOrderColor();
            ChangeThicknessSizeColor();
            content.EnableSelection();
        }