Example #1
0
    // drag mini game
    public void FocusMiniGame(DragGameMiniEvent drag)
    {
#if USE_XLUA
        InvokeXLua("FocusMiniGame", drag);
#else
        List <UILayer> layerTemps = layers[UILayer.Position.Middle].Where(a => a.dragMini != null).ToList();

        if (layerTemps.Count > 0)
        {
            if (drag == null)
            {
                layerMiniMask.SetActive(false);
                foreach (var layer in layerTemps)
                {
                    layer.dragMini.canvasGroup.alpha = 1f; // old is 0.6f
                }
            }
            else
            {
                layerMiniMask.SetActive(true);

                foreach (var layer in layerTemps)
                {
                    layer.dragMini.canvasGroup.alpha = 1f;
                }

                layerTemps = layerTemps.OrderBy(a => a.canvas.sortingOrder).ToList();
                UILayer layerTop     = layerTemps.Last();
                UILayer layerCurrent = layerTemps.FirstOrDefault(a => a.dragMini.Equals(drag));

                if (layerCurrent != null && !layerTop.Equals(layerCurrent))
                {
                    int   order      = layerTop.canvas.sortingOrder;
                    int   layerIndex = layerTop.layerIndex;
                    float distance   = layerTop.canvas.planeDistance;

                    layerTop.layerIndex = layerCurrent.layerIndex;
                    layerTop.SetSortOrder(layerCurrent.canvas.sortingOrder);
                    layerTop.canvas.planeDistance = layerCurrent.canvas.planeDistance;

                    layerCurrent.layerIndex = layerIndex;
                    layerCurrent.SetSortOrder(order);
                    layerCurrent.canvas.planeDistance = distance;
                }
                layers[UILayer.Position.Middle] = layers[UILayer.Position.Middle].OrderBy(a => a.canvas.sortingOrder).ToList();
            }
        }
#endif
    }