コード例 #1
0
ファイル: MyCannonGun.cs プロジェクト: Bunni/Miner-Wars-2081
        //  Every child of this base class must implement Shot() method, which shots projectile or missile.
        //  Method returns true if something was shot. False if not (because interval between two shots didn't pass)
        public override bool Shot(MyMwcObjectBuilder_SmallShip_Ammo usedAmmo)
        {
            if ((MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot) < MyCannonConstants.SHOT_INTERVAL_IN_MILISECONDS && !IsDummy) return false;

            //  Throw ship backward (by deviated vector)
            this.Parent.Physics.AddForce(MyPhysicsForceType.ADD_BODY_FORCE_AND_BODY_TORQUE,
                MyUtilRandomVector3ByDeviatingVector.GetRandom(Vector3.Backward, MathHelper.ToRadians(5)) * MyMwcUtils.GetRandomFloat(40000, 50000), null, null);

            //  Play missile launch cue (one-time)
            //AddWeaponCue(MySoundCuesEnum.WepMissileLaunch3d);
            AddWeaponCue(MySoundCuesEnum.WepCannon3d);

            Vector3 forwardVelocity = MyMath.ForwardVectorProjection(this.WorldMatrix.Forward, GetParentMinerShip().Physics.LinearVelocity);
            //Vector3 forwardVelocity = this.WorldMatrix.Forward;

            Vector3 deviatedVector = GetDeviatedVector(MinerWars.AppCode.Game.Gameplay.MyAmmoConstants.GetAmmoProperties(usedAmmo.AmmoType));

            var cannonShotStartPos = GetPosition() + WorldMatrix.Forward * WorldVolume.Radius;
            cannonShotStartPos = CorrectPosition(cannonShotStartPos, deviatedVector, Parent);

            //  Create and fire missile - but deviate missile direction be random angle
            MyCannonShots.Add(cannonShotStartPos, forwardVelocity, deviatedVector, usedAmmo, (MySmallShip) Parent);

            m_lastTimeShoot = MyMinerGame.TotalGamePlayTimeInMilliseconds;

            m_lastSmokePosition = GetSmokePosition();

            //  We shot one missile
            return true;
        }
コード例 #2
0
        public override bool Shot(MyMwcObjectBuilder_SmallShip_Ammo usedAmmo)
        {
            if (!base.Shot(usedAmmo))
                return false;


            return true;
        }
コード例 #3
0
ファイル: MyCannonShot.cs プロジェクト: Bunni/Miner-Wars-2081
        //  This method realy initiates/starts the missile
        //  IMPORTANT: Direction vector must be normalized!
        public void Start(Vector3 position, Vector3 initialVelocity, Vector3 directionNormalized, MyMwcObjectBuilder_SmallShip_Ammo usedAmmo, MySmallShip minerShip)
        {
            m_usedAmmo = usedAmmo;
            m_ammoProperties = MyAmmoConstants.GetAmmoProperties(usedAmmo.AmmoType);
            m_gameplayProperties = MyGameplayConstants.GetGameplayProperties(m_usedAmmo, Faction);
            m_penetratedVoxelMap = null;
            m_wasPenetration = false;
            m_hasExplosion = false;
            m_isExploded = false;
            m_collidedEntity = null;
            m_collisionPoint = null;
                
            Matrix orientation = GetWorldRotation();
            Vector3 pos = position;

            //  Play missile thrust cue (looping)
            m_thrusterCue = MyAudio.AddCue3D(MySoundCuesEnum.WepMissileFly, pos, orientation.Forward, orientation.Up, this.Physics.LinearVelocity);

            m_light = MyLights.AddLight();
            if (m_light != null)
            {
                m_light.Start(MyLight.LightTypeEnum.PointLight, GetPosition(), MyMissileHelperUtil.GetCannonShotLightColor(), 1, MyMissileConstants.MISSILE_LIGHT_RANGE);
            }

            m_diffuseColor = m_ammoProperties.TrailColor;

            switch (usedAmmo.AmmoType)
            {
                case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Basic:
                case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_High_Speed:
                case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Armor_Piercing_Incendiary:
                case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_SAPHEI:
                case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Proximity_Explosive:
                    m_explosionType = MyExplosionTypeEnum.MISSILE_EXPLOSION;
                    break;
                case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_BioChem:
                    m_explosionType = MyExplosionTypeEnum.BIOCHEM_EXPLOSION;
                    break;
                case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_EMP:
                    m_explosionType = MyExplosionTypeEnum.EMP_EXPLOSION;
                    break;
                case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Tunnel_Buster:
                    m_explosionType = MyExplosionTypeEnum.BLASTER_EXPLOSION;
                    break;
                default:
                    throw new MyMwcExceptionApplicationShouldNotGetHere();
                    break;
            }

            this.Physics.Mass = m_gameplayProperties.WeightPerUnit;

            Vector3? correctedDirection = null;
            if (MyGameplayConstants.GameplayDifficultyProfile.EnableAimCorrection)
            {
                if (minerShip == MinerWars.AppCode.Game.Managers.Session.MySession.PlayerShip)
                {
                    correctedDirection = MyEntities.GetDirectionFromStartPointToHitPointOfNearestObject(minerShip, position, m_ammoProperties.MaxTrajectory);
                }
            }

            if (correctedDirection != null)
                directionNormalized = correctedDirection.Value;

            base.Start(position, initialVelocity, directionNormalized, m_ammoProperties.DesiredSpeed, minerShip);

            if (correctedDirection != null) //override the base class behaviour, update the missile direction
            {
                Matrix ammoWorld = minerShip.WorldMatrix;
                ammoWorld.Translation = position;
                ammoWorld.Forward = correctedDirection.Value;

                SetWorldMatrix(ammoWorld);
            }

            m_smokeEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_CannonShot);
            m_smokeEffect.AutoDelete = false;
            m_smokeEffect.WorldMatrix = WorldMatrix;
        }
コード例 #4
0
 public override bool Shot(MyMwcObjectBuilder_SmallShip_Ammo usedAmmo)
 {
     // Ammo is never changed, it uses always same ammo as in init
     m_canStopShooting = m_barrel.StartShooting();
     return m_canStopShooting;
 }