Пример #1
0
 public UltraPhaser(ICanyonShooterGame game, WeaponHolderType weaponHolderType, WeaponManager weaponManager)
     : base(game, weaponHolderType, "UltraPhaser", weaponManager, "Weapon.UltraPhaser")
 {
     // Instance Data initialisieren:
     for (int i = 0; i < instanceCount; i++)
     {
         instanceData[i] = Matrix.Identity;
     }
 }
Пример #2
0
 public Minigun(ICanyonShooterGame game, WeaponHolderType weaponHolderType, WeaponManager weaponManager)
     : base(game, weaponHolderType, "Minigun", weaponManager, "Minigun")
 {
     // Instance Data initialisieren:
     for (int i = 0; i < instanceCount; i++)
     {
         instanceData[i] = Matrix.Identity;
     }
     DualWeapon = WeaponType.MINIGUN2;
 }
Пример #3
0
        public WeaponManager(ICanyonShooterGame game, IModel weaponHolder, WeaponHolderType weaponHolderType)
        {
            this.weaponHolderType = weaponHolderType;

            if (game != null)
            {
                this.game = game;
            }
            else
            {
                throw new Exception("game can't null!");
            }

            weapons.Add(WeaponType.NO_WEAPON, null);

            if (weaponHolder != null)
            {
                this.weaponHolder = weaponHolder;
            }
        }
Пример #4
0
        public UltraPhaserProjectile(ICanyonShooterGame game, Vector3 startPosition, Vector3 direction, UltraPhaser owner, WeaponHolderType weaponHolderType)
            : base(game, startPosition, direction, "Lasergun", weaponHolderType)
        {
            this.game  = game;
            this.Owner = owner;

            // ist nur instanz von einem model, daher nicht selbst anzeigen sondern durch die waffe
            Visible = false;

            if (direction.Length() > 0)
            {
                direction.Normalize();
            }

            Velocity = direction * 500 + owner.Velocity;

            //add Collision Hit Object:
            SphereShapeData hitObject = new SphereShapeData();

            hitObject.Radius              = 0.1f;
            hitObject.Material.Hardness   = 0.1f;
            hitObject.Material.Bounciness = 0.0f;
            hitObject.Material.Friction   = 1.0f;
            hitObject.Material.Density    = 1000f;
            hitObject.ContactGroup        = (int)ContactGroup;

            AddShape(hitObject);
            InfluencedByGravity = false;

            AutoDestruction     = true;
            AutoDestructionTime = TimeSpan.FromSeconds(2);

            Rotation = Helper.RotateTo(direction, DefaultDirection);

            // Größe der Laserstrahlen
            LocalScale = new Vector3(0.5f, 0, 5);

            // initialize the rotation
            MakeRotation();
        }
Пример #5
0
 public PlasmaGun(ICanyonShooterGame game, WeaponHolderType weaponHolder, WeaponManager weaponManager)
     : base(game, weaponHolder, "PlasmaGun", weaponManager, "Weapon.PlasmaGun")
 {
 }
Пример #6
0
        public PlasmaGunProjectile(ICanyonShooterGame game, Vector3 startPosition, Vector3 direction, PlasmaGun owner, WeaponHolderType weaponHolderType)
            : base(game, startPosition, direction, "RocketLaunch", weaponHolderType)
        {
            this.game  = game;
            this.owner = owner;
            // assign a Model
            SetModel("PlasmaGun");

            // effect light
            light        = new PointLight(game, Color.Azure, 1.0f);
            light.Parent = this;
            game.World.AddPointLight(light);



            // rotate the projectile into the direction
            Vector3 defaultDirection = new Vector3(0, 0, -1);

            if (defaultDirection != Direction)
            {
                Direction.Normalize();
                defaultDirection.Normalize();
                Vector3 rotationAxe = Vector3.Cross(defaultDirection, Direction);
                rotationAxe.Normalize();
                float angle = (float)Math.Acos(Vector3.Dot(Direction, defaultDirection));
                LocalRotation = Quaternion.CreateFromAxisAngle(rotationAxe, angle);
            }

            // set speed and direction of the projectile:
            velocity = Direction * owner.ProjectileSpeed + owner.Velocity;
            Velocity = velocity;

            InfluencedByGravity = false;

            /*
             * // create smoke effect
             * SmokeEmitter = game.Effects.CreateEffect("RocketSmoke");
             *
             * // connect the smoke to the this projectile-object:
             * SmokeEmitter.Parent = this;
             *
             * // place the smoke at the end of the rocket:
             * SmokeEmitter.LocalPosition = new Vector3(0, 0, 3.5f);
             *
             * // add smoke to the world
             * game.World.AddEffect(SmokeEmitter);
             *
             * // Loop Smoke until Destruction
             * SmokeEmitter.Play();
             */
        }
Пример #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BaseWeapon"/> class.
        /// </summary>
        /// <param name="game">The game to spawn this weapon in.</param>
        /// <param name="weaponDescription">The weapon description.</param>
        /// <param name="name">The name of the weapon</param>
        public BaseWeapon(ICanyonShooterGame game, WeaponHolderType weaponHolderType, string weaponDescription, WeaponManager weaponManager, string name) : base(game, name)
        {
            this.game        = game;
            manager          = weaponManager;
            WeaponHolderType = weaponHolderType;

            if (weaponDescription == String.Empty)
            {
                return;
            }

            // Load Weapon Description
            desc = game.Content.Load <WeaponDescription>("Content\\Weapons\\" + weaponDescription);

            // Load Model
            if (desc.Model != String.Empty)
#pragma warning disable DoNotCallOverridableMethodsInConstructor
            {
                SetModel(desc.Model);
            }
#pragma warning restore DoNotCallOverridableMethodsInConstructor

            // Load AmmoType
            ammoType = (AmmoType)Enum.Parse(typeof(AmmoType), desc.AmmoType);

            // Load Ammo
            Ammo += desc.DefaultAmmo;
            //if (desc.AmmoReloadCount > desc.DefaultAmmo)
            //{
            //    ammoInMagazine = desc.DefaultAmmo;
            //    Ammo = 0;
            //}
            //else
            //{
            //    ammoInMagazine = desc.AmmoReloadCount;
            //    Ammo += desc.DefaultAmmo - desc.AmmoReloadCount;
            //}

            // Load Sounds:
            if (desc.SoundFiring != String.Empty)
            {
                soundFiring        = game.Sounds.CreateSound(desc.SoundFiring);
                soundFiring.Parent = this;
            }
            if (desc.SoundStartFire != String.Empty)
            {
                soundStartFire        = game.Sounds.CreateSound(desc.SoundStartFire);
                soundStartFire.Parent = this;
            }
            if (desc.SoundStopFire != String.Empty)
            {
                soundStopFire        = game.Sounds.CreateSound(desc.SoundStopFire);
                soundStopFire.Parent = this;
            }
            if (desc.SoundReload != String.Empty)
            {
                soundReload        = game.Sounds.CreateSound(desc.SoundReload);
                soundReload.Parent = this;
            }
            if (desc.SoundAmmoEmpty != String.Empty)
            {
                soundAmmoEmpty        = game.Sounds.CreateSound(desc.SoundAmmoEmpty);
                soundAmmoEmpty.Parent = this;
            }
            state = WeaponState.NOTHING;
        }
Пример #8
0
 public StingerRocket(ICanyonShooterGame game, WeaponHolderType weaponHolder, WeaponManager weaponManager)
     : base(game, weaponHolder, "StingerRocket", weaponManager, "Weapon.StingerRocket")
 {
 }
Пример #9
0
        public BasicProjectile(ICanyonShooterGame game, Vector3 startPos, Vector3 direction, string soundName, WeaponHolderType weaponHolderType)
            : base(game)
        {
            if (game != null)
            {
                this.game = game;
            }
            else
            {
                throw new Exception("game can't be null!");
            }

            ConnectedToXpa = true;
            if (weaponHolderType == WeaponHolderType.Player)
            {
                ContactGroup = ContactGroup.PlayerProjectiles;
            }
            if (weaponHolderType == WeaponHolderType.Enemy)
            {
                ContactGroup = ContactGroup.EnemyProjectiles;
            }

            Direction = direction;

            LocalPosition = startPos;
            FromPosition  = startPos;

            if (soundName != String.Empty || soundName != "")
            {
                sound = game.Sounds.CreateSound(soundName);
                sound.Play();
            }
        }