Example #1
0
 public ThreadedAntiFlood(TickTime Start, long Interval, TickTime.Unit Unit)
 {
     this.Start    = Start;
     this.Interval = Interval;
     this.Unit     = Unit;
     locker        = new object();
 }
Example #2
0
        /// <summary>
        /// Waits for timeout
        /// </summary>
        /// <param name="start"></param>
        /// <param name="timeout"></param>
        /// <param name="unit"></param>
        /// <param name="intensity"></param>
        public static void Sleep(TickTime start, long timeout, TickTime.Unit timeoutUnit = TickTime.Unit.ms)
        {
            if (timeoutUnit < TickTime.Unit.ms)
            {
                throw new Exception("timeoutUnit is to small, must be greater or equal to ms");
            }

            long end = start.Ticks + ((long)timeoutUnit * timeout);
            long now = TickTime.NowTicks;


            if (end <= now)
            {
                return;
            }

            /*while (end > now)
             * {
             *  Thread.Sleep(1);
             *  now = TickTime.NowTicks;
             * }*/

            long wait  = end - now;
            int  sleep = (int)(wait / (long)TickTime.Unit.ms);

            if (sleep <= 0)
            {
                return;
            }

            Thread.Sleep(sleep);
        }
Example #3
0
        public void Synchronize()
        {
            bool done = false;

            while (!done)
            {
                if (Monitor.TryEnter(locker))
                {
                    try
                    {
                        long constant = ((long)this.Unit * this.Interval);
                        long end      = this.Start.Ticks + constant;

                        while (end > TickTime.NowTicks)
                        {
                            int speep = AMath.Random(1, 11);
                            Thread.Sleep(speep);
                            end = this.Start.Ticks + constant;
                        }

                        this.Start = TickTime.Now;
                    }
                    finally
                    {
                        Monitor.Exit(locker);
                        done = true;
                    }
                }
                else
                {
                    done = false;
                    Thread.Sleep(100);
                }
            }
        }
Example #4
0
        /// <summary>
        /// @"Token\Pair\BID\OFFER\HIGH\LOW\STATUS\NOTATION\DECIMALS\CLOSINGBID", @"\");
        /// </summary>
        /// <param name="data"></param>
        /// <param name="dateTimeFormat"></param>
        /// <returns></returns>
        public Rate ToRateOnConnect(string data, ref TickTime origin)
        {
            if (System.String.IsNullOrEmpty(data) || data.Length < 10)
            {
                return(null);
            }

            //Ignore token, might be corrupted
            string[] properties = Asmodat.Abbreviate.String.ToList(data, "\\");
            if (properties.Length != 10)
            {
                return(null);
            }


            string status   = properties[6];
            string notation = properties[7];

            if (status != "D" && status != "R")
            {
                return(null);
            }

            if (notation != "E" && notation != "A")
            {
                return(null);
            }

            Rate rate = new Rate();

            try
            {
                rate.Pair       = properties[1];
                rate.DECIMALS   = ForexConfiguration.GetDecimals(rate.Pair);
                rate.BID        = Doubles.Parse(properties[2], rate.DECIMALS);
                rate.OFFER      = Doubles.Parse(properties[3], rate.DECIMALS);
                rate.HIGH       = Doubles.Parse(properties[4], rate.DECIMALS);
                rate.LOW        = Doubles.Parse(properties[5], rate.DECIMALS);
                rate.STATUS     = status;
                rate.NOTATION   = notation;
                rate.CLOSINGBID = Doubles.Parse(properties[8], rate.DECIMALS);

                rate.ChartData.TickTime = (origin += 1);


                //backtest
                double pchange = RateInfo.ChangePercentage(rate.BID, rate.OFFER, rate.HIGH, rate.LOW);
                if (pchange < 25)
                {
                    return(null);
                }
            }
            catch (Exception e)
            {
                Exceptions.Add(e);
                return(null);
            }

            return(rate);
        }
Example #5
0
    public StatusEffect(StatusEffectScriptableObject data, TickTime tickTime, int duration)
    {
        this.data = ScriptableObject.Instantiate <StatusEffectScriptableObject>(data);

        this.tickTime     = tickTime;
        durationRemaining = duration;
    }
Example #6
0
 public void Update(TickTime tickTime)
 {
     lock (Factory.GameObjectsLock)
     {
         Parallel.ForEach(Factory.GameObjects, gameobject => gameobject.Update(tickTime));
     }
     CurrentState.Update(tickTime);
 }
Example #7
0
 public void Update(TickTime delta)
 {
     //_position += Velocity * delta.GameTimeDelta.TotalSeconds;
     Transformation = Mat4.Translate(_position) * new Euler(Angle.FromDegrees(45),0,0).ToQuat().ToMat4();
     //Console.WriteLine(Transformation);
     //Transformation *= Mat4.RotateX(Angle.FromDegrees(.5));
     //Transformation *= Mat4.RotateY(Angle.FromDegrees(.5));
     //Transformation *= Mat4.RotateZ(Angle.FromDegrees(.5));
 }
Example #8
0
        public void WaitForResponse(int timeout, TickTime.Unit unit = TickTime.Unit.ms)
        {
            TickTime start = TickTime.Now;

            while (!TickTime.Timeout(start, timeout, unit) && !Compleated)
            {
                Thread.Sleep(100);
            }
        }
Example #9
0
 public TradeEntry(object[] entry)
 {
     this.Price         = decimal.Parse((string)entry[0]);
     this.Volume        = decimal.Parse((string)entry[1]);
     this.Ticks         = TickTime.FromUnixTimeStamp(double.Parse(entry[2].ToString()));
     this.buy_sell      = (string)entry[3];
     this.market_limit  = (string)entry[4];
     this.miscellaneous = (string)entry[5];
 }
Example #10
0
 public void Update(TickTime tickTime)
 {
     if (Parent != null)
     {
         //Velocity = Velocity + (Acceleration * tickTime.GameTimeDelta.TotalSeconds);
         this.Rotation  = this._rotation * (this.RotationalVelocity * tickTime.GameTimeDelta.TotalSeconds);
         this._position = this._position + (this.Velocity * tickTime.GameTimeDelta.TotalSeconds);
     }
 }
        //TODO: NOT TESTED

        /// <summary>
        /// View your past trades.
        /// </summary>
        /// <param name="symbol">The pair traded (BTCUSD, LTCUSD, LTCBTC).</param>
        /// <param name="timestamp">Trades made before this timestamp won't be returned.</param>
        /// <param name="until">Optional. Trades made after this timestamp won't be returned.</param>
        /// <param name="limit_trades">Optional. Limit the number of trades returned. Default is 50.</param>
        /// <param name="reverse">Optional. Return trades in reverse order (the oldest comes first). Default is returning newest trades first.</param>
        /// <returns>An array of trades:</returns>
        public ObjPastTrades[] GetPastTrades(ApiProperties.Symbols symbol, TickTime timestamp, TickTime until, int limit_trades, int reverse)
        {
            return(GetPastTrades(
                       symbol.GetEnumName(),
                       timestamp.ToUnixTimeStamp(),
                       until.ToUnixTimeStamp(),
                       limit_trades,
                       reverse
                       ));
        }
 //TODO: NOT TESTED
 /// <summary>
 /// View all of your balance ledger entries.
 /// </summary>
 /// <param name="currency">The currency to look for.</param>
 /// <param name="since">Optional. Return only the history after this timestamp.</param>
 /// <param name="until">Optional. Return only the history before this timestamp.</param>
 /// <param name="limit">Optional. Limit the number of entries to return. Default is 500.</param>
 /// <param name="wallet">Optional. Return only entries that took place in this wallet. Accepted inputs are: "trading", "exchange", "deposit".</param>
 /// <returns></returns>
 public ObjBalanceHistory GetBalanceHistory(ApiProperties.Currency currency, TickTime since, TickTime until, int limit, ApiProperties.WalletName wallet)
 {
     return(GetBalanceHistory(
                currency.GetEnumName(),
                since.ToUnixTimeStamp(),
                until.ToUnixTimeStamp(),
                limit,
                wallet.GetEnumName()
                ));
 }
        private void dispatcherTimer_Tick(object sender, EventArgs e)
        {
            var vm = ViewModel as SecondViewModel;

            vm?.GetData();


            //Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
            //Int32 unixTickTimestamp = (Int32)(TickTime.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;

            double result        = TickTime.Subtract(DateTime.UtcNow).TotalSeconds;
            double percentResult = result / int.Parse(secText.Text);

            pbStatus.Value = 100 - (percentResult * 100);


            if (DateTime.UtcNow >= TickTime)
            {
                DispatcherTimer.Stop();
                timercontrol.IsEnabled = true;
                slValue.IsEnabled      = true;
                secText.IsEnabled      = true;
                seriesCheck.IsEnabled  = true;



                ExportToExcel exportToExcel = new ExportToExcel();
                bool          outResult;
                exportToExcel.ExportData(vm?.RootRefObjects, seriesChecklist, out outResult);

                if (outResult)
                {
                    StopExport.IsEnabled   = false;
                    Export.IsEnabled       = true;
                    secText.IsEnabled      = true;
                    timercontrol.IsEnabled = true;
                    seriesCheck.IsEnabled  = true;
                    progressArea.IsEnabled = false;
                    pbStatus.Value         = 0;
                    MessageBox.Show("Success!!! Please check your Drive C");
                }
                else
                {
                    MessageBox.Show("Something went wrong! Please check your Microsoft Office installed?");
                    StopExport.IsEnabled   = false;
                    Export.IsEnabled       = true;
                    timercontrol.IsEnabled = true;
                    secText.IsEnabled      = true;
                    seriesCheck.IsEnabled  = true;
                    progressArea.IsEnabled = false;
                    pbStatus.Value         = 0;
                }
            }
        }
Example #14
0
 /// <summary>
 /// Determines if
 /// </summary>
 /// <param name="DTKey"></param>
 /// <returns></returns>
 public bool IsValid(TickTime DTKey)
 {
     if (DTKey == TickTime.Default)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Example #15
0
        /// <summary>
        /// This is synchronised TCP Recive method, received data will be only written into buffer if received bytes contains End Of Message string.
        /// </summary>
        /// <param name="iTimeout">Determines, how long in [ms] method can be executed, if iTimeout is lower then 0, method will not be terminated. </param>
        private void Receive(int timeout = -1)
        {
            DateTime DTStart    = DateTime.Now;
            TickTime TTStart    = TickTime.Now;
            bool     bTimeout   = false;
            bool     bDataFound = false;

            byte[] baData;

            string sData           = sDataBuffer;
            string sMessage        = null;
            string sMessageResidue = null;
            int    iRecivedCount;

            while (!bTimeout && !bDataFound)
            {
                if (timeout > 0 && TickTime.Timeout(TTStart, timeout, TickTime.Unit.ms))
                {
                    bTimeout = true;
                }

                baData        = new byte[1024];
                iRecivedCount = SLClient.Receive(baData);
                sData        += Encoding.ASCII.GetString(baData, 0, iRecivedCount);


                sMessage = sData.ExtractTag(TcpAsyncCommon.SOM, TcpAsyncCommon.EOM, out sMessageResidue);

                if (sMessage == null)
                {
                    continue;
                }
                else
                {
                    bDataFound = true;
                }
            }

            if (!bDataFound)
            {
                sDataBuffer = sData;
                return;
            }

            sDataBuffer = sMessageResidue;
            sData       = sMessage;

            //sData.Replace(TcpAsyncClient.SOM, "");
            //sData.Replace(TcpAsyncClient.EOM, "");
            sData.Replace(@"\\", @"\");

            DBReceive.Set(sData);
        }
Example #16
0
        private void DecodeData()
        {
            TickTime TimeOrigin = Data.FirstKey;
            string   data       = Data[TimeOrigin];

            Data.Remove(TimeOrigin); //Remove data after reading

            string[] Packets = Asmodat.Abbreviate.String.ToList(data, "\r");


            if (Packets == null || Packets.Length <= 0)
            {
                return;
            }

            for (int i = 0; i < Packets.Length; i++)
            {
                string packet = Packets[i];
                TimeOrigin += i;

                if (System.String.IsNullOrEmpty(packet))
                {
                    continue;
                }

                List <Rate> Rates = this.DecodeRates(packet, ref TimeOrigin);

                if (Rates.Count <= 0)
                {
                    Rate Rate = this.ToRateOnChange(packet, ref TimeOrigin);

                    if (Rate != null && Rate.Token >= 0)
                    {
                        Rate.Pair = ForexConfiguration.OrderPair[Rate.Token];
                        Rate.ChartData.TickTime = TimeOrigin;
                        Rates.Add(Rate);
                    }
                    else
                    {
                        //"UP\\DEAL\\EUR/USD\\1000\\1000\\0\\0\\0\\256044115\\121334263\\1137.75\\1.13775000\\49040.82\\0\\"
                    }
                }

                if (ForexRates != null && ForexRates.Loaded)
                {
                    ForexRates.UpdateDataRates(Rates.ToArray());
                }

                ForexArchive.Update(ServiceConfiguration.TimeFrame.LIVE, Rates);
                ForexArchive.Updates += Rates.Count;
            }
        }
Example #17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="text"></param>
        /// <param name="color"></param>
        /// <param name="maxLines"></param>
        /// <param name="deleteMultiplayer">Reduces flicker of scrollbar</param>
        /// <param name="timeout"></param>
        public void AppendTextToStart(string text, Color color, int maxLines, double deleteMultiplayer = 2, int timeout = 1000)
        {
            try
            {
                bool readonlystate = this.ReadOnly;
                this.ReadOnly = false;

                TickTime start = TickTime.Now;



                this.SelectionStart  = 0;
                this.SelectionLength = 0;// text.Length - 1;
                this.ScrollToCaret();
                this.SelectionColor = color;
                this.SelectedText   = text;

                if (this.Lines.Length >= maxLines)
                {
                    while (this.Lines.Length >= (maxLines * deleteMultiplayer) && !TickTime.Timeout(start, timeout, TickTime.Unit.ms))
                    {
                        string rtext = this.Text;
                        int    last1 = rtext.IndexOfByCount('\n', -1);
                        int    last2 = rtext.IndexOfByCount('\n', -2);

                        if (last1 < 0 || last2 < 0)
                        {
                            Asmodat.Debugging.Output.WriteLine("Not managed outcom in  RichTextBox Abbreviate class !");
                            return;
                        }

                        this.SelectionStart  = (int)last2 + 1;
                        this.SelectionLength = ((int)last1 - (int)last2) + 1;
                        this.SelectedText    = "";
                    }
                }


                this.ScrollTop();

                if (TickTime.Timeout(start, timeout, TickTime.Unit.ms))
                {
                    Asmodat.Debugging.Output.WriteLine("Rtbx timeout.");
                }

                this.ReadOnly = readonlystate;
            }
            catch (Exception ex)
            {
                Asmodat.Debugging.Output.WriteException(ex);
            }
        }
Example #18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="DTime"></param>
        /// <param name="bIncrement"></param>
        /// <returns></returns>
        public string Get(TickTime DTime, bool bIncrement = false)
        {
            if (!DDTSBuffer.ContainsKey(DTime))
            {
                return(null);
            }

            if (bIncrement)
            {
                ++Indexer;
            }
            return(DDTSBuffer[DTime]);
        }
Example #19
0
        public static void AppendTextToStart(RichTextBox RTBox, string text, Color color, int maxLines, int timeout = 1000)
        {
            RTBox.Invoke((MethodInvoker)(() =>
            {
                bool readonlystate = RTBox.ReadOnly;

                try
                {
                    RTBox.ReadOnly = false;
                    RTBox.SelectionStart = 0;
                    RTBox.SelectionLength = 0;// text.Length - 1;
                    RTBox.ScrollToCaret();
                    RTBox.SelectionColor = color;
                    RTBox.SelectedText = text;

                    TickTime start = TickTime.Now;
                    while (RTBox.Lines.Length >= maxLines && !TickTime.Timeout(start, timeout, TickTime.Unit.ms))
                    {
                        string rtext = RTBox.Text;
                        int last1 = rtext.IndexOfByCount('\n', -1);
                        int last2 = rtext.IndexOfByCount('\n', -2);

                        if (last1 < 0 || last2 < 0)
                        {
                            Asmodat.Debugging.Output.WriteLine("Not managed outcom in  RichTextBox Abbreviate class !");
                            return;
                        }
                        // throw new Exception("TODO: finish");

                        RTBox.SelectionStart = (int)last2 + 1;
                        RTBox.SelectionLength = ((int)last1 - (int)last2) + 1;
                        RTBox.SelectedText = "";
                    }

                    RTBox.SelectionStart = 0;
                    RTBox.SelectionLength = 0;
                    RTBox.ScrollToCaret();

                    if (TickTime.Timeout(start, timeout, TickTime.Unit.ms))
                    {
                        Asmodat.Debugging.Output.WriteLine("Rtbx timeout.");
                    }
                }
                catch (Exception ex)
                {
                    Asmodat.Debugging.Output.WriteException(ex);
                }

                RTBox.ReadOnly = readonlystate;
            }));
        }
Example #20
0
        private void UpdateRates()
        {
            //ProductSetting PS = new ProductSetting();
            string   packet = GetRateBlotter();
            TickTime origin = TickTime.Now;

            if (System.String.IsNullOrEmpty(packet))
            {
                return;
            }

            List <Rate> Rates = this.DecodeRates(packet, ref origin);

            this.UpdateDataRates(Rates.ToArray());
        }
Example #21
0
 public void Update(TickTime tickTime)
 {
     /*
     Parallel.ForEach(_engine.Factory.GameObjects.Values.Where(o => o is IHasPhysics).Select(o => (IHasPhysics)o), gameobject =>
                                                                                                                       {
                                                                                                                           CheckCollision(gameobject);
                                                                                                                           gameobject.Body.Update(tickTime);
                                                                                                                      }); */
     /*
     foreach (var o in _gameObjectFactory.GameObjects.Values.OfType<IHasPhysics>())
     {
         CheckCollision(o);
         o.Body.Update(tickTime);
     }*/
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitializeTrackingNumber(true);
            }

            if (SManager != null && SManager.ExchangeOrder != null)
            {
                if (!SManager.ExchangeOrder.TimeoutWarningsExecute.IsDefault && TickTime.Timeout(SManager.ExchangeOrder.TimeoutWarningsExecute, 5, TickTime.Unit.s))
                {
                    SManager.ExchangeOrder.TimeoutWarningsExecute = TickTime.Default;
                    AlertsControlExecute.HideWarning();
                }
            }
        }
Example #23
0
        public static string NewString()
        {
            try
            {
                TickTime start  = TickTime.Now;
                string   time   = TickTime.NowTicks.ToString("X");
                string   random = AMath.Random(1, 1000000).ToString("X");
                string   span   = start.Span().ToString("X");

                return(string.Format("{0}{1}{2}", time, random, span));
            }
            catch (Exception ex)
            {
                ex.ToOutput();
                return(null);
            }
        }
Example #24
0
        public KeyValuePair <TickTime, string> GetPair(bool increment = false)
        {
            if (Indexer < 0)
            {
                return(new KeyValuePair <TickTime, string>(TickTime.Default, null));
            }

            TickTime key   = this.GetKey(Indexer);
            string   value = this.GetValue(Indexer);
            var      kvp   = new KeyValuePair <TickTime, string>(key, value);

            if (increment)
            {
                this.IndexerIcrement();
            }

            return(kvp);
        }
        public void TimrServerTime()
        {
            if (!TimeoutServerTime.IsTriggered)
            {
                return;
            }

            TimeoutServerTime.Forced = true;

            TickTime time = this.GetServerTime();

            if (time.IsDefault)
            {
                return;
            }

            this.ServerTime = time;
            TimeoutServerTime.Reset();
        }
Example #26
0
        public static void AppendText(RichTextBox RTBox, string text, Color color, int maxLines, bool scroll = false, int timeout = 1000)
        {
            RTBox.Invoke((MethodInvoker)(() =>
            {
                bool readonlystate = RTBox.ReadOnly;
                try
                {
                    RTBox.ReadOnly = false;
                    RTBox.SelectionStart = RTBox.TextLength;
                    RTBox.SelectionLength = 0;
                    RTBox.SelectionColor = color;
                    RTBox.AppendText(text);
                    RTBox.SelectionColor = RTBox.ForeColor;

                    int iSelectionSave = RTBox.SelectionStart;
                    TickTime start = TickTime.Now;
                    while (RTBox.Lines.Length > maxLines && !TickTime.Timeout(start, timeout, TickTime.Unit.ms))
                    {
                        RTBox.SelectionStart = 0;
                        RTBox.SelectionLength = RTBox.Text.IndexOf("\n", 0) + 1;
                        RTBox.SelectedText = "";
                    }

                    if (scroll && RTBox.Text != null)
                    {
                        RTBox.SelectionStart = RTBox.Text.Length;
                        RTBox.ScrollToCaret();
                    }

                    if (TickTime.Timeout(start, timeout, TickTime.Unit.ms))
                    {
                        Asmodat.Debugging.Output.WriteLine("Rtbx timeout.");
                    }
                }
                catch (Exception ex)
                {
                    Asmodat.Debugging.Output.WriteException(ex);
                }

                RTBox.ReadOnly = readonlystate;
            }));
        }
Example #27
0
        public static void Sleep(ref TickTime start, long timeout, TickTime.Unit timeoutUnit = TickTime.Unit.ms)
        {
            if (timeoutUnit < TickTime.Unit.ms)
            {
                throw new Exception("timeoutUnit is to small, must be greater or equal to ms");
            }

            long end = start.Ticks + ((long)timeoutUnit * timeout);
            long now = TickTime.NowTicks;


            if (end <= now)
            {
                return;
            }

            while (end > now)
            {
                Thread.Sleep(1);
                end = start.Ticks + ((long)timeoutUnit * timeout);
                now = TickTime.NowTicks;
            }
        }
Example #28
0
        private List <Rate> DecodeRates(string packet, ref TickTime origin)
        {
            List <Rate> Rates = new List <Rate>();

            string[] DelimitedData = Asmodat.Abbreviate.String.ToList(packet, "$");
            if (DelimitedData == null)
            {
                return(Rates);
            }



            foreach (string data in DelimitedData)
            {
                Rate Rate = this.ToRate(data, ref origin);
                if (Rate != null)
                {
                    Rates.Add(Rate);
                }
            }

            return(Rates);
        }
Example #29
0
        /// <summary>
        /// Decodes data and sets reciving time if origin != TickTime.MinValue
        /// </summary>
        /// <param name="packet"></param>
        /// <param name="origin"></param>
        /// <returns></returns>
        private List <Rate> DecodeRates(string packet, ref TickTime origin)
        {
            List <Rate> Rates = new List <Rate>();

            string[] DelimitedData = Asmodat.Abbreviate.String.ToList(packet, "$");
            if (DelimitedData == null)
            {
                return(Rates);
            }


            for (int i = 0; i < DelimitedData.Length; i++)
            {
                Rate Rate = this.ToRateOnConnect(DelimitedData[i], ref origin);

                if (Rate != null)
                {
                    Rates.Add(Rate);
                }
            }

            return(Rates);
        }
Example #30
0
 public void Update(TickTime tickTime)
 {
     Position += Velocity*tickTime.GameTimeDelta.TotalSeconds;
 }
Example #31
0
 public void Update(TickTime tickTime)
 {
 }
Example #32
0
 public void Update(TickTime delta)
 {
 }
Example #33
0
 private void Update(TickTime tickTime)
 {
     Parallel.ForEach(Factory.GameObjects, gameobject => gameobject.Value.Update(tickTime));
 }
Example #34
0
        private void Update(TickTime tickTime)
        {
            Parallel.ForEach(Factory.GameObjects.Values, gameObject =>
                {
                    var hasPhysics = gameObject as IHasPhysics;
                    if (hasPhysics != null)
                    {
                        hasPhysics.Body.Update(tickTime);
                    }
                    gameObject.Update(tickTime);
                });

            /*
            foreach (var gameObject in Factory.GameObjects.Values)
            {
                var hasPhysics = gameObject as IHasPhysics;
                if (hasPhysics != null)
                {
                    hasPhysics.Body.Update(tickTime);
                }
                gameObject.Update(tickTime);
            }*/
        }
Example #35
0
 public void Update(TickTime tickTime)
 {
     this.Rotation = this.Rotation * (this.RotationalVelocity * tickTime.GameTimeDelta.TotalSeconds);
     this.Position = this.Position + (this.Velocity * tickTime.GameTimeDelta.TotalSeconds);
 }
Example #36
0
        public void Tick(TickTime tickTime)
        {
            var collision = (from o in _physicsObjects
                             from b in _barriers
                             let c = CalculateCollision(b, o.Body, TimeSpan.Zero, tickTime.TickElapsed, 0)
                             where c != null
                             orderby c.CollisionTime
                             select c).FirstOrDefault();

            if (collision != null) {
                UpdateKinematics(collision.CollisionTime);
                collision.Barrier.ApplyCollision(_eventTriggerer, collision.Body);
                Tick(new TickTime(tickTime.TickElapsed - collision.CollisionTime, tickTime.TotalElapsed));
                return;
            }

            UpdateKinematics(tickTime.TickElapsed);

            _eventTriggerer.Trigger(new Tick());
        }
Example #37
0
        public ICollision CalculateCollision(GameObjectBase gameObject, TickTime tickTime)
        {
            if (gameObject.Body.Velocity == Vector2.Zero)
                return null;

            if (gameObject is GolfBall)
                return CalculateCollision((GolfBall) gameObject, tickTime);

            return null;
        }
Example #38
0
 public void Update(TickTime delta)
 {
     throw new NotImplementedException();
 }
Example #39
0
        public void LoadEntries(string[] pairs, OHLC.Interval[] intervals)
        {
            if (pairs == null || intervals == null || pairs.Length <= 0 || intervals.Length <= 0)
            {
                return;
            }

            foreach (OHLC.Interval interval in intervals)
            {
                foreach (string pair in pairs)
                {
                    string key     = this.GetKey(pair, interval);
                    var    entries = Entries.Get(key);

                    TickTime last    = new TickTime(0);
                    int      minutes = (int)interval;
                    if (entries != null)
                    {
                        if (entries.Last.AddMinutes(minutes) > TickTime.Now)
                        {
                            continue;
                        }

                        last = entries.Last;
                    }
                    else
                    {
                        entries          = new ArchiveEntriesJson();
                        entries.PairName = pair;
                        entries.Interval = interval;
                        entries.Last     = last;
                        entries.Entries  = new OHLCEntry[0];
                    }

                    if (last > new TickTime(0).AddMinutes(minutes))
                    {
                        last = last.AddMinutes(-minutes);
                    }

                    OHLC ohlc = null;
                    try
                    {
                        ohlc = Manager.GetOHLC(pair, interval, last);
                    }
                    catch
                    {
                        continue;
                    }

                    if (ohlc == null)
                    {
                        continue;
                    }


                    var _old = entries.Entries.ToDistinctKeyDictionary(x => x.Time, x => x);
                    var _new = ohlc.Entries.ToDistinctKeyDictionary(x => x.Time, x => x);
                    _old.AddOrUpdate(_new);

                    List <OHLCEntry> list = _old.Values.ToList();

                    if (list == null || list.Count <= 0)
                    {
                        continue;
                    }

                    entries.Entries = list.ToArray();
                    entries.Last    = list.Last().Time;
                    Entries.Set(key, entries, true);
                }
            }
        }