Exemplo n.º 1
0
 public static Func <int, int> Modulate(Func <int, int> carrier, Func <int, int> cellFunction, int period)
 {
     return(x =>
     {
         var n0 = Floor(carrier, period)(x);
         var n1 = Floor(carrier, period)(x + period);
         return n0 + (n1 - n0) * Periodic(cellFunction, period)(x);
     });
 }
Exemplo n.º 2
0
        /// <summary>
        /// Modulates the specified carrier.
        /// </summary>
        /// <param name="carrier">The carrier.</param>
        /// <param name="cellFunction">The cell function.</param>
        /// <param name="period">The period.</param>
        public static Func <int, int> Modulate(Func <int, int> carrier, Func <int, int> cellFunction, int period)
        {
            return(x =>
            {
                var n0 = Floor(carrier, period)(x);
                var n1 = Floor(carrier, period)(x + period);

                // ReSharper disable once StyleCop.SA1407
                return n0 + ((n1 - n0) * Periodic(cellFunction, period)(x));
            });
        }
Exemplo n.º 3
0
        protected void addPeriodic(InitTable config)
        {
            SoundDescriptor desc = new SoundDescriptor();

            desc.filename  = config.findData <string>("sound");
            desc.is3d      = true;
            desc.isLooping = false;
            desc.priority  = Priority.BACKGROUND_FX;

            Sound snd = new Sound(desc);

            snd.relativePosition = true;

            Periodic pr = new Periodic(this);

            pr.sound = snd;

            Random rand = new Random();

            pr.minPitch = config.findDataOr <float>("pitch.min", 0.8f);
            pr.maxPitch = config.findDataOr <float>("pitch.max", 1.2f);
            pr.minDelay = config.findDataOr <float>("delay.min", 1.0f);
            pr.maxDelay = config.findDataOr <float>("delay.min", 5.0f);
            pr.maxRange = config.findDataOr <Vector3>("maxRange", new Vector3(20, 20, 20));

            pr.nextTime = rand.randomInRange(pr.minDelay, pr.maxDelay);

            myPeriodics.Add(pr);
        }
Exemplo n.º 4
0
        public ResponseModel PutPeriodic([FromRoute] int id, [FromBody] Periodic periodic)
        {
            if (!ModelState.IsValid)
            {
                ResponseModel res = new ResponseModel("Fail", null, "200");
                return(res);
            }

            float    amount     = periodic.Amount_Per;
            string   disciption = periodic.Desciption;
            DateTime date_e     = periodic.date_e;
            DateTime date_s     = periodic.date_s;
            string   id_time    = periodic.id_Time;

            periodic            = _context.Periodic.Where(m => m.Id_Per == id).FirstOrDefault();
            periodic.Amount_Per = amount;
            periodic.Desciption = disciption;
            periodic.date_e     = date_e;
            periodic.date_s     = date_s;
            periodic.id_Time    = id_time;
            periodic.isComeback = false;
            //if (periodic.Id_Wallet == 0)
            //{
            //    periodic.Id_Wallet = 1;
            //}
            //if (periodic.Id_Cate == 0)
            //{
            //    periodic.Id_Cate = 1;
            //}
            //if (periodic.Id_Type == 0)
            //{
            //    periodic.Id_Type = 1;
            //}
            //if (periodic.id_Time == 0)
            //{
            //    periodic.id_Time = 1;
            //}
            try
            {
                _context.Entry(periodic).State = EntityState.Modified;
                _context.SaveChanges();
                ResponseModel res = new ResponseModel("Update success", null, "200");
                return(res);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PeriodicExists(id))
                {
                    ResponseModel res = new ResponseModel("Not found", null, "200");
                    return(res);
                }
                else
                {
                    throw;
                }
            }
        }
Exemplo n.º 5
0
                public IDisposable Run(Periodic parent, TimeSpan dueTime)
                {
                    //
                    // Optimize for the case of Observable.Interval.
                    //
                    if (dueTime == _period)
                    {
                        return(parent._scheduler.SchedulePeriodic(0L, _period, (Func <long, long>)Tick));
                    }

                    return(parent._scheduler.Schedule(default(object), dueTime, InvokeStart));
                }
Exemplo n.º 6
0
 public void Run(Periodic parent, TimeSpan dueTime)
 {
     //
     // Optimize for the case of Observable.Interval.
     //
     if (dueTime == _period)
     {
         SetUpstream(parent._scheduler.SchedulePeriodic(this, _period, @this => @this.Tick()));
     }
     else
     {
         SetUpstream(parent._scheduler.Schedule(this, dueTime, (innerScheduler, @this) => @this.InvokeStart(innerScheduler)));
     }
 }
Exemplo n.º 7
0
 public void Run(Periodic parent, TimeSpan dueTime)
 {
     //
     // Optimize for the case of Observable.Interval.
     //
     if (dueTime == _period)
     {
         SetUpstream(parent._scheduler.SchedulePeriodic(0L, _period, (Func <long, long>)Tick));
     }
     else
     {
         SetUpstream(parent._scheduler.Schedule(default(object), dueTime, InvokeStart));
     }
 }
Exemplo n.º 8
0
            public ICssValue Merge(ICssValue[] values)
            {
                var topLeft     = values[0] as CssTupleValue;
                var topRight    = values[1] as CssTupleValue;
                var bottomRight = values[2] as CssTupleValue;
                var bottomLeft  = values[3] as CssTupleValue;

                if (topLeft != null && topRight != null && bottomRight != null && bottomLeft != null)
                {
                    var horizontal = new Periodic <ICssValue>(new[] { topLeft.Items[0], topRight.Items[0], bottomRight.Items[0], bottomLeft.Items[0] });
                    var vertical   = new Periodic <ICssValue>(new[] { topLeft.Items[1], topRight.Items[1], bottomRight.Items[1], bottomLeft.Items[1] });
                    return(new BorderRadius(horizontal, vertical));
                }

                return(null);
            }
Exemplo n.º 9
0
        /// <summary>
        /// Schedules a periodic piece of work by creating a new thread that goes to sleep when work has been dispatched and wakes up again at the next periodic due time.
        /// </summary>
        /// <typeparam name="TState">The type of the state passed to the scheduled action.</typeparam>
        /// <param name="state">Initial state passed to the action upon the first iteration.</param>
        /// <param name="period">Period for running the work periodically.</param>
        /// <param name="action">Action to be executed, potentially updating the state.</param>
        /// <returns>The disposable object used to cancel the scheduled recurring action (best effort).</returns>
        /// <exception cref="ArgumentNullException"><paramref name="action"/> is null.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="period"/> is less than TimeSpan.Zero.</exception>
        public IDisposable SchedulePeriodic <TState>(TState state, TimeSpan period, Func <TState, TState> action)
        {
            if (period < TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException("period");
            }
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }

            var periodic = new Periodic <TState>(state, period, action);

            var thread = _threadFactory(periodic.Run);

            thread.Start();

            return(periodic);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Schedules a periodic piece of work by creating a new thread that goes to sleep when work has been dispatched and wakes up again at the next periodic due time.
        /// </summary>
        /// <typeparam name="TState">The type of the state passed to the scheduled action.</typeparam>
        /// <param name="state">Initial state passed to the action upon the first iteration.</param>
        /// <param name="period">Period for running the work periodically.</param>
        /// <param name="action">Action to be executed, potentially updating the state.</param>
        /// <returns>The disposable object used to cancel the scheduled recurring action (best effort).</returns>
        /// <exception cref="ArgumentNullException"><paramref name="action"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="period"/> is less than <see cref="TimeSpan.Zero"/>.</exception>
        public IDisposable SchedulePeriodic <TState>(TState state, TimeSpan period, Func <TState, TState> action)
        {
            if (TimeSpan.Zero > period)
            {
                throw new ArgumentOutOfRangeException(nameof(period));
            }

            if (null == action)
            {
                throw new ArgumentNullException(nameof(action));
            }

            var periodic = new Periodic <TState>(state, period, action);
            var thread   = threadFactory(periodic.Run);

            thread.Start();

            return(periodic);
        }
Exemplo n.º 11
0
        public ResponseModel PostPeriodic([FromBody] Periodic periodic)
        {
            if (!ModelState.IsValid)
            {
                ResponseModel res = new ResponseModel("Fail", null, "200");
                return(res);
            }

            periodic.isComeback = false;
            if (periodic != null)
            {
                _context.Periodic.Add(periodic);
                _context.SaveChanges();
                ResponseModel res = new ResponseModel("Create success", null, "200");
                return(res);
            }
            else
            {
                ResponseModel res = new ResponseModel("Create fail", null, "200");
                return(res);
            }
        }
Exemplo n.º 12
0
        public static void SetData(PeriodicData[] data)
        {
            if (data == null)
            {
                return;
            }

            m_Periodic = new Dictionary <ItemTypes, Periodic>();

            try
            {
                for (int i = 0; i < data.Length; i++)
                {
                    //Создать предмет
                    Periodic periodic = new Periodic(data[i].Type, data[i].PopulationMultiplayer);

                    m_Periodic.Add(data[i].Type, periodic);
                }
            }
            catch (System.Exception e)
            {
                UnityEngine.Debug.LogError(e.Message);
            }
        }
Exemplo n.º 13
0
 public IDisposable Run(Periodic parent, DateTimeOffset dueTime)
 {
     return(parent._scheduler.Schedule(default(object), dueTime, InvokeStart));
 }
Exemplo n.º 14
0
 public void Run(Periodic parent, DateTimeOffset dueTime)
 {
     SetUpstream(parent._scheduler.Schedule(this, dueTime, (innerScheduler, @this) => @this.InvokeStart(innerScheduler)));
 }
Exemplo n.º 15
0
 public void Run(Periodic parent, DateTimeOffset dueTime)
 {
     SetUpstream(parent._scheduler.Schedule(default(object), dueTime, InvokeStart));
 }