예제 #1
0
        public Color Calc(Color baseColor, IsoLightReciver _reciver)
        {
            if (!bOnOff || color == null)
            {
                return(baseColor);
            }

            float fLength = 0;

            if (bSimpleShadow)
            {
                Bounds  _bounds     = _reciver.Sprr.bounds;
                Vector3 topOfTarget = _bounds.center + Vector3.up * _bounds.extents.y;
                fLength = Vector3.Distance(transform.position, topOfTarget);
                var hits = Physics.RaycastAll(topOfTarget, transform.position - topOfTarget, fLength, -1, QueryTriggerInteraction.Collide);
                if (!hits.All(r => _reciver.transform.IsChildOf(r.transform) || r.transform.IsChildOf(transform.root)))
                {
                    return(ShadowColor);
                }
            }

            Vector3 position = _reciver.GetPositionWidthoutOffset() - transform.position;

            position.Scale(AxisWeightForDistance);
            fLength = position.magnitude;
            if (!bAffectOverRange && fLength > colorCurveRange.y)
            {
                return(baseColor);
            }

            float fClampedLength = Mathf.Clamp01(Mathf.InverseLerp(colorCurveRange.x, colorCurveRange.y, fLength));
            Color lightColor     = color.Evaluate(colorCurve.Evaluate(fClampedLength));
            float fLightAlpha    = lightColor.a;

            switch (type)
            {
            case ApplyType.Positive:
                baseColor = ClampedRGB(baseColor + fLightAlpha * lightColor);
                break;

            case ApplyType.Negative:
                baseColor = ClampedRGB(baseColor - fLightAlpha * lightColor);
                break;

            case ApplyType.Override:
                baseColor = lightColor;
                break;

            case ApplyType.Overlay:
                baseColor = ClampedRGB((1 - fLightAlpha) * baseColor + fLightAlpha * lightColor);
                break;

            case ApplyType.Multiply:
            default:
                baseColor *= lightColor;
                break;
            }
            baseColor.a = 1;
            return(baseColor);
        }
예제 #2
0
 public void AddTarget(IsoLightReciver reciver)
 {
     if (!targetList.Contains(reciver))
     {
         targetList.Add(reciver);
     }
 }
예제 #3
0
        private IsoLightReciver AddReciverToIso2D(Iso2DBase x)
        {
            IsoLightReciver r = x.gameObject.GetComponent <IsoLightReciver>();

            if (r == null)
            {
                r = x.gameObject.AddComponent <IsoLightReciver>();
                r.Init();
            }
            return(r);
        }
예제 #4
0
        public static IsoLightReciver SetIsoLightReciver(this GameObject obj, IsoLight light)
        {
            IsoLightReciver reciver = obj.GetComponent <IsoLightReciver>();

            if (reciver == null)
            {
                reciver = obj.AddComponent <IsoLightReciver>();
                reciver.Init();
            }
            reciver.AddLight(light);
            return(reciver);
        }
예제 #5
0
 public void RemoveReciver(IsoLightReciver reciver)
 {
     targetList.Remove(reciver);
 }