Пример #1
0
        /// <summary>
        /// Creates instance at given position and traveling to given target (position).
        /// </summary>
        /// <param name="position">The bullet start position.</param>
        /// <param name="solSystem">The bullet SolarSystem.</param>
        /// <param name="targetPosition">The taget position.</param>
        /// <param name="rec">The bullet't hit reciever.</param>
        public Missile2(Vector3 position, SolarSystem solSystem, Vector3 targetPosition, IBulletStopReciever rec)
        {
            this.position    = position;
            this.name        = Game.IGameObjectCreator.GetUnusedName(typeof(Missile2).ToString());
            this.solarSystem = solSystem;
            this.reciever    = rec;

            // Calucalates a distance and a direction.
            direction = targetPosition - position;
            distance  = direction.Normalise();

            // Registers IBullet and SolarSystem set visibility.
            solarSystem.AddIBullet(this);

            // Caluculate constants for hidden collision.
            a = -(targetPosition.z - position.z);
            b = (targetPosition.x - position.x);
            c = -a * targetPosition.x - b * targetPosition.z;
            destinationDevider = (float)System.Math.Sqrt(a * a + b * b);
        }
Пример #2
0
        /// <summary>
        /// Creates instance at given position and traveling to given target (position).
        /// </summary>
        /// <param name="position">The bullet start position.</param>
        /// <param name="solSystem">The bullet SolarSystem.</param>
        /// <param name="targetPosition">The taget position.</param>
        /// <param name="rec">The bullet't hit reciever.</param>
        public Missile2(Vector3 position, SolarSystem solSystem, Vector3 targetPosition, IBulletStopReciever rec)
        {
            this.position = position;
            this.name = Game.IGameObjectCreator.GetUnusedName(typeof(Missile2).ToString());
            this.solarSystem = solSystem;
            this.reciever = rec;

            // Calucalates a distance and a direction.
            direction = targetPosition - position;
            distance = direction.Normalise();

            // Registers IBullet and SolarSystem set visibility.
            solarSystem.AddIBullet(this);

            // Caluculate constants for hidden collision.
            a = -(targetPosition.z - position.z);
            b = (targetPosition.x - position.x);
            c = -a * targetPosition.x - b * targetPosition.z;
            destinationDevider = (float)System.Math.Sqrt(a * a + b * b);
        }