Esempio n. 1
0
        /// <summary>
        /// Creates a ShootScript that will fire Bullets from the given 
        /// Prefabs location and in the given Prefabs rotation. Firing is
        /// controlled by the given keyboard Device.
        /// </summary>
        /// <param name="shooter">Prefab to shoot the Bullets from</param>
        /// <param name="keyboard">Keyboard Device that determines when we shoot</param>
        public TankShootScript(Tank shooter, TankBarrel barrel)
        {
            this.shooter = shooter;
            this.barrel = barrel;

            this.shooting = false;
            this.timeSinceLastShot = barrel.ShootDelay;
            this.pushTime = barrel.ShootDelay * barrel.PullSpeed / (barrel.PullSpeed + barrel.PushSpeed);
            this.pullTime = barrel.ShootDelay * barrel.PushSpeed / (barrel.PullSpeed + barrel.PushSpeed);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a single TurretBarrel which will be represented by the
        /// given Model at the given location facing the given rotation. The
        /// TurretBarrel will be controlled by the given keyboard Device.
        /// </summary>
        /// <param name="barrelModel">
        /// Model to represent the TurretBarrel
        /// </param>
        /// <param name="location">Location of the TurretBarrel</param>
        /// <param name="rotation">Rotation the TurretBarrel is facing</param>
        /// <param name="scale">Scale of the TurretBarrel</param>
        /// <param name="keyboard">
        /// Keyboard Device used to control the TurretBarrel
        /// </param>
        public TankBarrel(Tank tank, Vector3 location, Vector3 rotation, Vector3 scale, Model barrelModel, float maxRotation,
            float minRotation, float shootDistance, float shootDelay, float pushSpeed, float pullSpeed)
            : base(location, rotation, scale)
        {
            this.minRotation = minRotation;
            this.maxRotation = maxRotation;
            this.drawLocation = location;
            this.shootDistance = shootDistance;
            this.shootDelay = shootDelay;
            this.pushSpeed = pushSpeed;
            this.pullSpeed = pullSpeed;

            this.models.Add(barrelModel);
            this.scripts.Add(new TankShootScript(tank, this));
        }