コード例 #1
0
ファイル: SystemBody.cs プロジェクト: intercross21/Pulsar4x
        /// <summary>
        /// Update the planet's position, Parent positions must be updated in sequence obviously.
        /// </summary>
        /// <param name="tickValue"></param>
        public void UpdatePosition(int tickValue)
        {
            double x, y;

            Orbit.GetPosition(GameState.Instance.CurrentDate, out x, out y);

            Position.X = x;
            Position.Y = y;

            if (Parent != null)
            {
                // Position is absolute system coordinates, while
                // coordinates returned from GetPosition are relative to it's parent.
                Position.X += Parent.Position.X;
                Position.Y += Parent.Position.Y;
            }

            /// <summary>
            /// Update all the moons.
            /// </summary>
            foreach (SystemBody CurrentMoon in Moons)
            {
                CurrentMoon.UpdatePosition(tickValue);
            }

            ///<summary>
            ///Update taskgroup positions.
            ///</summary>
            foreach (TaskGroupTN TaskGroup in TaskGroupsInOrbit)
            {
                TaskGroup.Contact.Position.X = Position.X;
                TaskGroup.Contact.Position.Y = Position.Y;
            }
        }
コード例 #2
0
        /// <summary>
        /// Update the planet's position, Parent positions must be updated in sequence obviously.
        /// </summary>
        /// <param name="tickValue"></param>
        public void UpdatePosition(int tickValue)
        {
            Pulsar4X.Lib.OrbitTable.Instance.UpdatePosition(this, tickValue);

            /// <summary>
            /// Adjust planet position based on the primary. Right now Position.X and Position.Y assume orbiting around 0,0. secondary stars, and eventually moons will have this issue.
            /// </summary>
            Position.X = Position.X + Parent.Position.X;
            Position.Y = Position.Y + Parent.Position.Y;

            /// <summary>
            /// Update all the moons.
            /// </summary>
            foreach (Planet CurrentMoon in Moons)
            {
                CurrentMoon.UpdatePosition(tickValue);
            }

            ///<summary>
            ///Update taskgroup positions.
            ///</summary>
            foreach (TaskGroupTN TaskGroup in TaskGroupsInOrbit)
            {
                TaskGroup.Contact.Position.X = Position.X;
                TaskGroup.Contact.Position.Y = Position.Y;
            }
        }