void PlayZoomingRelSound() { if ((m_zoomRelCue == null) || (m_zoomRelCue.Value.IsPlaying == false)) { m_zoomRelCue = MyAudio.AddCue2D(MySoundCuesEnum.WepSniperScopeZoomRel); } }
private void mineDetector_OnEntityPositionChange(MyEntityDetector sender, MyEntity entity, Vector3 newposition) { if (sender.Closed) { return; } if (entity == MySession.PlayerShip) { if (m_beepCue == null || !m_beepCue.Value.IsPlaying) { m_beepCue = MyAudio.AddCue2D(MySoundCuesEnum.SfxHudAlarmDamageA); } float distance = (entity.GetPosition() - sender.GetPosition()).Length(); if (distance < m_mineStartRadius) { uint mineId = 0; for (int i = 0; i < m_mines.GetLength(0); i++) { if (m_mines[i, 1] == sender.Parent.EntityId.Value.NumericValue) { mineId = m_mines[i, 0]; } } ExplodeMine(mineId); sender.Off(); sender.Parent.MarkForClose(); } } }
private void PlaySound() { if (m_scannerSound == null || !m_scannerSound.Value.IsPlaying) { m_scannerSound = MyAudio.AddCue2D(MySoundCuesEnum.SfxScanner); } }
public void Update(MySolarSystemMapCamera camera) { m_isMouseOverPrevious = m_isMouseOver; m_isMouseOver = false; UpdateWorldPosition(camera); Vector3 objToCamera = m_worldPosition; float dist = objToCamera.Length(); Visible = IsVisible(dist); if (Vector3.Dot(camera.Forward, objToCamera) >= 0 && Visible) { UpdateRenderedSizeAndOffsetPosition(); // we must use offset, because we need mark to be upper to other icons //m_worldPosition += camera.Up * m_actualRenderedSize * 4 * m_offsetIndex; m_worldPosition += new Vector3(0f, 1f, 0f) * m_actualRenderedSize * 4 * m_offsetIndex; m_screenPosition = GetScreenPosition(camera, m_worldPosition); Vector2 topLeft = GetScreenPosition(camera, m_worldPosition + camera.Left * m_actualRenderedSize + camera.Up * m_actualRenderedSize); Vector2 bottomRight = GetScreenPosition(camera, m_worldPosition - camera.Left * m_actualRenderedSize - camera.Up * m_actualRenderedSize); m_isMouseOver = MyGuiManager.MouseCursorPosition.X >= topLeft.X && MyGuiManager.MouseCursorPosition.X <= bottomRight.X && MyGuiManager.MouseCursorPosition.Y >= topLeft.Y && MyGuiManager.MouseCursorPosition.Y <= bottomRight.Y; } if (m_isMouseOverPrevious != m_isMouseOver) { MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseOver); } }
void OnAliveChanged() { var handler = AliveChanged; if (handler != null) { handler(this); } if (IsDead()) { m_deathBeep = MyAudio.AddCue2D(MySoundCuesEnum.SfxPlayerDeathBeep); if (MyMultiplayerGameplay.IsRunning && MySession.PlayerShip != null) { MyMultiplayerGameplay.Static.PilotDie(MySession.PlayerShip, m_LastDamageSource); } } else { if (m_deathBeep.HasValue && m_deathBeep.Value.IsPlaying) { m_deathBeep.Value.Stop(SharpDX.XACT3.StopFlags.Immediate); } } }
/// <summary> /// Called when user presses ESC or clicks on CANCEL - hook to this method so you can do gui-screen-specific event /// </summary> protected virtual void Canceling() { Canceled = true; MySoundCuesEnum cancelEnum = m_closingCueEnum.HasValue ? m_closingCueEnum.Value : MySoundCuesEnum.GuiMouseClick; MyAudio.AddCue2D(cancelEnum); CloseScreen(); }
public override bool Update(bool hasFocus) { if (m_progressCueEnum != null && (m_progressCue == null || !m_progressCue.Value.IsPlaying) && m_state == MyGuiScreenState.OPENED) { m_progressCue = MyAudio.AddCue2D(m_progressCueEnum.Value); } return(base.Update(hasFocus)); }
public override bool HandleInput(MyGuiInput input, bool hasKeyboardActiveControl, bool hasKeyboardActiveControlPrevious, bool receivedFocusInThisUpdate) { //If this control is not enable, do nothing if (!IsEnable) { return(false); } if (Visible) { if (((input.IsKeyPress(Keys.LeftShift) || input.IsKeyPress(Keys.RightShift)) && input.IsNewKeyPress(Keys.Tab)) || input.IsNewKeyPress(Keys.Up) || input.IsNewGamepadKeyUpPressed()) { SelectPrev(); } if ((!(input.IsKeyPress(Keys.LeftShift) || input.IsKeyPress(Keys.RightShift)) && input.IsNewKeyPress(Keys.Tab)) || input.IsNewKeyPress(Keys.Down) || input.IsNewGamepadKeyDownPressed()) { SelectNext(); } if (input.IsNewKeyPress(Keys.Escape) || input.IsJoystickButtonNewPressed(MyJoystickButtonsEnum.J02)) { HideScreenIfPossible(); } if (m_displayedItems[m_selected] != null) { if (input.IsNewKeyPress(Keys.Left) || input.IsNewGamepadKeyLeftPressed()) { m_displayedItems[m_selected].ChangeValueDown(); } if (input.IsNewKeyPress(Keys.Right) || input.IsNewGamepadKeyRightPressed()) { m_displayedItems[m_selected].ChangeValueUp(); } if (input.IsNewKeyPress(Keys.Enter) || input.IsNewKeyPress(Keys.Space) || input.IsJoystickButtonNewPressed(MyJoystickButtonsEnum.J01)) { m_displayedItems[m_selected].ChangeValueUp(); } } HandleMouse(input); } if (input.IsNewGameControlPressed(MyGameControlEnums.WHEEL_CONTROL)) { m_first = 0; Visible = !Visible; if (Visible == false) { MyAudio.AddCue2D(MySoundCuesEnum.GuiWheelControlClose); } else { MyAudio.AddCue2D(MySoundCuesEnum.GuiWheelControlOpen); } } return(base.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate)); }
private void PlayAlarmCue() { if ((m_alarmCue == null) || !m_alarmCue.Value.IsPlaying) { m_alarmCue = MyAudio.AddCue2D(MySoundCuesEnum.SfxClaxonAlert); m_alarmCueStartPlaying = MyMinerGame.TotalGamePlayTimeInMilliseconds; } RecheckNeedsUpdateState(); }
private void HandleDropingItem() { if (IsActive()) { Drop(); MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick); } }
public void HideScreenIfPossible() { m_first = 0; if (Visible) { MyAudio.AddCue2D(MySoundCuesEnum.GuiWheelControlClose); } Visible = false; }
private void PlaySound() { if (m_playOverDialogues || !MyDialogues.IsPlaying()) { if (m_soundCue == null || !m_soundCue.Value.IsPlaying) { m_soundCue = MyAudio.AddCue2D(Sound); } } }
public static void StartGameoverTimer() { if (m_gameOverTimer == null) { MyAudio.AddCue2D(MySoundCuesEnum.SfxClaxonAlert); MySmallShipBot.PlayFriendlyFireCue(); MyDialogues.Stop(); m_gameOverTimer = 10.0f; // 10s } }
static void PlayCurrentSentence() { MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("PlayCurrentSentence"); StopSound(); CurrentSentenceStarted_ms = MyMinerGame.TotalGamePlayTimeInMilliseconds; if (CurrentSentence == null || CurrentSentence.Cue == null) { m_currentCue = null; MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); return; } MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("LoadSentence"); if (CurrentSentence.Listener != null) { var speaker = MyScriptWrapper.TryGetEntity(MyActorConstants.GetActorName(CurrentSentence.Actor)) as MySmallShipBot; MySmallShip listener = null; if (CurrentSentence.Listener.Value == MyActorEnum.APOLLO) { listener = MySession.Static.Player.Ship; } else { listener = MyScriptWrapper.TryGetEntity(MyActorConstants.GetActorName(CurrentSentence.Listener.Value)) as MySmallShip; } if (speaker != null && listener != null) { speaker.LookTarget = listener; } } if (CurrentSentence.Cue != null) { m_currentCue = MyAudio.AddCue2D(CurrentSentence.Cue.Value, m_volume); if (OnSentenceStarted != null) { OnSentenceStarted(m_currentDialogueId, CurrentSentence.Text); } if (m_currentCue != null && CurrentSentence.PauseBefore_ms != 0) { m_currentCue.Value.Pause(); } } else { m_currentCue = null; } MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); }
public void Use(MySmallShip useBy) { // return the camera to owner's inventory bool addedSuccess = useBy.Inventory.AddInventoryItem(MyMwcObjectBuilderTypeEnum.SmallShip_Ammo, (int?)MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Remote_Camera, 1, false) == 0f; if (!addedSuccess) { MyAudio.AddCue2D(MySoundCuesEnum.HudInventoryFullWarning); } this.MarkForClose(); }
public void Display(object[] parameters) { if (Text != null) { MyGuiFont font = GetFontDelegate(); MyHudNotification.MyNotification notification = new MyHudNotification.MyNotification(Text.Value, font, 5000, null, parameters); MyHudNotification.AddNotification(notification); } if (SoundCue != null) { MyAudio.AddCue2D(SoundCue.Value); } }
public static void SwitchEnabled() { m_Enabled = !m_Enabled; MyAudio.AddCue2D(MySoundCuesEnum.GuiEditorVoxelHandSwitch); //if (m_Enabled == true) //{ // SelectedVoxelMap = null; // foreach (var entity in MyEditorGizmo.SelectedEntities) if (entity is MyVoxelMap) // { // SelectedVoxelMap = entity as MyVoxelMap; // } //} }
private void OnValueChange(bool playSound = true) { if (playSound) { MyAudio.AddCue2D(MySoundCuesEnum.SfxHudCockpitOff); } if (m_current == MyViewModeTypesEnum.ThirdPerson) { MyThirdPersonSpectator.Init(MySession.PlayerShip.GetPosition(), MySession.PlayerShip.GetWorldRotation()); } MyGuiScreenGamePlay.Static.CameraAttachedTo = GetCameraMode(); }
public void Use(MySmallShip useBy) { //m_droneObjectBuilder.DroneType // return the drone to inventory bool addedSuccess = useBy.Inventory.AddInventoryItem(MyMwcObjectBuilderTypeEnum.Drone, (int?)m_droneObjectBuilder.DroneType, 1, false) == 0f; if (!addedSuccess) { MyAudio.AddCue2D(MySoundCuesEnum.HudInventoryFullWarning); } else { MyAudio.AddCue2D(MySoundCuesEnum.SfxTakeAllUniversal); MyAudio.AddCue2D(MySoundCuesEnum.HudInventoryTransfer); } this.MarkForClose(); }
private static void UpdateShouts() { // check for new shout to start if (m_actualShoutCue == null || !m_actualShoutCue.Value.IsPlaying) { // check if we can start new shout if (m_nextShoutTime < MyMinerGame.TotalGamePlayTimeInMilliseconds) { // gets random faction to shout (from detected factions by radar) MyMwcObjectBuilder_FactionEnum?factionToShout = GetRandomDetectedFaction(); if (factionToShout != null) { MySoundCuesEnum shoutCue = GetRandomShout(factionToShout.Value); m_actualShoutCue = MyAudio.AddCue2D(shoutCue); if (m_actualShoutCue != null) { // because shouts can be ambient cues, so we must set correct volume for these cues if (m_actualShoutCue.Value.IsAmbientSound) { MyAudio.UpdateCueAmbVolume(m_actualShoutCue, 100f); } else { MyAudio.UpdateCueVolume(m_actualShoutCue, 0.9f); } m_actualShoutFaction = factionToShout; m_lastShoutCue = shoutCue; // calculate new time for next shout m_nextShoutTime = MyMinerGame.TotalGamePlayTimeInMilliseconds + MyMwcUtils.GetRandomInt(INTERVAL_BETWEEN_SHOUTS_MIN, INTERVAL_BETWEEN_SHOUTS_MAX); } } } } // check for old shout to stop else { if (!m_detectedFactions.Contains(m_actualShoutFaction.Value)) { StopShout(); } } }
public override void ChangeValueDown() { MyAudio.AddCue2D(MySoundCuesEnum.SfxHudRadarMode); switch (m_current) { case MyHudRadarTypesEnum.Normal3D: m_current = MyHudRadarTypesEnum.Solar2D; break; case MyHudRadarTypesEnum.Player2D: m_current = MyHudRadarTypesEnum.Normal3D; break; case MyHudRadarTypesEnum.Solar2D: m_current = MyHudRadarTypesEnum.Player2D; break; } base.ChangeValueDown(); }
// Method returns true if input was captured by control, so no other controls, nor screen can use input in this update public override bool HandleInput(MyGuiInput input, bool hasKeyboardActiveControl, bool hasKeyboardActiveControlPrevious, bool isThisFirstHandleInput) { bool ret = base.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, isThisFirstHandleInput); if (ret == false) { if (((IsMouseOver() == true) && (input.IsNewLeftMousePressed() == true)) || ((hasKeyboardActiveControl == true) && ((input.IsNewKeyPress(Keys.Enter) || (input.IsNewKeyPress(Keys.Space)))))) { if (!Selected) { MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick); Selected = true; ret = true; } } } return(ret); }
protected void ChangeSound(float influenceStrength) { Debug.Assert(IsSound); Volume = influenceStrength * (MyFakes.ENABLE_DEBUG_INFLUENCE_SPHERES_SOUNDS ? m_maxVolume : 100.0f); if (m_volume <= 0.0f) { if (m_cue.HasValue) { m_cue.Value.Stop(SharpDX.XACT3.StopFlags.Release); } } else { if ((m_cue.HasValue == false) || (m_cue.Value.IsPlaying == false)) { m_cue = MyAudio.AddCue2D(m_cueEnum, m_volume); } MyAudio.UpdateCueAmbVolume(m_cue, m_volume); } }
// Method returns true if input was captured by control, so no other controls, nor screen can use input in this update public override bool HandleInput(MyGuiInput input, bool hasKeyboardActiveControl, bool hasKeyboardActiveControlPrevious, bool receivedFocusInThisUpdate) { bool captureInput = base.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate); if (captureInput == false) { if (((IsMouseOver() == true) && ((input.IsNewLeftMouseReleased() == true))) || ((hasKeyboardActiveControl == true) && (m_canHandleKeyboardInput == true) && ((input.IsJoystickButtonNewPressed(MyJoystickButtonsEnum.J01)) || (input.IsNewKeyPress(Keys.Enter)) || (input.IsNewKeyPress(Keys.Space))))) { if (m_implementedFeature == false) { MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick); MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.ERROR, MyTextsWrapperEnum.FeatureNotYetImplemented, MyTextsWrapperEnum.MessageBoxCaptionFeatureDisabled, MyTextsWrapperEnum.Ok, null)); } else if (m_accessForbiddenReason != null) { MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick); MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.ERROR, m_accessForbiddenReason.Value, MyTextsWrapperEnum.MessageBoxCaptionFeatureDisabled, MyTextsWrapperEnum.Ok, null)); } else if (Enabled || UseSwitchMode) { MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick); if (m_onButtonClick != null) { m_onButtonClick(this); } else if (m_onIndexedButtonClick != null) { m_onIndexedButtonClick(m_buttonIndex); } } captureInput = true; } } return(captureInput); }
/// <summary> /// Remove all action entities /// </summary> protected virtual void RemoveFromScene() { foreach (MyEntity actionEntity in ActionEntities) { //dont delete player ship if (actionEntity == MySession.PlayerShip) { continue; } MyEditorGizmo.RemoveEntityFromSelection(actionEntity); if (actionEntity == MyEditor.Static.GetEditedPrefabContainer()) { MyEditor.Static.ResetActivePrefabContainer(); } MyEditor.Static.DeleteEntityFromCollidingList(actionEntity); if (!(actionEntity is MyPrefabBase)) { if (m_activeContainer == null && MyEditor.Static.IsEditingPrefabContainer()) { MyEditor.Static.ExitActivePrefabContainer(); } } else { MyEditor.Static.EditPrefabContainer(m_activeContainer); } actionEntity.MarkForClose(); MyEditor.Static.RecheckAllColidingEntitesAndClearNonColiding(); } ActionEntities.Clear(); MyAudio.AddCue2D(MySoundCuesEnum.GuiEditorObjectDelete); }
public override void CloseScreenNow() { if (m_progressCue != null && m_progressCue.Value.IsPlaying) { m_progressCue.Value.Stop(SharpDX.XACT3.StopFlags.Immediate); } if (GetValue() < SUCCESS_VALUE) { if (m_cancelCueEnum != null && (m_cancelCue == null || !m_cancelCue.Value.IsPlaying)) { m_cancelCue = MyAudio.AddCue2D(m_cancelCueEnum.Value); } } else { if (m_successCueEnum != null && (m_successCue == null || !m_successCue.Value.IsPlaying)) { m_successCue = MyAudio.AddCue2D(m_successCueEnum.Value); } } base.CloseScreenNow(); }
public override bool HandleInput(MyGuiInput input, bool hasKeyboardActiveControl, bool hasKeyboardActiveControlPrevious, bool receivedFocusInThisUpdate) { bool ret = GetTabSubControl(m_selectedTab).HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate); if (ret) { return(true); } ret = base.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate); if (ret == false) { int tab = GetMouseOverTab(); if (tab != -1 && input.IsNewLeftMousePressed()) { MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick); ActivateTab(tab); //m_selectedTab = tab; ret = true; } } return(ret); }
// Method returns true if input was captured by control, so no other controls, nor screen can use input in this update public virtual bool HandleInput(MyGuiInput input, bool hasKeyboardActiveControl, bool hasKeyboardActiveControlPrevious, bool receivedFocusInThisUpdate) { if (m_isActiveControl) { //m_hasKeyboardActiveControlInPrevious = m_hasKeyboardActiveControl; m_hasKeyboardActiveControl = hasKeyboardActiveControl; m_isMouseOverInPrevious = m_isMouseOver; m_isMouseOver = CheckMouseOver(); m_mouseButtonPressed = IsMouseOver() && input.IsLeftMousePressed(); if (((m_isMouseOver == true) && (m_isMouseOverInPrevious == false)) || ((m_hasKeyboardActiveControl == true) && (hasKeyboardActiveControlPrevious == false))) { if (receivedFocusInThisUpdate == false) { MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseOver); } } } // if mouseover this control longer than specified period, show tooltip for the control if ((m_isMouseOver == true) && (m_isMouseOverInPrevious == true)) { if (m_showToolTip == false) { m_showToolTipDelay = MyMinerGame.TotalGamePlayTimeInMilliseconds + MyGuiConstants.SHOW_CONTROL_TOOLTIP_DELAY; m_showToolTip = true; } } else { m_showToolTip = false; } return(false); }
public override void HandleInput(MyGuiInput input, bool receivedFocusInThisUpdate) { base.HandleInput(input, receivedFocusInThisUpdate); if (MyGuiInput.ENABLE_DEVELOPER_KEYS) { if (input.IsNewKeyPress(Keys.C) && input.IsAnyCtrlKeyPressed()) { CopySector(); } if (input.IsNewKeyPress(Keys.V) && input.IsAnyCtrlKeyPressed()) { PasteSector(); } } if (MyFakes.DRAW_FACTION_AREAS_IN_SOLAR_MAP) { MySolarMapAreaInput.HandleInput(m_solarMapRender, input, receivedFocusInThisUpdate); } float rollIndicator = input.GetRoll(); Vector2 rotationIndicator = Vector2.Zero; if (input.IsNewRightMousePressed() && MyVideoModeManager.IsHardwareCursorUsed()) { m_oldRotationIndicator = input.GetRotation(); } if (input.IsRightMousePressed()) { if (MyVideoModeManager.IsHardwareCursorUsed()) { rotationIndicator = m_oldRotationIndicator - input.GetRotation(); m_oldRotationIndicator = input.GetRotation(); } else { rotationIndicator = input.GetRotation(); } } Vector3 moveIndicator = input.GetPositionDelta(); if (input.IsKeyPress(Keys.Left)) { moveIndicator.X = -1; } if (input.IsKeyPress(Keys.Right)) { moveIndicator.X = 1; } if (input.IsKeyPress(Keys.Up)) { moveIndicator.Z = -1; } if (input.IsKeyPress(Keys.Down)) { moveIndicator.Z = 1; } m_camera.Zoom(input.DeltaMouseScrollWheelValue()); m_camera.MoveAndRotate(moveIndicator, rotationIndicator, rollIndicator, 1); bool sectorChanged = false; if (m_lastSector != m_camera.TargetSector) { sectorChanged = true; m_lastSector = m_camera.TargetSector; } MySolarSystemMapNavigationMark navigationMarkUnderMouse = GetNearestNavigationMarkUnderMouseCursor(); const float maxHeightForEnter = MySolarSystemMapCamera.SECTOR_SIZE_GAMEUNITS * 16; if (sectorChanged) // we have moved camera so deselect sector { m_selectedSector = null; } // tool tips if (m_lastNavigationMarkUnderMouse != navigationMarkUnderMouse) { m_toolTip.ClearToolTips(); if (navigationMarkUnderMouse != null) { m_toolTip.AddToolTip(new StringBuilder(GetSectorName(navigationMarkUnderMouse))); if (!String.IsNullOrEmpty(navigationMarkUnderMouse.Description)) { m_toolTip.AddToolTip(new StringBuilder(navigationMarkUnderMouse.Description), Color.LightGray); } m_toolTip.AddToolTip(new StringBuilder(navigationMarkUnderMouse.Sector.ToString()), Color.LightGray); } m_lastNavigationMarkUnderMouse = navigationMarkUnderMouse; } if (navigationMarkUnderMouse != null) { MyGuiManager.SetMouseCursorTexture(MyGuiManager.GetMouseCursorHandTexture()); if (input.IsNewLeftMousePressed() && !m_travelButton.IsMouseOver()) { MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick); if (m_selectedNavigationMark != null) { m_selectedNavigationMark.Highlight = false; } m_selectedNavigationMark = navigationMarkUnderMouse; m_selectedNavigationMark.Highlight = true; sectorChanged = true; m_slectionLocked = true; m_travelButton.Visible = false; } if (input.IsNewLeftMouseDoubleClick()) { TravelToSector(navigationMarkUnderMouse.Sector, navigationMarkUnderMouse.MissionID); } } else if (m_camera.CameraDistance < maxHeightForEnter && !m_slectionLocked) { if (MyGuiScreenGamePlay.CanTravelToSector(m_camera.TargetSector)) { //MyGuiManager.SetMouseCursorTexture(MyGuiManager.GetMouseCursorHandTexture()); if (m_selectedNavigationMark != null) { m_selectedNavigationMark.Highlight = false; } var navigationMarkUnderCamera = GetNavigationMarkUnderCamera(); if (navigationMarkUnderCamera != null && navigationMarkUnderCamera.Sector == m_camera.TargetSector) { m_selectedNavigationMark = navigationMarkUnderCamera; } else { m_selectedNavigationMark = new MySolarSystemMapNavigationMark(m_camera.TargetSector, ""); m_travelButton.Visible = false; } } else { m_selectedNavigationMark = null; } } else if (input.IsNewLeftMousePressed()) { if (m_selectedNavigationMark != null) { m_selectedNavigationMark.Highlight = false; } if (!m_travelButton.IsMouseOver()) { m_selectedNavigationMark = null; } m_slectionLocked = false; } else if (sectorChanged && m_camera.CameraDistance > maxHeightForEnter && !m_slectionLocked) { m_selectedNavigationMark = null; } else { MyGuiManager.SetMouseCursorTexture(MyGuiManager.GetMouseCursorArrowTexture()); } if (m_selectedNavigationMark != null) { if (!m_travelButton.Visible) { m_travelButton.Text.Clear(); string text = GetSectorName(m_selectedNavigationMark); if (text.Length > 21) { text = text.Substring(0, 20); text += "…"; } m_travelButton.Text.Append(MyTextsWrapper.GetFormatString(MyTextsWrapperEnum.TravelTo, text)); // float width = MyGuiManager.GetNormalizedSize( MyGuiManager.GetFontMinerWarsBlue(), m_travelButton.Text, 1).X + 0.05f; // m_travelButton.SetSize(new Vector2(width, MyGuiConstants.BACK_BUTTON_SIZE.Y)); m_travelButton.Visible = true; } } else { m_travelButton.Visible = false; } }
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; }