Example #1
0
        public static void Mask(Light2D light, LightCollider2D id, LayerSetting layerSetting)
        {
            if (id.InLight(light) == false)
            {
                return;
            }

            int shapeCount = id.shapes.Count;

            for (int i = 0; i < shapeCount; i++)
            {
                LightColliderShape shape = id.shapes[i];

                List <MeshObject> meshObjects = shape.GetMeshes();

                if (meshObjects == null)
                {
                    return;
                }

                Vector2 position = shape.transform2D.position - light.transform2D.position;

                Vector2 pivotPosition = shape.GetPivotPoint() - light.transform2D.position;
                GL.Color(LayerSettingColor.Get(pivotPosition, layerSetting, id.maskEffect, id.maskTranslucency));

                GLExtended.DrawMeshPass(meshObjects, position, shape.transform.lossyScale, shape.transform2D.rotation);
            }
        }
Example #2
0
    private void AddChildShapes(Transform parent)
    {
        foreach (Transform child in parent)
        {
            LightColliderShape shape = new LightColliderShape();
            shape.maskType         = mainShape.maskType;
            shape.maskPivot        = mainShape.maskPivot;
            shape.maskTranslucency = mainShape.maskTranslucency;

            shape.shadowType         = mainShape.shadowType;
            shape.shadowDistance     = mainShape.shadowDistance;
            shape.shadowTranslucency = mainShape.shadowTranslucency;

            shape.SetTransform(child);
            shape.transform2D.Update();

            shapes.Add(shape);

            AddChildShapes(child);
        }
    }
Example #3
0
    public static Color Get(LightColliderShape lightShape, Vector2 position, LayerSetting layerSetting, MaskEffect maskEffect, float maskTranslucency)
    {
        if (maskEffect == MaskEffect.Unlit)
        {
            return(Color.black);
        }

        if (maskEffect == MaskEffect.Isometric)
        {
            Rect rect = lightShape.GetIsoWorldRect();
            if (rect.width < rect.height)
            {
                float x = position.y + position.x / 2;
                return(LayerSettingsColorEffects.GetColor(x, layerSetting));
            }
            else
            {
                float y = position.y - position.x / 2;
                return(LayerSettingsColorEffects.GetColor(y, layerSetting));
            }
        }

        //	return(Color.white);
        if (layerSetting.maskEffect == LightLayerMaskEffect.AboveLit)
        {
            return(LayerSettingsColorEffects.GetColor(position.y, layerSetting));
        }
        else if (layerSetting.maskEffect == LightLayerMaskEffect.NeverLit)
        {
            return(Color.black);
        }
        else
        {
            return(new Color(1, 1, 1, maskTranslucency));
        }
    }