示例#1
0
    public SrpgLayer CreateLayer(string layerName, bool touchable = false, int zIndexStart = -1)
    {
        if (zIndexStart < 0)
        {
            // magic number 5!?
            List <SrpgLayer> layers = GetSortedLayers();
            if (layers.Count > 0)
            {
                zIndexStart = layers[0].zIndexStart + _mapHeight + 5;
            }
            else
            {
                zIndexStart = 5;
            }
        }

        GameObject layerObj = new GameObject(layerName);

        layerObj.transform.parent   = transform;
        layerObj.transform.position = Vector3.zero;

        SrpgLayer newLayer = layerObj.AddComponent <SrpgLayer>();

        newLayer.touchable = touchable;
        newLayer.SetZIndex(zIndexStart, _mapHeight);

        return(newLayer);
    }
示例#2
0
    public void ZIndexDown(int layerIndex)
    {
        if (layerIndex >= transform.childCount - 1)
        {
            return;
        }

        List <SrpgLayer> layers      = GetSortedLayers();
        SrpgLayer        destLayer   = layers[layerIndex + 1];
        SrpgLayer        targetLayer = layers[layerIndex];
        int destLayerZIndexStart     = destLayer.zIndexStart;

        destLayer.SetZIndex(targetLayer.zIndexStart, _mapHeight);
        targetLayer.SetZIndex(destLayerZIndexStart, _mapHeight);
        layers[layerIndex + 1] = targetLayer;
        layers[layerIndex]     = destLayer;
    }
示例#3
0
    public void ZIndexUp(int layerIndex)
    {
        if (layerIndex <= 0)
        {
            return;
        }

        List <SrpgLayer> layers      = GetSortedLayers();
        SrpgLayer        destLayer   = layers[layerIndex - 1];
        SrpgLayer        targetLayer = layers[layerIndex];
        int destLayerZIndexStart     = destLayer.zIndexStart;

        destLayer.SetZIndex(targetLayer.zIndexStart, _mapHeight);
        targetLayer.SetZIndex(destLayerZIndexStart, _mapHeight);
        layers[layerIndex - 1] = targetLayer;
        layers[layerIndex]     = destLayer;
    }