Ejemplo n.º 1
0
        /// <summary>
        /// Static function to find the distance between two positions.
        /// </summary>
        /// <param name="posA"></param>
        /// <param name="posB"></param>
        /// <returns>distance between posA and posB</returns>
        public static float GetDistanceBetween(SystemPosition posA, SystemPosition posB)
        {
            if (posA.System != posB.System)
            {
                throw new InvalidOperationException("Cannont compare distances between positions in different systems.");
            }
            float distX = (float)(posA.X - posB.X);
            float distY = (float)(posA.Y - posB.Y);

            return (float)Math.Sqrt((distX * distX) + (distY * distY));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Static function to find the distance between two positions.
        /// </summary>
        /// <param name="posA"></param>
        /// <param name="posB"></param>
        /// <returns>distance between posA and posB</returns>
        public static float GetDistanceBetween(SystemPosition posA, SystemPosition posB)
        {
            if (posA.System != posB.System)
            {
                throw new InvalidOperationException("Cannont compare distances between positions in different systems.");
            }
            float distX = (float)(posA.X - posB.X);
            float distY = (float)(posA.Y - posB.Y);

            return((float)Math.Sqrt((distX * distX) + (distY * distY)));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a new system contact.
        /// </summary>
        /// <param name="Fact">Faction of contact.</param>
        /// <param name="entity">Backing entity of the contact.</param>
        public SystemContact(Faction Fact, StarSystemEntity entity)
        {
            Id           = Guid.NewGuid();
            faction      = Fact;
            Position     = entity.Position;
            LastPosition = Position;

            Entity = entity;

            DistTable = new DistanceTable(this);

            SSEntity = entity.SSEntity;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a new system contact.
        /// </summary>
        /// <param name="Fact">Faction of contact.</param>
        /// <param name="entity">Backing entity of the contact.</param>
        public SystemContact(Faction Fact, StarSystemEntity entity)
        {
            Id           = Guid.NewGuid();
            faction      = Fact;
            Position     = entity.Position;
            LastPosition = Position;

            Entity = entity;

            DistTable = new DistanceTable(this);

            SSEntity = entity.SSEntity;

            //add legal orders to list
            _legalOrders.Add(Constants.ShipTN.OrderType.Follow);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Updates the contact after transiting a jump point, LastPosition.X needs to be set to current position for the travel line.
 /// </summary>
 public void UpdateLocationAfterTransit()
 {
     LastPosition = Entity.Position;
     Position     = Entity.Position;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Instance function for those who don't like static functions.
 /// </summary>
 /// <param name="otherPos"></param>
 /// <returns></returns>
 public float GetDistanceTo(SystemPosition otherPos)
 {
     return GetDistanceBetween(this, otherPos);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Instance function for those who don't like static functions.
 /// </summary>
 /// <param name="otherPos"></param>
 /// <returns></returns>
 public float GetDistanceTo(SystemPosition otherPos)
 {
     return(GetDistanceBetween(this, otherPos));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Updates the contact after transiting a jump point, LastPosition.X needs to be set to current position for the travel line.
 /// </summary>
 public void UpdateLocationAfterTransit()
 {
     LastPosition = Entity.Position;
     Position = Entity.Position;
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates a new system contact.
        /// </summary>
        /// <param name="Fact">Faction of contact.</param>
        /// <param name="entity">Backing entity of the contact.</param>
        public SystemContact(Faction Fact, StarSystemEntity entity)
        {
            Id = Guid.NewGuid();
            faction = Fact;
            Position = entity.Position;
            LastPosition = Position;

            Entity = entity;

            DistTable = new DistanceTable(this);

            SSEntity = entity.SSEntity;

            //add legal orders to list
            _legalOrders.Add(Constants.ShipTN.OrderType.Follow);
        }