Example #1
0
        /// <summary>
        /// Populate the geometry km information based on the calculated distance from the first km post.
        /// </summary>
        /// <param name="train">A train object.</param>
        public void populateGeometryKm(Train train)
        {
            /* Determine the direction of the km's the train is travelling. */
            direction direction           = determineTrainDirection(train);
            double    point2PointDistance = 0;

            /* Thie first km point is populated by the parent function ICEData.CleanData(). */
            for (int journeyIdx = 1; journeyIdx < train.TrainJourney.Count(); journeyIdx++)
            {
                /* Calculate the distance between successive points. */
                GeoLocation point1 = new GeoLocation(train.TrainJourney[journeyIdx - 1]);
                GeoLocation point2 = new GeoLocation(train.TrainJourney[journeyIdx]);
                point2PointDistance = calculateDistance(point1, point2);

                /* Determine the cumulative actual geometry km based on the direction. */
                if (direction.Equals(direction.increasing))
                {
                    train.TrainJourney[journeyIdx].geometryKm = train.TrainJourney[journeyIdx - 1].geometryKm + point2PointDistance / 1000;
                }

                else if (direction.Equals(direction.decreasing))
                {
                    train.TrainJourney[journeyIdx].geometryKm = train.TrainJourney[journeyIdx - 1].geometryKm - point2PointDistance / 1000;
                }

                else
                {
                    train.TrainJourney[journeyIdx].geometryKm = train.TrainJourney[journeyIdx].kmPost;
                }
            }
        }
Example #2
0
 /// <summary>
 /// Update ammo coordinates.
 /// </summary>
 /// <param name="amount"></param>
 public void Move(double amount)
 {
     if (_dir.Equals(direction.UP))
     {
         _coordinates.Y -= amount;
     }
     else if (_dir.Equals(direction.DOWN))
     {
         _coordinates.Y += amount;
     }
 }
Example #3
0
 public void MovePlayer(direction d)  // in the works
 {
     //int[] squareToMoveTo = {playerPosition[0] + 1, 0}
     if (d.Equals(direction.up))
     {
         playerPosition[1]++;
     }
     if (d.Equals(direction.down))
     {
         playerPosition[1]--;
     }
     if (d.Equals(direction.left))
     {
         playerPosition[0]++;
     }
     if (d.Equals(direction.right))
     {
         playerPosition[0]--;
     }
 }
Example #4
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="dir">Ammo direction (up/down)</param>
        /// <param name="coordinates">Initial coordinates</param>
        public Ammo(direction dir, Point coordinates)
        {
            _ammoImage   = new Image();
            _dir         = dir;
            _coordinates = coordinates;
            _ammoSpeed   = 1;

            _ammoBitmap = (_dir.Equals(direction.UP))
                             ? new BitmapImage(new Uri(@"Resources\Bullet_down.png", UriKind.Relative))
                             : new BitmapImage(new Uri(@"Resources\Bullet_up.png", UriKind.Relative));

            _ammoImage.Source = _ammoBitmap;
            _ammoImage.Width  = _ammoImage.Width;
            _ammoImage.Height = _ammoImage.Height;
        }
Example #5
0
 // is free the next cell to move
 protected bool FreeCells(direction d)
 {
     bool result = false;
     int row = topPos;
     int col = leftPos;
     if (d.Equals(direction.right))
     {
         result = Battlefield.content[row + 1, col + 4] == ' ' && Battlefield.content[row, col + 4] == ' ' &&
             Battlefield.content[row + 2, col + 4] == ' ';
     }
     else if (d.Equals(direction.left))
     {
         result = Battlefield.content[row + 1, col - 2] == ' ' && Battlefield.content[row, col - 2] == ' ' &&
             Battlefield.content[row + 2, col - 2] == ' ';
     }
     else if (d.Equals(direction.up))
     {
         result = Battlefield.content[row - 1, col] == ' ' && Battlefield.content[row - 1, col + 1] == ' ' &&
             Battlefield.content[row - 1, col + 2] == ' ';
     }
     else // direction down
     {
         result = Battlefield.content[row + 3, col] == ' ' && Battlefield.content[row + 3, col + 1] == ' ' &&
             Battlefield.content[row + 3, col + 2] == ' ';
     }
     return result;
 }