Esempio n. 1
0
 public static Color[] CreateBaseImage(int imageWidth, int imageHeight, ImageType baseIMageType)
 {
     Color[] array = new Color[imageWidth * imageHeight];
     for (int i = 0; i < imageWidth; i++)
     {
         for (int j = 0; j < imageHeight; j++)
         {
             int num = j * imageWidth + i;
             if (CommonConfiguration.IsShowPoint(imageWidth, imageHeight, i, j, baseIMageType))
             {
                 array[num] = new Color(0f, 0f, 0f, 1f);
             }
             else
             {
                 array[num] = new Color(0f, 0f, 0f, 0f);
             }
         }
     }
     return(array);
 }
Esempio n. 2
0
    private void SelectDragImage()
    {
#if UNITY_EDITOR
        if (Input.GetKeyDown(KeyCode.Mouse0))
#else
        if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
#endif
        {
            Vector2 one = Vector2.one;
            Profiler.BeginSample("RectTransformUtility");
            RectTransformUtility.ScreenPointToLocalPointInRectangle(this.Operational_Figure, Input.mousePosition, this.canvas.worldCamera, out one);
            List <ImageControl> list  = new List <ImageControl>();
            List <ImageControl> list2 = new List <ImageControl>();
            Profiler.EndSample();
            Profiler.BeginSample("--------------------1");
            foreach (ImageControl current in this.Operational_Figure_Control.imageList)
            {
                if (one.x > current.transform.localPosition.x - (float)current.halfWidth && one.x < current.transform.localPosition.x + (float)current.halfWidth && one.y > current.transform.localPosition.y - (float)current.halfHeight && one.y < current.transform.localPosition.y + (float)current.halfHeight)
                {
                    int x = (int)((float)current.halfWidth - (current.transform.localPosition.x - one.x));
                    int y = (int)((float)current.halfHeight - (current.transform.localPosition.y - one.y));
                    if (CommonConfiguration.IsShowPoint(current.showImageTexture.width, current.showImageTexture.height, x, y, CommonConfiguration.baseImages[current.imageIndex].baseImageType))
                    {
                        list.Add(current);
                    }
                    else
                    {
                        list2.Add(current);
                    }
                }
            }
            Profiler.EndSample();
            List <ImageControl> list3 /*= new List<ImageControl>()*/;
            if (list.Count != 0)
            {
                list3 = list;
            }
            else
            {
                list3 = list2;
            }
            ImageControl imageControl = null;
            int          num          = -2147483648;
            Profiler.BeginSample("--------------------2");
            foreach (ImageControl current2 in list3)
            {
                if (current2.transform.GetSiblingIndex() > num)
                {
                    num          = current2.transform.GetSiblingIndex();
                    imageControl = current2;
                }
            }
            Profiler.EndSample();
            Profiler.BeginSample("--------------------3");
            if (imageControl != null)
            {
                this.currentSelectImage = imageControl;
                imageControl.OnPointerDown();
            }
            Profiler.EndSample();
        }

#if UNITY_EDITOR
        if (Input.GetKeyUp(KeyCode.Mouse0) && this.currentSelectImage != null)
#else
        if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended && this.currentSelectImage != null)
#endif
        {
            FSoundManager.PlaySound("drop");
            this.currentSelectImage.OnDragEnd();
            this.currentSelectImage = null;
        }
#if UNITY_EDITOR
        if (true)
#else
        if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved)
#endif
        {
            if (this.currentSelectImage != null)
            {
                Profiler.BeginSample("-----------drag---------");
#if UNITY_EDITOR
                this.currentSelectImage.OnDragIng(Input.mousePosition);
#else
                this.currentSelectImage.OnDragIng(Input.GetTouch(0).position);
#endif
                Profiler.EndSample();
            }
        }
    }