示例#1
0
        public void Setup(
            BaseClientComponentLightSource lightSource,
            double flickeringPercents,
            double flickeringChangePercentsPerSecond,
            double updateRatePerSecond = 15)
        {
            if (flickeringPercents <= 0 ||
                flickeringPercents > 100)
            {
                throw new ArgumentException("Flickering percent must be in range (0;100]", nameof(flickeringPercents));
            }

            this.lightSource = lightSource;

            var size = lightSource.Size;

            this.sizeRangeX = new Interval <double>(
                size.X * (1 - flickeringPercents / 100.0),
                size.X);

            this.sizeRangeY = new Interval <double>(
                size.Y * (1 - flickeringPercents / 100.0),
                size.Y);

            this.maxSizeChangePerSecond = (
                size.X * flickeringChangePercentsPerSecond / 100.0,
                size.Y *flickeringChangePercentsPerSecond / 100.0);

            this.updateInterval = 1.0 / updateRatePerSecond;

            this.Randomize();
            this.currentSizeX = this.targetSizeX;
            this.currentSizeY = this.targetSizeY;
            this.Apply(deltaTime: 10000);
        }
        public void Setup(
            IStaticWorldObject worldObject,
            double safeDistance,
            BaseClientComponentLightSource lightSource,
            IComponentSoundEmitter soundEmitter,
            double fromPercents,
            double toPercents,
            double durationSeconds)
        {
            if (fromPercents < 0)
            {
                throw new ArgumentException("fromPercent must be >= 0");
            }

            if (fromPercents >= toPercents)
            {
                throw new ArgumentException("toPercent must be higher than fromPercent");
            }

            if (durationSeconds <= 0)
            {
                throw new Exception("Duration must be > 0");
            }

            this.worldObject     = worldObject;
            this.safeDistance    = safeDistance;
            this.durationSeconds = durationSeconds;
            this.lightSource     = lightSource;
            this.soundEmitter    = soundEmitter;

            var size = lightSource.RenderingSize;

            this.sizeRangeX = new Interval <double>(
                size.X * (fromPercents / 100.0),
                size.X * (toPercents / 100.0));

            this.sizeRangeY = new Interval <double>(
                size.Y * (fromPercents / 100.0),
                size.Y * (toPercents / 100.0));

            this.value = (this.lightSource.RenderingSize.X - this.sizeRangeX.Min)
                         / (this.sizeRangeX.Max - this.sizeRangeX.Min);
            this.isIncreasingValue = true;
            this.Apply(deltaTime: 0);
        }
示例#3
0
        public void Setup(
            BaseClientComponentLightSource lightSource,
            double fromPercents,
            double toPercents,
            double durationSeconds)
        {
            if (fromPercents < 0)
            {
                throw new ArgumentException("fromPercent must be >= 0");
            }

            if (fromPercents >= toPercents)
            {
                throw new ArgumentException("toPercent must be higher than fromPercent");
            }

            if (durationSeconds <= 0)
            {
                throw new Exception("Duration must be > 0");
            }

            this.durationSeconds = durationSeconds;
            this.lightSource     = lightSource;

            var size = lightSource.Size;

            this.sizeRangeX = new Interval <double>(
                size.X * (fromPercents / 100.0),
                size.X * (toPercents / 100.0));

            this.sizeRangeY = new Interval <double>(
                size.Y * (fromPercents / 100.0),
                size.Y * (toPercents / 100.0));

            this.value             = (this.lightSource.Size.X - this.sizeRangeX.Min) / (this.sizeRangeX.Max - this.sizeRangeX.Min);
            this.isIncreasingValue = true;
            this.Apply(deltaTime: 0);
        }
 public static void Unregister(BaseClientComponentLightSource lightSource)
 {
     allLightSources.Remove(lightSource);
 }
 public static void Register(BaseClientComponentLightSource lightSource)
 {
     allLightSources.Add(lightSource);
 }