示例#1
0
        static void OnBar(iConnector connector, OnTickEventArgs args)
        {
            var Time  = UnixTimeStampToDateTime(connector.GetTime());
            var Quote = connector.GetQuote(args.Symbol);

            Console.WriteLine(String.Format("Bar {0} {1}: {2}", Time.ToShortDateString(), Time.ToShortTimeString(), Quote));
        }
示例#2
0
 private void onTickHandler(iConnector connector, OnTickEventArgs args)
 {
     if (args.Symbol != this.symbolTimeFrame.symbol)
     {
         return;
     }
     this.onTick();
 }
示例#3
0
 private void onBarHandler(iConnector connector, OnTickEventArgs args)
 {
     if (args.Symbol != this.symbolTimeFrame.symbol && args.timeFrame != this.symbolTimeFrame.timeFrame)
     {
         return;
     }
     this.onBar();
 }
示例#4
0
        internal virtual void Update(GameTime gameTime)
        {
            Timer += (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (Timer > Interval)
            {
                var args = new OnTickEventArgs();
                OnTickEvent?.Invoke(this, args);
                Timer = 0;
            }
        }
示例#5
0
        /// <summary>
        /// Updates the game-time
        /// </summary>
        /// <param name="sender">Sender</param>
        /// <param name="eventArgs">Event-args</param>
        public void UpdateTime(object sender, OnTickEventArgs eventArgs)
        {
            if (Math.Floor(eventArgs.GameTime.TotalGameTime.TotalSeconds) < secondsPast + INGAME_MINUTE_LENGTH)
            {
                return;
            }

            secondsPast = (int)eventArgs.GameTime.TotalGameTime.TotalSeconds;

            TickMinute();

            Console.WriteLine(currentTime);
        }
示例#6
0
        public void Update(object sender, OnTickEventArgs eventArgs)
        {
            if (!Waypoints.Any())
            {
                return;
            }

            float speed = LocationModel.Parent.UnitModel.Speed;

            if (DistanceCalculator.DiagonalDistance(Waypoints.Peek(), LocationModel.FloatCoords) < speed)
            {
                // Arrived near destination
                LocationModel.FloatCoords = Waypoints.Dequeue();

                if (!Waypoints.Any())
                {
                    MoveComplete?.Invoke(this, new EventArgsWithPayload <FloatCoords>(LocationModel.FloatCoords));
                }

                return;
            }

            float xDifference = (float)DistanceCalculator.CalcDistance(LocationModel.FloatCoords.x, Waypoints.Peek().x);
            float yDifference = (float)DistanceCalculator.CalcDistance(LocationModel.FloatCoords.y, Waypoints.Peek().y);

            // calculate new coords
            float diagonalDifference = (float)DistanceCalculator.Pythagoras(xDifference, yDifference);
            float v = diagonalDifference / speed;

            FloatCoords difference = new FloatCoords
            {
                x = xDifference / v,
                y = yDifference / v
            };

            difference.x = Waypoints.Peek().x < LocationModel.FloatCoords.x ? -difference.x : difference.x;

            difference.y = Waypoints.Peek().y < LocationModel.FloatCoords.y ? -difference.y : difference.y;

            LocationModel.FloatCoords = new FloatCoords()
            {
                x = LocationModel.FloatCoords.x + difference.x,
                y = LocationModel.FloatCoords.y + difference.y
            };
        }
示例#7
0
        public void Update(object sender, OnTickEventArgs eventArgs)
        {
            if (!active)
            {
                return;
            }

            MouseState temp       = Mouse.GetState();
            Coords     tempcoords = new Coords {
                x = temp.X, y = temp.Y
            };
            // saves current mouse location
            FloatCoords SecondPoint = WorldPositionCalculator.DrawCoordsToCellFloatCoords(WorldPositionCalculator.TransformWindowCoords(tempcoords, Game.Camera.GetViewMatrix()), Game.GameView.TileSize);

            //standardices coords to topleft and bottomright
            SetCoords(firstPoint, SecondPoint);
            RegisterDrawBox();
        }
示例#8
0
        public bool Next()
        {
            this.time += this.lowestTimeFrame * 60;
            if (this.time > this.endTime)
            {
                return(this.end());
            }

            var pairTimeFrameEvents = new List <PairTimeFrame>();

            foreach (var pairTimeFrame in pairTimeFrames)
            {
                var hasEvent = pairTimeFrame.SetTime(this.time);
                if (hasEvent)
                {
                    pairTimeFrameEvents.Add(pairTimeFrame);
                }
            }

            this.checkStopLossAndTakeProfits();
            foreach (var pairTimeFrame in pairTimeFrameEvents)
            {
                var eventArgs = new OnTickEventArgs(pairTimeFrame.Symbol, pairTimeFrame.TimeFrame);

                if (pairTimeFrame.TimeFrame == this.lowestTimeFrame && this.OnTick != null)
                {
                    this.OnTick(this, eventArgs);
                }
                if (this.OnBar != null)
                {
                    this.OnBar(this, eventArgs);
                }
            }

            return(true);
        }
示例#9
0
 private void TickEquipment(object sender, OnTickEventArgs e)
 {
     UpdateTowingEquipment();
 }
 /// <summary>
 /// updates the cooldown of the actions
 /// </summary>
 /// <param name="sender">Event sender</param>
 /// <param name="eventArgs">EventArgs in gametime</param>
 public void Update(object sender, OnTickEventArgs eventArgs)
 {
     CurrentCooldown -= (uint)eventArgs.GameTime.ElapsedGameTime.TotalSeconds;
 }
示例#11
0
 public void Update(object sender, OnTickEventArgs eventArgs)
 {
     UpdateViewModes(ViewMode.Fog);
     UpdateViewModes(ViewMode.Full);
 }