Exemplo n.º 1
0
    private void DrawGizmos()
    {
        if (isActiveAndEnabled == false)
        {
            return;
        }

        Gizmos.color = new Color(1f, 0.5f, 0.25f);

        if (mainShape.shadowType != LightCollider2D.ShadowType.None)
        {
            foreach (LightColliderShape shape in shapes)
            {
                List <Polygon2> polygons = shape.GetPolygonsWorld();

                GizmosHelper.DrawPolygons(polygons, transform.position);
            }
        }

        switch (Lighting2D.ProjectSettings.editorView.drawGizmosBounds)
        {
        case EditorGizmosBounds.Rectangle:

            if (maskEffect == MaskEffect.Isometric)
            {
                Gizmos.color = Color.green;
                GizmosHelper.DrawIsoRect(transform.position, mainShape.GetIsoWorldRect());
            }
            else
            {
                Gizmos.color = new Color(0, 1f, 1f);
                GizmosHelper.DrawRect(transform.position, mainShape.GetWorldRect());
            }

            break;
        }

        Vector2?pivotPoint = mainShape.GetPivotPoint();

        if (pivotPoint != null)
        {
            Vector3 pos = transform.position;
            pos.x = pivotPoint.Value.x;
            pos.y = pivotPoint.Value.y;

            Gizmos.DrawIcon(pos, "circle_v2", true);
        }
    }
Exemplo n.º 2
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));
        }
    }