protected void HandleScrolls(InputState input) { if ((double)this.AdjustCamTimer >= 0.0) return; if ((input.ScrollOut || input.BButtonHeld) && !this.LookingAtPlanet) { float num = (float)(1500.0 * (double)this.camHeight / 3000.0 + 100.0); //fbedard: faster scroll //if ((double)this.camHeight < 10000.0) // num -= 200f; this.transitionDestination.X = this.camPos.X; this.transitionDestination.Y = this.camPos.Y; this.transitionDestination.Z = this.camHeight + num; if ((double)this.camHeight > 12000.0) { this.transitionDestination.Z += 3000f; this.viewState = UniverseScreen.UnivScreenState.SectorView; if ((double)this.camHeight > 32000.0) this.transitionDestination.Z += 15000f; if ((double)this.camHeight > 100000.0) this.transitionDestination.Z += 40000f; } if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftControl)) { if ((double)this.camHeight < 55000.0) { this.transitionDestination.Z = 60000f; this.AdjustCamTimer = 1f; this.transitionElapsedTime = 0.0f; } else { this.transitionDestination.Z = 4200000f * this.GameScale; this.AdjustCamTimer = 1f; this.transitionElapsedTime = 0.0f; } } } if (!input.YButtonHeld && !input.ScrollIn || this.LookingAtPlanet) return; float num1 = (float)(1500.0 * (double)this.camHeight / 3000.0 + 100.0); //fbedard: faster scroll //if ((double)this.camHeight < 10000.0) // num1 -= 200f; this.transitionDestination.Z = this.camHeight - num1; if ((double)this.camHeight >= 16000.0) { this.transitionDestination.Z -= 2000f; if ((double)this.camHeight > 32000.0) this.transitionDestination.Z -= 7500f; if ((double)this.camHeight > 150000.0) this.transitionDestination.Z -= 40000f; } if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftControl) && (double)this.camHeight > 10000.0) this.transitionDestination.Z = (double)this.camHeight <= 65000.0 ? 10000f : 60000f; if (this.ViewingShip) return; if ((double)this.camHeight <= 450.0) this.camHeight = 450f; float num2 = this.transitionDestination.Z; //fbedard: add a scroll on selected object if (!input.CurrentKeyboardState.IsKeyDown(Keys.LeftShift)) { if (this.SelectedShip != null && this.SelectedShip.Active) { this.transitionDestination = new Vector3(this.SelectedShip.Position.X, this.SelectedShip.Position.Y, num2); } else if (this.SelectedPlanet != null) { this.transitionDestination = new Vector3(this.SelectedPlanet.Position.X, this.SelectedPlanet.Position.Y, num2); } else if (this.SelectedFleet != null && this.SelectedFleet.Ships.Count > 0) { this.transitionDestination = new Vector3(this.SelectedFleet.findAveragePositioncg().X, this.SelectedFleet.findAveragePositioncg().Y, num2); } else this.transitionDestination = new Vector3(this.CalculateCameraPositionOnMouseZoom(new Vector2((float)input.CurrentMouseState.X, (float)input.CurrentMouseState.Y), num2), num2); } else this.transitionDestination = new Vector3(this.CalculateCameraPositionOnMouseZoom(new Vector2((float)input.CurrentMouseState.X, (float)input.CurrentMouseState.Y), num2), num2); }
protected void HandleScrollsSectorMiniMap(InputState input) { this.SectorMiniMapHeight = MathHelper.SmoothStep(this.SectorMiniMapHeight, this.desiredSectorZ, 0.2f); if ((double)this.SectorMiniMapHeight < 6000.0) this.SectorMiniMapHeight = 6000f; if (input.InGameSelect) { this.transitionDestination.Z = this.SectorMiniMapHeight; this.transitionDestination.X = this.playerShip.Center.X; this.transitionDestination.Y = this.playerShip.Center.Y; } if ((input.ScrollOut || input.BButtonHeld) && !this.LookingAtPlanet) { float num = (float)(1500.0 * (double)this.SectorMiniMapHeight / 3000.0 + 550.0); if ((double)this.SectorMiniMapHeight < 10000.0) num -= 200f; this.desiredSectorZ = this.SectorMiniMapHeight + num; if ((double)this.SectorMiniMapHeight > 12000.0) { this.desiredSectorZ += 3000f; this.viewState = UniverseScreen.UnivScreenState.SectorView; if ((double)this.SectorMiniMapHeight > 32000.0) this.desiredSectorZ += 15000f; if ((double)this.SectorMiniMapHeight > 100000.0) this.desiredSectorZ += 40000f; } } if ((input.YButtonHeld || input.ScrollIn) && !this.LookingAtPlanet) { float num = (float)(1500.0 * (double)this.SectorMiniMapHeight / 3000.0 + 550.0); if ((double)this.SectorMiniMapHeight < 10000.0) num -= 200f; this.desiredSectorZ = this.SectorMiniMapHeight - num; if ((double)this.SectorMiniMapHeight >= 16000.0) { this.desiredSectorZ -= 3000f; if ((double)this.SectorMiniMapHeight > 32000.0) this.desiredSectorZ -= 7500f; if ((double)this.SectorMiniMapHeight > 150000.0) this.desiredSectorZ -= 40000f; } } if ((double)this.camHeight <= 168471840.0 * (double)this.GameScale) return; this.camHeight = 1.684718E+08f * this.GameScale; }
protected virtual void AdjustCamera(float elapsedTime) { if (this.ShipToView == null) this.ViewingShip = false; this.AdjustCamTimer -= elapsedTime; if (this.ViewingShip && !this.snappingToShip) { this.camPos.X = this.ShipToView.Center.X; this.camPos.Y = this.ShipToView.Center.Y; this.camHeight = (float)(int)MathHelper.SmoothStep(this.camHeight, this.transitionDestination.Z, 0.2f); if ((double)this.camHeight < 550.0) this.camHeight = 550f; } if (this.AdjustCamTimer > 0.0) { if (this.ShipToView == null) this.snappingToShip = false; if (this.snappingToShip) { this.transitionDestination.X = this.ShipToView.Center.X; this.transitionDestination.Y = this.ShipToView.Center.Y; this.transitionElapsedTime += elapsedTime; float amount = (float)Math.Pow((double)this.transitionElapsedTime / (double)this.transDuration, 0.699999988079071); this.camTransitionPosition.X = MathHelper.SmoothStep(this.camPos.X, this.transitionDestination.X, amount); float num1 = MathHelper.SmoothStep(this.camPos.Y, this.transitionDestination.Y, amount); float num2 = MathHelper.SmoothStep(this.camHeight, this.transitionDestination.Z, amount); this.camTransitionPosition.Y = num1; this.camHeight = (float)(int)num2; this.camPos = this.camTransitionPosition; if ((double)this.AdjustCamTimer - (double)elapsedTime <= 0.0) { this.ViewingShip = true; this.transitionElapsedTime = 0.0f; this.AdjustCamTimer = -1f; this.snappingToShip = false; } } else { this.transitionElapsedTime += elapsedTime; float amount = (float)Math.Pow((double)this.transitionElapsedTime / (double)this.transDuration, 0.699999988079071); this.camTransitionPosition.X = MathHelper.SmoothStep(this.camPos.X, this.transitionDestination.X, amount); float num1 = MathHelper.SmoothStep(this.camPos.Y, this.transitionDestination.Y, amount); float num2 = MathHelper.SmoothStep(this.camHeight, this.transitionDestination.Z, amount); this.camTransitionPosition.Y = num1; this.camHeight = num2; this.camPos = this.camTransitionPosition; if ((double)this.transitionElapsedTime > (double)this.transDuration || (double)Vector2.Distance(new Vector2(this.camPos.X, this.camPos.Y), new Vector2(this.transitionDestination.X, this.transitionDestination.Y)) < 50.0 && (double)Math.Abs(this.camHeight - this.transitionDestination.Z) < 50.0) { this.transitionElapsedTime = 0.0f; this.AdjustCamTimer = -1f; } } if ((double)this.camHeight < 550.0) this.camHeight = 550f; } else if (this.LookingAtPlanet && this.SelectedPlanet != null) { this.camTransitionPosition.X = MathHelper.SmoothStep(this.camPos.X, this.SelectedPlanet.Position.X, 0.2f); this.camTransitionPosition.Y = MathHelper.SmoothStep(this.camPos.Y, this.SelectedPlanet.Position.Y + 400f, 0.2f); this.camPos = this.camTransitionPosition; } else if (!this.ViewingShip) { this.camTransitionPosition.X = MathHelper.SmoothStep(this.camPos.X, this.transitionDestination.X, 0.2f); float num1 = MathHelper.SmoothStep(this.camPos.Y, this.transitionDestination.Y, 0.2f); float num2 = MathHelper.SmoothStep(this.camHeight, this.transitionDestination.Z, 0.2f); this.camTransitionPosition.Y = num1; this.camHeight = num2; if ((double)this.camHeight < 550.0) this.camHeight = 550f; this.camPos = this.camTransitionPosition; } if ((double)this.camPos.X > (double)this.Size.X) this.camPos.X = this.Size.X; if ((double)this.camPos.X < 0.0) this.camPos.X = 0.0f; if ((double)this.camPos.Y > (double)this.Size.Y) this.camPos.Y = this.Size.Y; if ((double)this.camPos.Y < 0.0) this.camPos.Y = 0.0f; if ((double)this.camHeight > (double)this.MaxCamHeight * (double)this.GameScale) this.camHeight = this.MaxCamHeight * this.GameScale; else if ((double)this.camHeight < 1337.0) this.camHeight = 1337f; if ((double)this.camHeight > 30000.0) { this.viewState = UniverseScreen.UnivScreenState.SystemView; if ((double)this.camHeight <= 250000.0) return; this.viewState = UniverseScreen.UnivScreenState.SectorView; if ((double)this.camHeight <= 1775000.0) return; this.viewState = UniverseScreen.UnivScreenState.GalaxyView; } else this.viewState = UniverseScreen.UnivScreenState.ShipView; }