static string GetRandomBackgroundTexture() { int randomNumber = MyMwcUtils.GetRandomInt(MyGuiConstants.LOADING_RANDOM_SCREEN_INDEX_MIN, MyGuiConstants.LOADING_RANDOM_SCREEN_INDEX_MAX + 1); string paddedNumber = randomNumber.ToString().PadLeft(3, '0'); return("Textures\\GUI\\LoadingScreen\\Background" + paddedNumber); }
public override void Load() { base.Load(); MissionTimer.RegisterTimerAction(MyMwcUtils.GetRandomInt(3000, 5000), m_shakeAction, true); doorDetector1 = MyScriptWrapper.GetDetector(MyScriptWrapper.GetEntity(367)); doorDetector1.OnEntityEnter += DoorDetector1Open; doorDetector1.On(); doorDetector2 = MyScriptWrapper.GetDetector(MyScriptWrapper.GetEntity(366)); doorDetector2.OnEntityEnter += DoorDetector2Closed; doorDetector2.On(); for (int i = 0; i < mines.GetLength(0); i++) { MyEntityDetector mineDetector = MyScriptWrapper.GetDetector(mines[i, 1]); mineDetector.OnEntityEnter += new OnEntityEnter(mineDetector_OnEntityEnter); mineDetector.OnEntityPositionChange += new OnEntityPositionChange(mineDetector_OnEntityPositionChange); mineDetector.On(); } MyScriptWrapper.OnBotReachedWaypoint += OnBotReachedWaypoint; MyScriptWrapper.OnSpawnpointBotSpawned += OnSpawnpointBotSpawned; //aliendetector MyScriptWrapper.Highlight(RadarEntity, true, this); MyScriptWrapper.EnablePhysics(RadarEntity, false); //aliendetector MyScriptWrapper.Highlight(1962, true, this); MyScriptWrapper.EnablePhysics(1962, false); }
private void MeteorAction() { MyScriptWrapper.EnableGlobalEvent(World.Global.MyGlobalEventEnum.MeteorWind, true); MissionTimer.RegisterTimerAction(MyMwcUtils.GetRandomInt(2000, 4000), MeteorAction, false); //MyScriptWrapper.GenerateMeteor(100, MySession.PlayerShip.GetPosition() + MySession.PlayerShip.WorldMatrix.Forward * 500, MyMwcVoxelMaterialsEnum.Lava_01, MySession.PlayerShip.WorldMatrix.Forward * -1000, MyParticleEffectsIDEnum.MeteorTrail_FireAndSmoke); }
public MyGameExtendedInfo(MyGameInfo gameInfo) { GameInfo = gameInfo; Ping = MyMwcUtils.GetRandomInt(10, 20); SectorType = MySectorType.Official; GameType = gameInfo.GameType; }
// Update an explosion objects // Explosions blinks and then wait some time // After the explosion dissapears, it will move to a nearby location and // repeat private void updateExplosion() { if (m_fading && !m_IsWaiting) { Color.W -= MyDistantObjectsImpostorsConstants.EXPLOSION_FADE * m_blinkMultiplierDown; } else if (m_exploding) { Color.W += MyDistantObjectsImpostorsConstants.EXPLOSION_FADE * m_blinkMultiplierUp; } Radius = MathHelper.Lerp(m_startingRadius / 4f, m_startingRadius, Color.W); if (Color.W <= 0) { m_IsWaiting = true; Color.W = MathHelper.Clamp(Color.W, 0, 1); Color.X = 0; Color.Y = 0; Color.Z = 0; if (m_glowTime > m_explosionDelay) { float minNewHorizontal = m_targetHorizontal - (MyDistantObjectsImpostorsConstants.EXPLOSION_MOVE_DISTANCE * MyMwcUtils.GetRandomInt(4, 7)); float maxNewHorizontal = m_targetHorizontal + (MyDistantObjectsImpostorsConstants.EXPLOSION_MOVE_DISTANCE * MyMwcUtils.GetRandomInt(4, 7)); float minNewVertical = m_targetVertical - (MyDistantObjectsImpostorsConstants.EXPLOSION_MOVE_DISTANCE * MyMwcUtils.GetRandomInt(4, 7)); float maxNewVertical = m_targetVertical + (MyDistantObjectsImpostorsConstants.EXPLOSION_MOVE_DISTANCE * MyMwcUtils.GetRandomInt(4, 7)); Color.X = MyMwcUtils.GetRandomFloat(170.0f / 255f, 1.0f); Color.Y = MyMwcUtils.GetRandomFloat(100.0f / 255f, 1.0f); Color.Z = MyMwcUtils.GetRandomFloat(0.0f, 40.0f / 255f); m_angleHorizontal = MyMwcUtils.GetRandomFloat(minNewHorizontal, maxNewHorizontal); m_angleVertical = MyMwcUtils.GetRandomFloat(minNewVertical, maxNewVertical); m_IsWaiting = false; m_exploding = true; m_fading = false; } } if (m_IsWaiting) { m_glowTime += MyConstants.PHYSICS_STEP_SIZE_IN_MILLISECONDS; } else { m_glowTime = 0; } if (Color.W >= 1f) { m_fading = true; m_exploding = false; Color.W = MathHelper.Clamp(Color.W, 0, 1); // We set delay time here to avoid unnecessarry logic for it m_explosionDelay = MyMwcUtils.GetRandomInt((int)(MyDistantObjectsImpostorsConstants.EXPLOSION_WAIT_MILLISECONDS / 3f), (int)(MyDistantObjectsImpostorsConstants.EXPLOSION_WAIT_MILLISECONDS * 3f)); } }
void BotSpawned(MyEntity spawnpoint, MyEntity bot) { //List<uint> { // (uint)EntityID.SpawnLastR, // (uint)EntityID.SpawnLastL, // (uint)EntityID.SpawnLastAsteroid, // (uint)EntityID.SpawnCenterL, // (uint)EntityID.SpawnCenterR } var attackerList = new List <uint> { (uint)EntityID.SpawnInR, (uint)EntityID.SpawnInL, (uint)EntityID.SpawnIn3, (uint)EntityID.SpawnIn4, (uint)EntityID.SpawnFrontL, (uint)EntityID.SpawnFrontR, (uint)EntityID.SpawnCenterL, (uint)EntityID.SpawnCenterR, (uint)EntityID.SpawnLastL, (uint)EntityID.SpawnLastR, (uint)EntityID.SpawnLastAsteroid, (uint)EntityID.SpawnLast1, (uint)EntityID.SpawnLast1_2, (uint)EntityID.SpawnLast2, (uint)EntityID.SpawnLast2_2, (uint)EntityID.SpawnLast3, (uint)EntityID.SpawnLast3_2, (uint)EntityID.SpawnLast4, }; foreach (var item in attackerList) { if (spawnpoint == MyScriptWrapper.GetEntity(item) && bot != null) { MyScriptWrapper.SetSleepDistance(bot as MySmallShipBot, 10000); var botShip = bot as MySmallShipBot; m_attackerBots.Add(botShip); //botShip.Attack(MyScriptWrapper.GetEntity((uint)m_transporterAttackPoints[MyMwcUtils.GetRandomInt(m_transporterAttackPoints.Count)])); } } foreach (var item in m_spawnCompanions) { if (spawnpoint == MyScriptWrapper.GetEntity(item)) { MySmallShipBot botship = bot as MySmallShipBot; //botship.SlowDown = 0.583f; botship.SpeedModifier = 0.583f * (MOTHERSHIP_SLOWSPEED / MOTHERSHIP_FULLSPEED); botship.IsDestructible = m_reassignBotTargets; if (m_reassignBotTargets) { bot.Kill(m_towers[MyMwcUtils.GetRandomInt(m_towers.Length)]); } } } }
// This method will start sun wind. Or if there is one coming, this will reset it so it will start again. public static void Start() { IsActive = true; //m_burningCue = MyAudio.AddCue3D(MySoundCuesEnum.SfxSolarWind, m_initialSunWindPosition, m_directionFromSunNormalized, Vector3.Up, Vector3.Zero); const int meteorsCount = 5; //const int frontDistance = 1000; //const int sideDistance = 3000; const int minSpeed = 1000; const int maxSpeed = 4000; //Vector3 sphereCenter = MyCamera.Position + MyCamera.ForwardVector * frontDistance - MyCamera.LeftVector * sideDistance; Vector3 sphereCenter = MyCamera.Position + MyGuiScreenGamePlay.Static.GetDirectionToSunNormalized() * 10000; //Vector3 windForwardDirection = MyCamera.LeftVector ; int i = 0; while (i < meteorsCount) { //float distance = MyMwcUtils.GetRandomFloat(0, sphereRadius); //Vector3 position = sphereCenter + MyMwcUtils.GetRandomVector3Normalized() * new Vector3(distance, distance, distance); //Vector3 meteorDirection = (windForwardDirection + (MyMwcUtils.GetRandomVector3Normalized() * 0.05f)) * MyMwcUtils.GetRandomInt(minSpeed, maxSpeed); //Vector3 meteorDirection = -MyGuiScreenGamePlay.Static.GetDirectionToSunNormalized();// MyMwcUtils.GetRandomVector3HemisphereNormalized(-MyGuiScreenGamePlay.Static.GetDirectionToSunNormalized()); Vector3 meteorDirection = MyMwcUtils.GetRandomVector3HemisphereNormalized(-MyGuiScreenGamePlay.Static.GetDirectionToSunNormalized()); Vector3 position = sphereCenter + meteorDirection * MyMwcUtils.GetRandomInt(100, 5000); //float normalizedDistance = distance / sphereRadius; float size = MyMwcUtils.GetRandomInt(minSize, maxSize); MyLine line = new MyLine(position, position + meteorDirection * 100); MyIntersectionResultLineBoundingSphere?result = MyEntities.GetIntersectionWithLineAndBoundingSphere(ref line, null, null, 1, null, true); if (result != null) { //Do not create meteors colliding with base if (!(result.Value.PhysObject is MyMeteor)) { continue; } } Matrix worldMatrix = Matrix.CreateFromAxisAngle(MyMwcUtils.GetRandomVector3Normalized(), MyMwcUtils.GetRandomFloat(0, MathHelper.Pi)); worldMatrix.Translation = position; MyMeteor meteor = MyMeteor.GenerateMeteor(size, worldMatrix, position, m_fireMeteorMaterials[MyMwcUtils.GetRandomInt(0, m_fireMeteorMaterials.Count)]); float speed = MyMwcUtils.GetRandomInt(minSpeed, maxSpeed); meteor.Start(meteorDirection * speed, MyMwcUtils.GetRandomFloat(0, 1) > 0.92f ? 101 : 100); i++; } }
/// <summary> /// Starts, or resumes, measuring elapsed time for an interval. /// </summary> public void Start() { if (!m_isRunning) { m_startTime = MyMinerGame.TotalGamePlayTimeInMilliseconds; } m_isRunning = true; m_currentTimeInterval = MyMwcUtils.GetRandomInt(MinTimeMilliseconds, MaxTimeMilliseconds); }
public override void ApplyVariance(ref int interpolatedValue, ref int variance, float multiplier, out int value) { if ((variance != 0) || (multiplier != 1)) { interpolatedValue = (int)(MyMwcUtils.GetRandomInt(interpolatedValue - variance, interpolatedValue + variance) * multiplier); } value = interpolatedValue; }
private void PlayBehindDialogue() { if (MyMwcUtils.GetRandomFloat(0, 1) < DialogPorobability) { if (BehindDialogs != null) { MyScriptWrapper.PlayDialogue(BehindDialogs[MyMwcUtils.GetRandomInt(0, BehindDialogs.Count - 1)]); } } }
private static MyMwcObjectBuilder_FactionEnum?GetRandomDetectedFaction() { MyMwcObjectBuilder_FactionEnum?randomDetectedFaction = null; if (m_detectedFactions.Count > 0) { int randomFactionIndex = MyMwcUtils.GetRandomInt(m_detectedFactions.Count - 1); randomDetectedFaction = m_detectedFactions[randomFactionIndex]; } return(randomDetectedFaction); }
private void RiftReached(MyEntityDetector sender, MyEntity entity, int meetCriterias) { if (entity == MySession.PlayerShip) { //MyAudio.ApplyTransition(MyMusicTransitionEnum.Mystery); // start shakes m_riftShake = true; MissionTimer.RegisterTimerAction(MyMwcUtils.GetRandomInt(4000, 12000), m_farExplosionAction, false); } }
private void AddUnusedSector() { if (m_startSessionType == MyMwcStartSessionRequestTypeEnum.EDITOR_SANDBOX && m_sectors[0].UserId == null) { MyMwcVector3Int position; do { position = new MyMwcVector3Int(MyMwcUtils.GetRandomInt(-100, 100), 0, MyMwcUtils.GetRandomInt(-100, 100)); } while (m_sectors.Any(s => s.Position == position)); m_sectors.Add(new MyMwcSectorIdentifier(MyMwcSectorTypeEnum.SANDBOX, null, position, "<unused>")); } }
private void PlayInFrontDialogue() { var rand = MyMwcUtils.GetRandomFloat(0, 1); if (rand < DialogPorobability) { if (FrontDialogs != null) { MyScriptWrapper.PlayDialogue(FrontDialogs[MyMwcUtils.GetRandomInt(0, FrontDialogs.Count - 1)]); } } }
private static MySoundCuesEnum GetRandomShout(MyMwcObjectBuilder_FactionEnum faction) { int index; List <MySoundCuesEnum> shouts = GetShouts(faction); do { index = MyMwcUtils.GetRandomInt(shouts.Count); } while (m_lastShoutCue.HasValue && shouts.Count > 1 && m_lastShoutCue.Value == shouts[index]); return(shouts[index]); }
public static MyMeteor CreateComet(Vector3 position, Vector3 direction) { float size = MyMwcUtils.GetRandomInt(m_sizeMin, m_sizeMax); Matrix worldMatrix = Matrix.CreateFromAxisAngle(MyMwcUtils.GetRandomVector3Normalized(), MyMwcUtils.GetRandomFloat(0, MathHelper.Pi)); worldMatrix.Translation = position; MyMeteor meteor = MyMeteor.GenerateMeteor(size, worldMatrix, position, m_iceMeteorMaterials[MyMwcUtils.GetRandomInt(0, m_iceMeteorMaterials.Count)]); meteor.Start(direction, 953); return(meteor); }
// Start shooting on the presented target in the queue: public override bool StartShooting() { // start shooting this kind of ammo ... if (!base.StartShooting()) { return(false); } if ((MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot) < (MyMachineGunConstants.SHOT_INTERVAL_IN_MILISECONDS /* * 0.75f*/)) { return(false); } // Set muzzle flashes: m_muzzleFlashLength = MyMwcUtils.GetRandomFloat(4, 6); m_muzzleFlashRadius = MyMwcUtils.GetRandomFloat(1.2f, 2.0f); // Increse smoke to generate IncreaseSmoke(); // Make random trajectories for the bullet: Matrix worldMatrix = WorldMatrix; // get muzzel flash positions: List <MyModelDummy> muzzles = GetMuzzleFlashMatrix(); m_activeMuzzle = muzzles.Count == 1 ? 0 : MyMwcUtils.GetRandomInt(muzzles.Count); m_muzzleFlashPosition = MyUtils.GetTransform(muzzles[m_activeMuzzle].Matrix.Translation, ref worldMatrix); if (m_shotSmoke == null) { m_shotSmoke = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_LargeGunShot); m_shotSmoke.AutoDelete = false; } m_shotSmoke.UserEmitterScale = m_smokeToGenerate; m_shotSmoke.WorldMatrix = Matrix.CreateTranslation(m_muzzleFlashPosition); m_shotSmoke.UserScale = 5; GetWeaponBase().PlayShootingSound(); // Shoot projectiles AddProjectile(MyAmmoConstants.GetAmmoProperties(GetAmmoType()), m_muzzleFlashPosition); // dont decrease ammo count ... m_lastTimeShoot = MyMinerGame.TotalGamePlayTimeInMilliseconds; return(true); }
private void FarExplosion() { // MainShake MyScriptWrapper.IncreaseHeadShake(MyMwcUtils.GetRandomInt(7, 10)); MyScriptWrapper.AddAudioImpShipQuake(); // Register sub shakes MissionTimer.RegisterTimerAction(MyMwcUtils.GetRandomInt(200, 400), m_subShakeAction, false); MissionTimer.RegisterTimerAction(MyMwcUtils.GetRandomInt(600, 800), m_subShakeAction, false); MissionTimer.RegisterTimerAction(MyMwcUtils.GetRandomInt(800, 1200), m_subShakeAction, false); MissionTimer.RegisterTimerAction(MyMwcUtils.GetRandomInt(1200, 1400), m_subShakeAction, false); // Register next far explosion MissionTimer.RegisterTimerAction(MyMwcUtils.GetRandomInt(3000, 5000), m_shakeAction, false); //TODO add particle effect }
public void UpdateShooting(int time) { if (m_nextShoot < time) { m_nextShoot = time + shootInterval; shootInterval = MyMwcUtils.GetRandomInt(0, 2000); m_shoot = !m_shoot; } if (m_shoot && m_botBehindRacer && Math.Abs(m_distanceToMe) > ShootDistance) { if (m_racer.Weapons != null) { m_racer.Shoot(MyMwcObjectBuilder_FireKeyEnum.Primary); } } }
public override void Load() { base.Load(); MissionTimer.RegisterTimerAction(MyMwcUtils.GetRandomInt(40000, 50000), SolarwindAction, false); MissionTimer.RegisterTimerAction(MyMwcUtils.GetRandomInt(4000, 5000), MeteorAction, false); m_riftShake = false; MyEntityDetector shakeDetector = MyScriptWrapper.GetDetector((uint)EntityID.Deterctor_shakes); shakeDetector.OnEntityEnter += RiftReached; shakeDetector.OnEntityLeave += RiftLeft; shakeDetector.On(); foreach (var detector in m_eruptionDetectors) { MyEntityDetector eruptionDetector = MyScriptWrapper.GetDetector(detector); eruptionDetector.OnEntityEnter += Erupt; eruptionDetector.On(); } /* * foreach (var detector in m_meteorDetectors) * { * MyEntityDetector MeteorDetector = MyScriptWrapper.GetDetector(detector); * MeteorDetector.OnEntityEnter += Meteorite; * MeteorDetector.On(); * } */ MySmallShipBot ravenGirl = (MySmallShipBot)MyScriptWrapper.GetEntity("RavenGirl"); MySmallShipBot ravenGuy = (MySmallShipBot)MyScriptWrapper.GetEntity("RavenGuy"); MyScriptWrapper.StopFollow(ravenGirl); MyScriptWrapper.StopFollow(ravenGuy); ravenGirl.LookTarget = MySession.PlayerShip; ravenGuy.LookTarget = MySession.PlayerShip; MyAudio.MusicAllowed = false; //to forbid action music caused by bot fight MissionTimer.RegisterTimerAction(1000, PlayActionMusic, false); }
public static void LoadAnimation() { MyMwcLog.WriteLine("MyTrailerLoad.LoadContent() - START"); MyMwcLog.IncreaseIndent(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyTrailerLoad::LoadAnimation"); if (!AnimationSelectedFromMenu) { MyTrailerXml res = LoadTrailerXml(); Animations = res.Animation; if (MyGuiScreenGamePlay.Static.IsMainMenuActive()) { SetTrailerAnimation(res.MainMenuAnimation); } else if (MyGuiScreenGamePlay.Static.IsGameActive()) { SetTrailerAnimation(res.GameAnimation); } else if (MyGuiScreenGamePlay.Static.IsFlyThroughActive()) { if (string.IsNullOrEmpty(res.FlyThroughOrCreditsAnimation)) { // Pick random animation if ((res.Animation != null) && (Animations.Length > 0)) { TrailerAnimation = res.Animation[MyMwcUtils.GetRandomInt(0, Animations.Length)]; } } else { SetTrailerAnimation(res.FlyThroughOrCreditsAnimation); } } } AnimationSelectedFromMenu = false; MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); MyMwcLog.DecreaseIndent(); MyMwcLog.WriteLine("MyTrailerLoad.LoadContent() - END"); }
public static MyMeteor GenerateMeteor(float sizeInMeters, Matrix worldMatrix, Vector3 position, MyMwcVoxelMaterialsEnum material) { int size = MySectorGenerator.FindAsteroidSize(sizeInMeters, MyMwcObjectBuilder_StaticAsteroid.AsteroidSizes); asteroids.Clear(); MyMwcObjectBuilder_Meteor.GetAsteroids(size, MyStaticAsteroidTypeSetEnum.A, asteroids); int rndIndex = MyMwcUtils.GetRandomInt(0, asteroids.Count); var builder = new MyMwcObjectBuilder_Meteor(asteroids[rndIndex], material); builder.PositionAndOrientation.Position = position; builder.PositionAndOrientation.Forward = MyMwcUtils.GetRandomVector3Normalized(); builder.PositionAndOrientation.Up = MyMwcUtils.GetRandomVector3Normalized(); builder.UseModelTechnique = false; MyMeteor meteor = (MyMeteor)MyEntities.CreateFromObjectBuilderAndAdd(null, builder, worldMatrix); meteor.m_size = sizeInMeters; return(meteor); }
// IMPORTANT: This class isn't realy inicialized by constructor, but by Start() // So don't initialize members here, do it in Start() public virtual void Init(MyModelsEnum modelLod0Enum, MyModelsEnum?modelLod1Enum, MyMaterialType materialType, float scale, List <MyRBElementDesc> collisionPrimitives, float mass) { MyPhysicsObjects physobj = MyPhysics.physicsSystem.GetPhysicsObjects(); base.Init(null, modelLod0Enum, modelLod1Enum, null, scale, null); m_maxLifeTimeInMiliseconds = MyMwcUtils.GetRandomInt(MyExplosionsConstants.EXPLOSION_DEBRIS_LIVING_MIN_IN_MILISECONDS, MyExplosionsConstants.EXPLOSION_DEBRIS_LIVING_MAX_IN_MILISECONDS); m_randomizedDiffuseTextureColorMultiplier = MyMwcUtils.GetRandomFloat(0.4f, 0.6f); m_initialOrientation = Matrix.CreateRotationX(MyMwcUtils.GetRandomRadian()) * Matrix.CreateRotationY(MyMwcUtils.GetRandomRadian()) * Matrix.CreateRotationZ(MyMwcUtils.GetRandomRadian()); // create physics this.Physics = new MyPhysicsBody(this, mass, 0) { MaterialType = materialType }; for (int i = 0; i < collisionPrimitives.Count; i++) { MyRBSphereElement sphereEl = (MyRBSphereElement)physobj.CreateRBElement(collisionPrimitives[i]); // sphereEl.Radius *= scale; this.Physics.AddElement(sphereEl, true); } }
public override void Update(MyMissionBase sender) { if (m_isFirstUpdate) { for (int i = 0; i < m_scannersStartTimes.Count; i++) { m_scannersStartTimes[i] = sender.MissionTimer.ElapsedTime + MyMwcUtils.GetRandomInt(0, 3) * 1000; } m_isFirstUpdate = false; } else { var index = 0; foreach (MyEntity scanner in m_scanners) { if (m_scannersStartTimes[index] < sender.MissionTimer.ElapsedTime) { scanner.Enabled = !scanner.Enabled; m_scannersStartTimes[index] = sender.MissionTimer.ElapsedTime + m_scannersUpdateTimes[index]; } index++; } } }
void PlanNextMissile() { m_planedMissileTime = MyMinerGame.TotalGamePlayTimeInMilliseconds + MyMwcUtils.GetRandomInt(3000, 6000); }
public override bool StartShooting() { if (!base.StartShooting()) { return(false); } if ((MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot) < MyAutocanonConstants.SHOT_INTERVAL_IN_MILISECONDS) { return(false); } // Set muzzle flashes: m_muzzleFlashLength = MyMwcUtils.GetRandomFloat(4, 6); m_muzzleFlashRadius = MyMwcUtils.GetRandomFloat(1.2f, 2.0f); // Increse smoke to generate IncreaseSmoke(); // Make random trajectories for the bullet: Matrix worldMatrix = WorldMatrix; // get muzzle flashes: List <MyModelDummy> muzzles = GetMuzzleFlashMatrix(); muzzleFlashPosition1 = MyUtils.GetTransform(muzzles[0].Matrix.Translation, ref worldMatrix); muzzleFlashPosition2 = MyUtils.GetTransform(muzzles[1].Matrix.Translation, ref worldMatrix); // if (!IsControlledByPlayer()) { if (m_shotSmoke == null) { m_shotSmoke = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_LargeGunShot); m_shotSmoke.AutoDelete = false; } m_shotSmoke.UserEmitterScale = m_smokeToGenerate; m_shotSmoke.WorldMatrix = Matrix.CreateTranslation(muzzleFlashPosition1); if (m_shotSmoke2 == null) { m_shotSmoke2 = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_LargeGunShot); m_shotSmoke2.AutoDelete = false; } m_shotSmoke2.UserEmitterScale = m_smokeToGenerate; m_shotSmoke2.WorldMatrix = Matrix.CreateTranslation(muzzleFlashPosition2); } int randSoundSource = MyMwcUtils.GetRandomInt(2); MySoundCue?shootingSound = GetWeaponBase().UnifiedWeaponCueGet(MySoundCuesEnum.WepMachineGunNormFire3d); if (shootingSound == null || !shootingSound.Value.IsPlaying) { GetWeaponBase().UnifiedWeaponCueSet(Audio.MySoundCuesEnum.WepMachineGunNormFire3d, MyAudio.AddCue2dOr3d(this.GetWeaponBase().PrefabParent, Audio.MySoundCuesEnum.WepMachineGunNormFire3d, randSoundSource == 1 ? muzzleFlashPosition1 : muzzleFlashPosition2, WorldMatrix.Forward, WorldMatrix.Up, Vector3.Zero)); //MyAudio.AddCue3D(Audio.MySoundCuesEnum.WepAutocanonFire3d, randSoundSource == 1 ? muzzleFlashPosition1 : muzzleFlashPosition2, WorldMatrix.Forward, WorldMatrix.Up, Vector3.Zero)); } AddProjectile(MyAmmoConstants.GetAmmoProperties(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic), muzzleFlashPosition1); AddProjectile(MyAmmoConstants.GetAmmoProperties(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic), muzzleFlashPosition2); m_lastTimeShoot = MyMinerGame.TotalGamePlayTimeInMilliseconds; return(true); }
public static void Update() { // Update only if sun wind is active if (IsActive == false) { return; } float darkeningPhase; float dt; int relTime = GetDarkeningPhase(out darkeningPhase, out dt); if (relTime > MaxTimeMs) { Clear(); return; } MyAudio.UpdateCuePosition(ambientSound, MyCamera.Position + MyCamera.ForwardVector * -MaxSoundDistance * (1 - darkeningPhase), MyCamera.ForwardVector, MyCamera.UpVector, Vector3.Zero); MyAudio.UpdateCueVolume(ambientSound, darkeningPhase * MaxAmbientVolume); // update smoke foreach (SmokeParticle part in smokeParticles) { Vector3 toCamera = (MyCamera.Position - part.Pos); toCamera.Normalize(); float alpha = darkeningPhase * MaxSmokeAlpha; part.Color = new Vector4(alpha, alpha, alpha, alpha); //part.Color.W = darkeningPhase; part.Pos += part.Velocity * dt + toCamera * CenterBias * dt; part.Angle += part.AngularVelocity * dt; } // remove old ice and sparks m_iceList.Clear(); foreach (IceParticle particle in iceParticles) { if (particle.StartTime + 4000 < relTime) { m_iceList.Add(particle); } } foreach (IceParticle ice in m_iceList) { ice.AsteroidEntity.MarkForClose(); Debug.Assert(ice.TrailEffect != null, "ice.TrailEffect != null"); ice.TrailEffect.Stop(); ice.TrailEffect = null; StopCue(ice.Sound); iceParticles.Remove(ice); } int c = 0; while (c < storms.Count) { ElectricStorm storm = storms[c]; if (storm.StartTime + 1500 < relTime) { storms.RemoveAt(c); continue; } c++; } // if its dark add new sparks and ice balls if (darkeningPhase >= 1) { if (storms.Count < MaxSparkCount && MyMwcUtils.GetRandomInt(SparkEveryMs) < dt * 1000.0f) { var storm = new ElectricStorm { Position = MyCamera.Position + MyCamera.ForwardVector * 250 + MyMwcUtils.GetRandomVector3HemisphereNormalized(MyCamera.ForwardVector) * MyMwcUtils.GetRandomFloat(0, 300), StartTime = relTime, Effect = MyParticlesManager.CreateParticleEffect( (int)MyParticleEffectsIDEnum.Damage_Sparks), }; storm.Effect.WorldMatrix = Matrix.CreateTranslation(storm.Position); storm.Effect.AutoDelete = true; storm.Effect.UserScale = 2; storm.Sound = MyAudio.AddCue2D(MySoundCuesEnum.SfxSpark); storms.Add(storm); } if (iceParticles.Count < MaxIceCount && MyMwcUtils.GetRandomInt(IceEveryMs) < dt * 1000.0f) { Vector3 dir = MyMwcUtils.GetRandomVector3HemisphereNormalized(MyCamera.ForwardVector); Vector3 pos = MyCamera.Position + MyCamera.ForwardVector * 250 + MyMwcUtils.GetRandomVector3Normalized() * MyMwcUtils.GetRandomFloat(0, 200) + dir * MyMwcUtils.GetRandomFloat(0, 500); MyMwcObjectBuilder_StaticAsteroid rockModel = MySectorGenerator.GenerateStaticAsteroid(MyMwcUtils.GetRandomFloat(0.1f, 2f), MyStaticAsteroidTypeSetEnum.A, MyMwcVoxelMaterialsEnum.Ice_01, pos, random, asteroidTypes); Matrix matrix = Matrix.CreateFromAxisAngle(MyMwcUtils.GetRandomVector3Normalized(), MyMwcUtils.GetRandomFloat(0, MathHelper.Pi)); matrix.Translation = pos; MyEntity asteroid = MyEntities.CreateFromObjectBuilderAndAdd(null, rockModel, matrix); asteroid.Physics.Enabled = false; asteroid.CastShadows = false; MyParticleEffect effect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_CannonShot); Vector3 velocity = -dir *MyMwcUtils.GetRandomInt(150, 400); iceParticles.Add(new IceParticle { StartTime = relTime, Position = pos, Direction = -dir, AsteroidEntity = asteroid, TrailEffect = effect, RotAxis = MyMwcUtils.GetRandomVector3Normalized(), RotAngle = MyMwcUtils.GetRandomRadian(), AngularVelocity = MyMwcUtils.GetRandomFloat(0.2f, 10f), Velocity = velocity, Sound = MyAudio.AddCue3D(MySoundCuesEnum.WepSniperHighFire2d, pos, dir, dir * -dir, velocity) }); } } // update ice parts foreach (IceParticle particle in iceParticles) { particle.RotAngle += particle.AngularVelocity * dt; particle.Position += particle.Velocity * dt; Matrix matrix = Matrix.CreateFromAxisAngle(particle.RotAxis, particle.RotAngle); matrix.Translation = particle.Position; particle.AsteroidEntity.SetWorldMatrix(matrix); Matrix trans = Matrix.CreateTranslation(-particle.Direction * 10); particle.TrailEffect.WorldMatrix = matrix * trans; MyAudio.UpdateCuePosition(particle.Sound, particle.Position, particle.Direction, particle.Direction * -particle.Direction, particle.Velocity); } lastUpdateMs = MyMinerGame.TotalGamePlayTimeInMilliseconds; }
/* * private void Meteorite(MyEntityDetector sender, MyEntity entity, int meetCriterias) * { * if (entity == MySession.PlayerShip) * { * MyScriptWrapper.GenerateMeteor(100, MySession.PlayerShip.GetPosition() + MySession.PlayerShip.WorldMatrix.Forward * 500, MyMwcVoxelMaterialsEnum.Lava_01, MySession.PlayerShip.WorldMatrix.Forward * -1000, MyParticleEffectsIDEnum.MeteorTrail_FireAndSmoke); * sender.Off(); * } * } */ private void SubShake() { MyScriptWrapper.IncreaseHeadShake(MyMwcUtils.GetRandomInt(3, 4)); }
private void SolarwindAction() { MyScriptWrapper.EnableGlobalEvent(World.Global.MyGlobalEventEnum.SunWind, true); MissionTimer.RegisterTimerAction(MyMwcUtils.GetRandomInt(5000, 40000), SolarwindAction, false); }
public static void LoadContent() { MyMwcLog.WriteLine("MySunWind.LoadContent() - START"); MyMwcLog.IncreaseIndent(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MySunwind::LoadContent"); // Large billboards m_largeBillboards = new MySunWindBillboard[MySunWindConstants.LARGE_BILLBOARDS_SIZE.X][]; for (int x = 0; x < MySunWindConstants.LARGE_BILLBOARDS_SIZE.X; x++) { m_largeBillboards[x] = new MySunWindBillboard[MySunWindConstants.LARGE_BILLBOARDS_SIZE.Y]; for (int y = 0; y < MySunWindConstants.LARGE_BILLBOARDS_SIZE.Y; y++) { m_largeBillboards[x][y] = new MySunWindBillboard(); MySunWindBillboard billboard = m_largeBillboards[x][y]; billboard.Radius = MyMwcUtils.GetRandomFloat(MySunWindConstants.LARGE_BILLBOARD_RADIUS_MIN, MySunWindConstants.LARGE_BILLBOARD_RADIUS_MAX); billboard.InitialAngle = MyMwcUtils.GetRandomRadian(); billboard.RotationSpeed = MyMwcUtils.GetRandomSign() * MyMwcUtils.GetRandomFloat(MySunWindConstants.LARGE_BILLBOARD_ROTATION_SPEED_MIN, MySunWindConstants.LARGE_BILLBOARD_ROTATION_SPEED_MAX); //billboard.Color = MySunWindConstants.BILLBOARD_COLOR; //billboard.Color.X = MyMwcUtils.GetRandomFloat(0.5f, 3); //billboard.Color.Y = MyMwcUtils.GetRandomFloat(0.5f, 2); //billboard.Color.Z = MyMwcUtils.GetRandomFloat(0.5f, 2); //billboard.Color.W = MyMwcUtils.GetRandomFloat(0.5f, 2); billboard.Color.X = MyMwcUtils.GetRandomFloat(0.5f, 3); billboard.Color.Y = MyMwcUtils.GetRandomFloat(0.5f, 1); billboard.Color.Z = MyMwcUtils.GetRandomFloat(0.5f, 1); billboard.Color.W = MyMwcUtils.GetRandomFloat(0.5f, 1); } } // Small billboards m_smallBillboards = new MySunWindBillboardSmall[MySunWindConstants.SMALL_BILLBOARDS_SIZE.X][]; for (int x = 0; x < MySunWindConstants.SMALL_BILLBOARDS_SIZE.X; x++) { m_smallBillboards[x] = new MySunWindBillboardSmall[MySunWindConstants.SMALL_BILLBOARDS_SIZE.Y]; for (int y = 0; y < MySunWindConstants.SMALL_BILLBOARDS_SIZE.Y; y++) { m_smallBillboards[x][y] = new MySunWindBillboardSmall(); MySunWindBillboardSmall billboard = m_smallBillboards[x][y]; billboard.Radius = MyMwcUtils.GetRandomFloat(MySunWindConstants.SMALL_BILLBOARD_RADIUS_MIN, MySunWindConstants.SMALL_BILLBOARD_RADIUS_MAX); billboard.InitialAngle = MyMwcUtils.GetRandomRadian(); billboard.RotationSpeed = MyMwcUtils.GetRandomSign() * MyMwcUtils.GetRandomFloat(MySunWindConstants.SMALL_BILLBOARD_ROTATION_SPEED_MIN, MySunWindConstants.SMALL_BILLBOARD_ROTATION_SPEED_MAX); //billboard.Color = MySunWindConstants.BILLBOARD_COLOR; billboard.Color.X = MyMwcUtils.GetRandomFloat(0.5f, 1); billboard.Color.Y = MyMwcUtils.GetRandomFloat(0.2f, 0.5f); billboard.Color.Z = MyMwcUtils.GetRandomFloat(0.2f, 0.5f); billboard.Color.W = MyMwcUtils.GetRandomFloat(0.1f, 0.5f); billboard.TailBillboardsCount = MyMwcUtils.GetRandomInt(MySunWindConstants.SMALL_BILLBOARD_TAIL_COUNT_MIN, MySunWindConstants.SMALL_BILLBOARD_TAIL_COUNT_MAX); billboard.TailBillboardsDistance = MyMwcUtils.GetRandomFloat(MySunWindConstants.SMALL_BILLBOARD_TAIL_DISTANCE_MIN, MySunWindConstants.SMALL_BILLBOARD_TAIL_DISTANCE_MAX); billboard.RadiusScales = new float[billboard.TailBillboardsCount]; for (int i = 0; i < billboard.TailBillboardsCount; i++) { billboard.RadiusScales[i] = MyMwcUtils.GetRandomFloat(0.7f, 1.0f); } } } MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); MyMwcLog.DecreaseIndent(); MyMwcLog.WriteLine("MySunWind.LoadContent() - END"); }