Exemple #1
0
        //  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);
        }
        public override bool Shot(MyMwcObjectBuilder_SmallShip_Ammo usedAmmo)
        {
            if (usedAmmo == null || (MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot) < MySniperConstants.SHOT_INTERVAL_IN_MILISECONDS && !IsDummy)
            {
                return(false);
            }

            MyAmmoProperties ammoProperties = MyAmmoConstants.GetAmmoProperties(usedAmmo.AmmoType);

            AddProjectile(ammoProperties, this);

            m_lastTimeShoot = MyMinerGame.TotalGamePlayTimeInMilliseconds;
            AddWeaponCue(ammoProperties.ShotSound);

            if (SysUtils.MyMwcFinalBuildConstants.ENABLE_TRAILER_SAVE)
            {
                MinerWars.AppCode.Game.Trailer.MyTrailerSave.UpdateGunShot(this.Parent, Trailer.MyTrailerGunsShotTypeEnum.PROJECTILE);
            }

            MyParticleEffect startEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_SmallGunShot);

            startEffect.WorldMatrix = Matrix.CreateWorld(GetMuzzlePosition(), GetForward(), GetUp());

            return(true);
        }
        public override bool Shot(MyMwcObjectBuilder_SmallShip_Ammo usedAmmo)
        {
            if (usedAmmo == null || (MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot) < MyMachineGunConstants.SHOT_INTERVAL_IN_MILISECONDS && !IsDummy) return false;

            if (m_smokeEffect == null)
            {
                if (MyCamera.GetDistanceWithFOV(GetPosition()) < 150)
                {
                    m_smokeEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_Autocannon);
                    m_smokeEffect.WorldMatrix = WorldMatrix;
                    m_smokeEffect.OnDelete += OnSmokeEffectDelete;
                }
            }

            MyAmmoProperties ammoProperties = MyAmmoConstants.GetAmmoProperties(usedAmmo.AmmoType);

            if (MyMwcFinalBuildConstants.ENABLE_TRAILER_SAVE)
            {
                MinerWars.AppCode.Game.Trailer.MyTrailerSave.UpdateGunShot(this.Parent, Trailer.MyTrailerGunsShotTypeEnum.PROJECTILE);
            }

            AddProjectile(ammoProperties, this);

            m_lastTimeShoot = MyMinerGame.TotalGamePlayTimeInMilliseconds;
            StartLoopSound(ammoProperties.ShotSound);

            return true;
        }
Exemple #4
0
        public override bool Shot(MyMwcObjectBuilder_SmallShip_Ammo usedAmmo)
        {
            if (usedAmmo == null || (MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot) < MyMachineGunConstants.SHOT_INTERVAL_IN_MILISECONDS && !IsDummy)
            {
                return(false);
            }

            if (m_smokeEffect == null)
            {
                if (MyCamera.GetDistanceWithFOV(GetPosition()) < 150)
                {
                    m_smokeEffect             = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_Autocannon);
                    m_smokeEffect.WorldMatrix = WorldMatrix;
                    m_smokeEffect.OnDelete   += OnSmokeEffectDelete;
                }
            }

            MyAmmoProperties ammoProperties = MyAmmoConstants.GetAmmoProperties(usedAmmo.AmmoType);

            if (MyMwcFinalBuildConstants.ENABLE_TRAILER_SAVE)
            {
                MinerWars.AppCode.Game.Trailer.MyTrailerSave.UpdateGunShot(this.Parent, Trailer.MyTrailerGunsShotTypeEnum.PROJECTILE);
            }

            AddProjectile(ammoProperties, this);

            m_lastTimeShoot = MyMinerGame.TotalGamePlayTimeInMilliseconds;
            StartLoopSound(ammoProperties.ShotSound);

            return(true);
        }
 public static void Add(Vector3 position, Vector3 initialVelocity, Vector3 direction, MyMwcObjectBuilder_SmallShip_Ammo usedAmmo, MySmallShip ignoreMinerShip)
 {
     MyCannonShot newMissile = m_missiles.Allocate();
     if (newMissile != null)
     {
         newMissile.Start(position, initialVelocity, direction, usedAmmo, ignoreMinerShip);
     }
 }
Exemple #6
0
        public override bool Shot(MyMwcObjectBuilder_SmallShip_Ammo usedAmmo)
        {
            if (usedAmmo == null || (MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot) < MyShotgunConstants.SHOT_INTERVAL_IN_MILISECONDS && !IsDummy) return false;

            MyAmmoProperties ammoProperties = MyAmmoConstants.GetAmmoProperties(usedAmmo.AmmoType);
          
            FireShotGunShot(ammoProperties);
            
            return true;
        }
Exemple #7
0
        public override bool Shot(MyMwcObjectBuilder_SmallShip_Ammo usedAmmo)
        {
            if (!base.Shot(usedAmmo))
            {
                return(false);
            }


            return(true);
        }
        //  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_lastTimeStarted) < MyPressureDrillDeviceConstants.SHOT_INTERVAL_IN_MILISECONDS)
                return false;

            if (!base.Shot(usedAmmo))
                return false;

            m_state = PressureState.Init;

            return true;
        }
Exemple #9
0
        public override bool Shot(MyMwcObjectBuilder_SmallShip_Ammo usedAmmo)
        {
            if (usedAmmo == null || (MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot) < MyShotgunConstants.SHOT_INTERVAL_IN_MILISECONDS && !IsDummy)
            {
                return(false);
            }

            MyAmmoProperties ammoProperties = MyAmmoConstants.GetAmmoProperties(usedAmmo.AmmoType);

            FireShotGunShot(ammoProperties);

            return(true);
        }
Exemple #10
0
        private void AddSmallShipAmmoItems(MyTreeViewItem parentItem)
        {
            Vector2 itemSize = MyGuiManager.GetNormalizedSizeFromScreenSize(new Vector2(64, 64));

            foreach (MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum enumValue in MyGuiSmallShipHelpers.MyMwcObjectBuilder_SmallShip_Ammo_TypesEnumValues)
            {
                MyMwcObjectBuilder_SmallShip_Ammo ammoObjectBuilder     = new MyMwcObjectBuilder_SmallShip_Ammo(enumValue);
                MyBuildingSpecification           buildingSpecification = MyBuildingSpecifications.GetBuildingSpecification(ammoObjectBuilder);
                if (buildingSpecification != null)
                {
                    MyGuiSmallShipHelperAmmo smallShipAmmoHelper = MyGuiObjectBuilderHelpers.GetGuiHelper(MyMwcObjectBuilderTypeEnum.SmallShip_Ammo, (int)enumValue) as MyGuiSmallShipHelperAmmo;
                    AddTreeViewItem(parentItem, smallShipAmmoHelper.Description, smallShipAmmoHelper.Icon, itemSize, MyGuiManager.GetBlankTexture(), MyGuiManager.GetBlankTexture(), MyGuiConstants.CHECKBOX_SIZE, ammoObjectBuilder, buildingSpecification);
                }
            }
        }
        //  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_lastTimeStarted) < MyPressureDrillDeviceConstants.SHOT_INTERVAL_IN_MILISECONDS)
            {
                return(false);
            }

            if (!base.Shot(usedAmmo))
            {
                return(false);
            }

            m_state = PressureState.Init;

            return(true);
        }
Exemple #12
0
        //  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 (CurrentState == MyHarvestingDeviceEnum.InVoxel)
            {
                StartReturningBack();
            }
            else if (CurrentState == MyHarvestingDeviceEnum.InsideShip)
            {
                StartFindingVoxel();
            }
            else
            {
                StartFastReturningBack();
            }

            return(true);
        }
Exemple #13
0
        public override bool Shot(MyMwcObjectBuilder_SmallShip_Ammo usedAmmo)
        {
            if (MySession.Is25DSector)
            {
                CurrentState = MyDrillStateEnum.Activated;
            }

            if (!m_fullyEjected || GetParentMinerShip().Fuel <= 0 || !GetParentMinerShip().Config.Engine.On)
            {
                return(false);
            }

            m_lastTimeStarted = MyMinerGame.TotalGamePlayTimeInMilliseconds;
            CurrentState      = MyDrillStateEnum.Drilling;

            return(true);
        }
Exemple #14
0
        public override bool Shot(MyMwcObjectBuilder_SmallShip_Ammo usedAmmo)
        {
            if (usedAmmo == null || (MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot) < MySniperConstants.SHOT_INTERVAL_IN_MILISECONDS && !IsDummy) 
                return false;

            MyAmmoProperties ammoProperties = MyAmmoConstants.GetAmmoProperties(usedAmmo.AmmoType);

            AddProjectile(ammoProperties, this);

            m_lastTimeShoot = MyMinerGame.TotalGamePlayTimeInMilliseconds;
            AddWeaponCue(ammoProperties.ShotSound);

            if (SysUtils.MyMwcFinalBuildConstants.ENABLE_TRAILER_SAVE)
            {
                MinerWars.AppCode.Game.Trailer.MyTrailerSave.UpdateGunShot(this.Parent, Trailer.MyTrailerGunsShotTypeEnum.PROJECTILE);
            }

            MyParticleEffect startEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_SmallGunShot);
            startEffect.WorldMatrix = Matrix.CreateWorld(GetMuzzlePosition(), GetForward(), GetUp());

            return true;
        }
        //  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 (GetParentMinerShip() == null)
            {
                return false;
            }

            //  Allow shoting only at intervals
            if ((MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot) < MyAutocanonConstants.SHOT_INTERVAL_IN_MILISECONDS && !IsDummy) return false;
            //  Stop 'release cue' if playing
            MySoundCue? autocanonReleaseCue = GetParentMinerShip().UnifiedWeaponCueGet(AUTOCANON_RELEASE);
            if ((autocanonReleaseCue != null) && (autocanonReleaseCue.Value.IsPlaying == true))
            {
                autocanonReleaseCue.Value.Stop(SharpDX.XACT3.StopFlags.Immediate);
            }

            //  Angle of muzzle flash particle
            m_muzzleFlashLength = MyMwcUtils.GetRandomFloat(3, 4) * m_barrel.GetMuzzleSize();
            m_muzzleFlashRadius = MyMwcUtils.GetRandomFloat(1.8f, 2.2f) * m_barrel.GetMuzzleSize();

            //  Increase count of smokes to draw
            SmokesToGenerateIncrease();

            //Use looping cue only in playership
            MySoundCuesEnum attackCue = GetParentMinerShip() == MySession.PlayerShip ? AUTOCANON_ATTACK_LOOP : AUTOCANON_ATTACK;

            //  Start 'attack and loop' cue (shooting)
            MySoundCue? autocanonAttackLoopCue = GetParentMinerShip().UnifiedWeaponCueGet(attackCue);
            if ((autocanonAttackLoopCue == null) || (autocanonAttackLoopCue.Value.IsPlaying == false))
            {
                //MyMwcLog.WriteLine("Adding new AUTOCANNON attack loop");
                GetParentMinerShip().UnifiedWeaponCueSet(
                    attackCue,
                    MyAudio.AddCue2dOr3d(GetParentMinerShip(), attackCue,
                    m_positionMuzzleInWorldSpace, WorldMatrix.Forward, WorldMatrix.Up, Parent.Physics.LinearVelocity));
            }

            MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum ammoType = MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic;
            if (usedAmmo != null) //TODO: bot fires without ammo
            {
                ammoType = usedAmmo.AmmoType;
            }

            MyAmmoProperties ammoProperties = MyAmmoConstants.GetAmmoProperties(ammoType);

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyAutocannonGun.Shot add projectile");

            if(MyMwcFinalBuildConstants.ENABLE_TRAILER_SAVE)
            {
                MinerWars.AppCode.Game.Trailer.MyTrailerSave.UpdateGunShot(this.Parent, Trailer.MyTrailerGunsShotTypeEnum.PROJECTILE);
            }

            AddProjectile(ammoProperties, this);
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

            m_cannonMotorEndPlayed = false;
            m_lastTimeShoot = MyMinerGame.TotalGamePlayTimeInMilliseconds;

            //  We shot one projectile
            return true;
        }
        public override bool Shot(MyMwcObjectBuilder_SmallShip_Ammo usedAmmo)
        {
            if (usedAmmo == null || (MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot) < UNIVERSAL_LAUNCHER_SHOT_INTERVAL_IN_MILISECONDS && !IsDummy)
            {
                return(false);
            }

            bool shot = false;

            switch (usedAmmo.AmmoType)
            {
            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Smart:
                shot = Shot <MyMineSmart>();
                break;

            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Basic:
                shot = Shot <MyMineBasic>();
                break;

            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_BioChem:
                shot = Shot <MyMineBioChem>();
                break;

            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Sphere_Explosive:
                shot = Shot <MySphereExplosive>();
                break;

            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Decoy_Flare:
                shot = Shot <MyDecoyFlare>();
                break;

            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Flash_Bomb:
                shot = Shot <MyFlashBomb>();
                break;

            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Illuminating_Shell:
                shot = Shot <MyIlluminatingShell>();
                break;

            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Smoke_Bomb:
                shot = Shot <MySmokeBomb>();
                break;

            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Asteroid_Killer:
                shot = Shot <MyAsteroidKiller>();
                break;

            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Directional_Explosive:
                shot = Shot <MyDirectionalExplosive>();
                break;

            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Time_Bomb:
                shot = Shot <MyTimeBomb>();
                break;

            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Remote_Bomb:
                shot = Shot <MyRemoteBomb>();
                break;

            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Hologram:
                shot = Shot <MyHologram>();
                break;

            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Gravity_Bomb:
                shot = Shot <MyGravityBomb>();
                break;

            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Remote_Camera:
                shot = Shot <MyRemoteCamera>();
                break;

            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_EMP_Bomb:
                shot = Shot <MyEMPBomb>();
                break;
            }

            if (!shot)
            {
                return(false);
            }

            AddWeaponCue(MySoundCuesEnum.WepUnivLaunch3d);

            var smokeEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_SmallGunShot);

            smokeEffect.WorldMatrix = Matrix.CreateWorld(m_positionMuzzleInWorldSpace, WorldMatrix.Forward, WorldMatrix.Up);

            m_lastTimeShoot = MyMinerGame.TotalGamePlayTimeInMilliseconds;
            return(true);
        }
Exemple #17
0
        private void Shot(int timeToActivateShell, MyMwcObjectBuilder_SmallShip_Ammo ammoBuilder)
        {
            switch (ammoBuilder.AmmoType)
            {
            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Smart:
                Shot <MyMineSmart>(this.GetPosition(), timeToActivateShell);
                break;

            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Basic:
                Shot <MyMineBasic>(this.GetPosition(), timeToActivateShell);
                break;

            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_BioChem:
                Shot <MyMineBioChem>(this.GetPosition(), timeToActivateShell);
                break;

            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Sphere_Explosive:
                Shot <MySphereExplosive>(this.GetPosition(), timeToActivateShell);
                break;

            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Decoy_Flare:
                Shot <MyDecoyFlare>(this.GetPosition(), timeToActivateShell);
                break;

            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Flash_Bomb:
                Shot <MyFlashBomb>(this.GetPosition(), timeToActivateShell);
                break;

            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Illuminating_Shell:
                Shot <MyIlluminatingShell>(this.GetPosition(), timeToActivateShell);
                break;

            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Smoke_Bomb:
                Shot <MySmokeBomb>(this.GetPosition(), timeToActivateShell);
                break;

            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Asteroid_Killer:
                Shot <MyAsteroidKiller>(this.GetPosition(), timeToActivateShell);
                break;

            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Directional_Explosive:
                Shot <MyDirectionalExplosive>(this.GetPosition(), timeToActivateShell);
                break;

            //case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Time_Bomb:
            //    Shot<MyTimeBomb>(this.GetPosition(), 3000);
            //    break;

            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Remote_Bomb:
                Shot <MyRemoteBomb>(this.GetPosition(), timeToActivateShell);
                break;

            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Hologram:
                Shot <MyHologram>(this.GetPosition(), timeToActivateShell);
                break;

            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Gravity_Bomb:
                Shot <MyGravityBomb>(this.GetPosition(), timeToActivateShell);
                break;

            //case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Remote_Camera:
            //    Shot<MyRemoteCamera>(this.GetPosition(), timeToActivateShell);
            //    break;

            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_EMP_Bomb:
                Shot <MyEMPBomb>(this.GetPosition(), timeToActivateShell);
                break;
            }
        }
        //  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 (CurrentState == MyHarvestingDeviceEnum.InVoxel)
            {
                StartReturningBack();
            }
            else if (CurrentState == MyHarvestingDeviceEnum.InsideShip)
            {
                StartFindingVoxel();
            }
            else
            {
                StartFastReturningBack();
            }

            return true;
        }
Exemple #19
0
        public override bool Shot(MyMwcObjectBuilder_SmallShip_Ammo usedAmmo)
        {
            if (MySession.Is25DSector)
            {
                CurrentState = MyDrillStateEnum.Activated;
            }

            if (!m_fullyEjected || GetParentMinerShip().Fuel <= 0 || !GetParentMinerShip().Config.Engine.On)
                return false;

            m_lastTimeStarted = MyMinerGame.TotalGamePlayTimeInMilliseconds;
            CurrentState = MyDrillStateEnum.Drilling;

            return true;
        }
        //  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)
        {
            LastShotId = null;
            float missileLauncherShotInterval = float.MaxValue;

            switch (usedAmmo.AmmoType)
            {
                case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic:
                case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_BioChem:
                case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_EMP:
                case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Engine_Detection:
                case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Radar_Detection:
                case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Visual_Detection:
                    missileLauncherShotInterval = MyGuidedMissileConstants.MISSILE_LAUNCHER_SHOT_INTERVAL_IN_MILISECONDS;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
            }

            if ((MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot) < missileLauncherShotInterval && !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);

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


            //  Create and fire missile - but deviate missile direction be random angle
            Vector3 deviatedVector = GetDeviatedVector(MinerWars.AppCode.Game.Gameplay.MyAmmoConstants.GetAmmoProperties(usedAmmo.AmmoType));

            // correct missile start position if it would intersect some entity
            Vector3 missileStartPosition = m_positionMuzzleInWorldSpace;
            missileStartPosition = CorrectPosition(missileStartPosition, deviatedVector, Parent);

            if (MinerWars.AppCode.Game.Managers.Session.MySession.Static.Is2DSector)
            {
                forwardVelocity.Y = 0;
                deviatedVector.Y = 0;
            }

            var missile = MyMissiles.Add(usedAmmo.AmmoType, missileStartPosition, forwardVelocity, deviatedVector, LocalMatrix.Translation, Parent, ((MySmallShip)Parent).TargetEntity, isDummy: this.IsDummy);
            if (missile != null)
            {
                missile.EntityId = MyEntityIdentifier.AllocateId();
                MyEntityIdentifier.AddEntityWithId(missile);
                LastShotId = missile.EntityId;
                GetParentMinerShip().LastMissileFired = missile;
            }
            //MyUtilRandomVector3ByDeviatingVector.GetRandom(WorldMatrix.Forward

            m_lastTimeShoot = MyMinerGame.TotalGamePlayTimeInMilliseconds;
            m_lastSmokePosition = GetSmokePosition();

            if (SysUtils.MyMwcFinalBuildConstants.ENABLE_TRAILER_SAVE)
            {
                MinerWars.AppCode.Game.Trailer.MyTrailerSave.UpdateGunShot(this.Parent, Trailer.MyTrailerGunsShotTypeEnum.MISSILE);
            }

            //  We shot one missile
            return true;
        }
Exemple #21
0
        //  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 (GetParentMinerShip() == null)
            {
                return(false);
            }

            //  Allow shoting only at intervals
            if ((MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot) < MyAutocanonConstants.SHOT_INTERVAL_IN_MILISECONDS && !IsDummy)
            {
                return(false);
            }
            //  Stop 'release cue' if playing
            MySoundCue?autocanonReleaseCue = GetParentMinerShip().UnifiedWeaponCueGet(AUTOCANON_RELEASE);

            if ((autocanonReleaseCue != null) && (autocanonReleaseCue.Value.IsPlaying == true))
            {
                autocanonReleaseCue.Value.Stop(SharpDX.XACT3.StopFlags.Immediate);
            }

            //  Angle of muzzle flash particle
            m_muzzleFlashLength = MyMwcUtils.GetRandomFloat(3, 4) * m_barrel.GetMuzzleSize();
            m_muzzleFlashRadius = MyMwcUtils.GetRandomFloat(1.8f, 2.2f) * m_barrel.GetMuzzleSize();

            //  Increase count of smokes to draw
            SmokesToGenerateIncrease();

            //Use looping cue only in playership
            MySoundCuesEnum attackCue = GetParentMinerShip() == MySession.PlayerShip ? AUTOCANON_ATTACK_LOOP : AUTOCANON_ATTACK;

            //  Start 'attack and loop' cue (shooting)
            MySoundCue?autocanonAttackLoopCue = GetParentMinerShip().UnifiedWeaponCueGet(attackCue);

            if ((autocanonAttackLoopCue == null) || (autocanonAttackLoopCue.Value.IsPlaying == false))
            {
                //MyMwcLog.WriteLine("Adding new AUTOCANNON attack loop");
                GetParentMinerShip().UnifiedWeaponCueSet(
                    attackCue,
                    MyAudio.AddCue2dOr3d(GetParentMinerShip(), attackCue,
                                         m_positionMuzzleInWorldSpace, WorldMatrix.Forward, WorldMatrix.Up, Parent.Physics.LinearVelocity));
            }

            MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum ammoType = MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic;

            if (usedAmmo != null) //TODO: bot fires without ammo
            {
                ammoType = usedAmmo.AmmoType;
            }

            MyAmmoProperties ammoProperties = MyAmmoConstants.GetAmmoProperties(ammoType);

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyAutocannonGun.Shot add projectile");

            if (MyMwcFinalBuildConstants.ENABLE_TRAILER_SAVE)
            {
                MinerWars.AppCode.Game.Trailer.MyTrailerSave.UpdateGunShot(this.Parent, Trailer.MyTrailerGunsShotTypeEnum.PROJECTILE);
            }

            AddProjectile(ammoProperties, this);
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

            m_cannonMotorEndPlayed = false;
            m_lastTimeShoot        = MyMinerGame.TotalGamePlayTimeInMilliseconds;

            //  We shot one projectile
            return(true);
        }
        //  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;
        }
Exemple #23
0
        //  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)
        {
            LastShotId = null;
            float missileLauncherShotInterval = float.MaxValue;

            switch (usedAmmo.AmmoType)
            {
            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic:
            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_BioChem:
            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_EMP:
            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Engine_Detection:
            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Radar_Detection:
            case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Visual_Detection:
                missileLauncherShotInterval = MyGuidedMissileConstants.MISSILE_LAUNCHER_SHOT_INTERVAL_IN_MILISECONDS;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if ((MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot) < missileLauncherShotInterval && !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);

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


            //  Create and fire missile - but deviate missile direction be random angle
            Vector3 deviatedVector = GetDeviatedVector(MinerWars.AppCode.Game.Gameplay.MyAmmoConstants.GetAmmoProperties(usedAmmo.AmmoType));

            // correct missile start position if it would intersect some entity
            Vector3 missileStartPosition = m_positionMuzzleInWorldSpace;

            missileStartPosition = CorrectPosition(missileStartPosition, deviatedVector, Parent);

            if (MinerWars.AppCode.Game.Managers.Session.MySession.Static.Is2DSector)
            {
                forwardVelocity.Y = 0;
                deviatedVector.Y  = 0;
            }

            var missile = MyMissiles.Add(usedAmmo.AmmoType, missileStartPosition, forwardVelocity, deviatedVector, LocalMatrix.Translation, Parent, ((MySmallShip)Parent).TargetEntity, isDummy: this.IsDummy);

            if (missile != null)
            {
                missile.EntityId = MyEntityIdentifier.AllocateId();
                MyEntityIdentifier.AddEntityWithId(missile);
                LastShotId = missile.EntityId;
                GetParentMinerShip().LastMissileFired = missile;
            }
            //MyUtilRandomVector3ByDeviatingVector.GetRandom(WorldMatrix.Forward

            m_lastTimeShoot     = MyMinerGame.TotalGamePlayTimeInMilliseconds;
            m_lastSmokePosition = GetSmokePosition();

            if (SysUtils.MyMwcFinalBuildConstants.ENABLE_TRAILER_SAVE)
            {
                MinerWars.AppCode.Game.Trailer.MyTrailerSave.UpdateGunShot(this.Parent, Trailer.MyTrailerGunsShotTypeEnum.MISSILE);
            }

            //  We shot one missile
            return(true);
        }
Exemple #24
0
 //  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 abstract bool Shot(MyMwcObjectBuilder_SmallShip_Ammo usedAmmo);
Exemple #25
0
 //  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 abstract bool Shot(MyMwcObjectBuilder_SmallShip_Ammo usedAmmo);
        public static void Add(Vector3 position, Vector3 initialVelocity, Vector3 direction, MyMwcObjectBuilder_SmallShip_Ammo usedAmmo, MySmallShip ignoreMinerShip)
        {
            MyCannonShot newMissile = m_missiles.Allocate();

            if (newMissile != null)
            {
                newMissile.Start(position, initialVelocity, direction, usedAmmo, ignoreMinerShip);
            }
        }