public void Fire() { if (!IsAnimating && CurrentWeapon != null) { CurrentWeapon.Fire(); } }
/// <summary> /// fires forward. /// There is a divergence of a specified range around the shooting angle. /// </summary> public override void WeaponFire() { Vector3 fireStart = BoneTransforms[indexTurretBone].Translation; Vector3 fireDirection = BoneTransforms[indexTurretBone].Up; // The weapon firing. Play a sound and particle CurrentWeapon.Fire(fireStart, fireDirection, CurrentWeapon.SpecData.FireRange, ref colLayerFriendlyMech, ref colLayerHitWorld, BoneTransforms[indexFireWeaponBone], null); }
/// <summary> /// fires forward. /// </summary> public override void WeaponFire() { Vector3 start = WorldTransform.Translation + (WorldTransform.Up * 5.0f); Matrix rot = Matrix.CreateFromAxisAngle( WorldTransform.Right, MathHelper.ToRadians(-30.0f)); Vector3 direction = Vector3.Transform(WorldTransform.Forward, rot); // The weapon firing // Fire hit test and sound play CurrentWeapon.Fire(start, direction, CurrentWeapon.SpecData.FireRange * 1.5f, ref colLayerFriendlyMech, ref colLayerHitWorld, null, null); }
/// <summary> /// fires forward. /// There is a divergence of a specified range around the shooting angle. /// </summary> public override void WeaponFire() { int weaponCount = 1; Vector3 start = Vector3.Zero; Vector3 direction = Vector3.Zero; // Calculate fire and target info if (CurrentWeapon.WeaponType == WeaponType.CameleerGun || CurrentWeapon.WeaponType == WeaponType.MaomingGun || CurrentWeapon.WeaponType == WeaponType.DuskmasCannon || CurrentWeapon.WeaponType == WeaponType.HammerCannon || CurrentWeapon.WeaponType == WeaponType.TigerCannon) { int fireHorizontalTiltAngle = CurrentWeapon.SpecData.FireHorizontalTiltAngle; float fireHorizontal = MathHelper.ToRadians( (float)HelperMath.Randomi( -fireHorizontalTiltAngle, fireHorizontalTiltAngle)); int fireVerticalTiltAngle = CurrentWeapon.SpecData.FireVerticalTiltAngle; float fireVertical = MathHelper.ToRadians( (float)HelperMath.Randomi( -fireVerticalTiltAngle, fireVerticalTiltAngle)); start = WorldTransform.Translation + (WorldTransform.Up * 2.0f); Matrix RndMatrix = Matrix.CreateFromAxisAngle(Up, fireHorizontal) * Matrix.CreateFromAxisAngle(Right, fireVertical) * WorldTransform; direction = RndMatrix.Forward; } else if (CurrentWeapon.WeaponType == WeaponType.PhantomMelee) { start = WorldTransform.Translation + (WorldTransform.Up * 2.0f); Matrix rot = Matrix.CreateFromAxisAngle( WorldTransform.Right, MathHelper.ToRadians(-30.0f)); direction = Vector3.Transform(start, rot); } switch (this.UnitType) { case UnitTypeId.Cameleer: case UnitTypeId.Hammer: weaponCount = 2; break; case UnitTypeId.Maoming: case UnitTypeId.Duskmas: case UnitTypeId.Tiger: weaponCount = 1; break; } Matrix?fireFxBone1 = null, fireFxBone2 = null; for (int i = 0; i < weaponCount; i++) { if (i == 0) { Matrix fireMatrix = TransformedMatrix; fireMatrix.Translation = BoneTransforms[indexRightFireWeaponBone].Translation; fireFxBone1 = fireMatrix; } else if (i == 1) { Matrix fireMatrix = TransformedMatrix; fireMatrix.Translation = BoneTransforms[indexLeftFireWeaponBone].Translation; fireFxBone2 = fireMatrix; } } // The weapon firing. Play the sound and particle CurrentWeapon.Fire(start, direction, CurrentWeapon.SpecData.FireRange, ref colLayerFriendlyMech, ref colLayerHitWorld, fireFxBone1, fireFxBone2); }