new public void Update(GameTime gameTime) { if (Input.DisplayHUD) { if (BackgroundRectangle.Contains(Input.GesturePosition)) { if (BackgroundRectangle.Contains(Input.Tap)) { foreach (LayerWindowButton button in layerIndexButtons) { if (button.Rect.Contains(Input.Tap)) { // We have to set the slider's position to the saved position for this layer. SelectedLayer = button.ID; sliderButton.ChangeXPosition(button.SliderValue - sliderButton.Rect.Location.X); } } } if (Input.Drag.X != 0) { // Change the position of the slider, and then save its position for this layer. ChangeSliderPosition((int)Input.Drag.X); layerIndexButtons[SelectedLayer].SliderValue = sliderButton.Rect.Location.X; } } } base.Update(gameTime); }
public void Update(GameTime gameTime) { if (BackgroundRectangle.Contains(Input.Tap)) { System.Diagnostics.Debug.WriteLine("Exporting."); FileExporter.ExportCanvas(); } base.Update(gameTime); }
new public void Update(GameTime gameTime) { if (Input.DisplayHUD) { if (BackgroundRectangle.Contains(Input.GesturePosition)) { if (Input.Tap != new Vector2(-1, -1) && BackgroundRectangle.Contains(Input.Tap)) { SelectedTile = SelectNewTile(Input.Tap); } if (Input.Drag.Y != 0) { Slide((int)Input.Drag.Y); } } } base.Update(gameTime); }
public void Update() { Draw(); if (Globals.enemy.Count == 0) { for (int i = 0; i < 26; i++) { Globals.enemy.Add(new Enemyship_1()); } Globals.iteration_for_points = 0; } for (int i = 0; i < backgroundItems.Count; i++) { BackgroundRectangle currentBackgroundRect = (BackgroundRectangle)backgroundItems[i]; currentBackgroundRect.Update(); if (currentBackgroundRect._position.Y > Globals.screenSize.Y) { backgroundItems.Remove(currentBackgroundRect); } } if (points_1.Count > Globals.iteration_for_points) { for (int i = 0; i < Globals.enemy.Count; i++) { var list = points_list_for_flyin[i]; if (list.Count > Globals.iteration_for_points) { Globals.enemy[i]._position = list[Globals.iteration_for_points]; Globals.enemy[i]._bounds = new Rectangle((int)Globals.enemy[i]._position.X, (int)Globals.enemy[i]._position.Y, Globals.enemyship_1.Width, Globals.enemyship_1.Height); } } Globals.iteration_for_points++; } Console.WriteLine(Globals.enemy.Count); spacekraft.Update(); }
public void InterpolateBetween(VariableState firstState, VariableState secondState, float interpolationValue) { #if DEBUG if (float.IsNaN(interpolationValue)) { throw new System.Exception("interpolationValue cannot be NaN"); } #endif bool setBackgroundRectangleAlphaFirstValue = false; bool setBackgroundRectangleAlphaSecondValue = false; int BackgroundRectangleAlphaFirstValue = 0; int BackgroundRectangleAlphaSecondValue = 0; bool setBackgroundRectangleHeightFirstValue = false; bool setBackgroundRectangleHeightSecondValue = false; float BackgroundRectangleHeightFirstValue = 0; float BackgroundRectangleHeightSecondValue = 0; bool setBackgroundRectangleCurrentVariableStateFirstValue = false; bool setBackgroundRectangleCurrentVariableStateSecondValue = false; Pirates.GumRuntimes.ColoredRectangleRuntime.VariableState BackgroundRectangleCurrentVariableStateFirstValue = Pirates.GumRuntimes.ColoredRectangleRuntime.VariableState.Default; Pirates.GumRuntimes.ColoredRectangleRuntime.VariableState BackgroundRectangleCurrentVariableStateSecondValue = Pirates.GumRuntimes.ColoredRectangleRuntime.VariableState.Default; bool setBackgroundRectangleWidthFirstValue = false; bool setBackgroundRectangleWidthSecondValue = false; float BackgroundRectangleWidthFirstValue = 0; float BackgroundRectangleWidthSecondValue = 0; bool setBackgroundRectangleXFirstValue = false; bool setBackgroundRectangleXSecondValue = false; float BackgroundRectangleXFirstValue = 0; float BackgroundRectangleXSecondValue = 0; bool setBackgroundRectangleYFirstValue = false; bool setBackgroundRectangleYSecondValue = false; float BackgroundRectangleYFirstValue = 0; float BackgroundRectangleYSecondValue = 0; bool setHeightFirstValue = false; bool setHeightSecondValue = false; float HeightFirstValue = 0; float HeightSecondValue = 0; bool setItemSpriteHeightFirstValue = false; bool setItemSpriteHeightSecondValue = false; float ItemSpriteHeightFirstValue = 0; float ItemSpriteHeightSecondValue = 0; bool setItemSpriteWidthFirstValue = false; bool setItemSpriteWidthSecondValue = false; float ItemSpriteWidthFirstValue = 0; float ItemSpriteWidthSecondValue = 0; bool setItemSpriteXFirstValue = false; bool setItemSpriteXSecondValue = false; float ItemSpriteXFirstValue = 0; float ItemSpriteXSecondValue = 0; bool setItemSpriteYFirstValue = false; bool setItemSpriteYSecondValue = false; float ItemSpriteYFirstValue = 0; float ItemSpriteYSecondValue = 0; bool setWidthFirstValue = false; bool setWidthSecondValue = false; float WidthFirstValue = 0; float WidthSecondValue = 0; bool setBackgroundRectangleBlueFirstValue = false; bool setBackgroundRectangleBlueSecondValue = false; int BackgroundRectangleBlueFirstValue = 0; int BackgroundRectangleBlueSecondValue = 0; bool setBackgroundRectangleGreenFirstValue = false; bool setBackgroundRectangleGreenSecondValue = false; int BackgroundRectangleGreenFirstValue = 0; int BackgroundRectangleGreenSecondValue = 0; switch (firstState) { case VariableState.Default: setBackgroundRectangleAlphaFirstValue = true; BackgroundRectangleAlphaFirstValue = 128; setBackgroundRectangleHeightFirstValue = true; BackgroundRectangleHeightFirstValue = 100f; if (interpolationValue < 1) { this.BackgroundRectangle.HeightUnits = Gum.DataTypes.DimensionUnitType.PercentageOfOtherDimension; } setBackgroundRectangleCurrentVariableStateFirstValue = true; BackgroundRectangleCurrentVariableStateFirstValue = Pirates.GumRuntimes.ColoredRectangleRuntime.VariableState.Default; setBackgroundRectangleWidthFirstValue = true; BackgroundRectangleWidthFirstValue = 90f; if (interpolationValue < 1) { this.BackgroundRectangle.WidthUnits = Gum.DataTypes.DimensionUnitType.Percentage; } setBackgroundRectangleXFirstValue = true; BackgroundRectangleXFirstValue = 5f; if (interpolationValue < 1) { this.BackgroundRectangle.XUnits = Gum.Converters.GeneralUnitType.Percentage; } setBackgroundRectangleYFirstValue = true; BackgroundRectangleYFirstValue = 5f; if (interpolationValue < 1) { this.BackgroundRectangle.YUnits = Gum.Converters.GeneralUnitType.Percentage; } setHeightFirstValue = true; HeightFirstValue = 60f; if (interpolationValue < 1) { this.HeightUnits = Gum.DataTypes.DimensionUnitType.Absolute; } setItemSpriteHeightFirstValue = true; ItemSpriteHeightFirstValue = 100f; if (interpolationValue < 1) { this.ItemSprite.HeightUnits = Gum.DataTypes.DimensionUnitType.PercentageOfOtherDimension; } setItemSpriteWidthFirstValue = true; ItemSpriteWidthFirstValue = 90f; if (interpolationValue < 1) { this.ItemSprite.WidthUnits = Gum.DataTypes.DimensionUnitType.Percentage; } setItemSpriteXFirstValue = true; ItemSpriteXFirstValue = 5f; if (interpolationValue < 1) { this.ItemSprite.XUnits = Gum.Converters.GeneralUnitType.Percentage; } setItemSpriteYFirstValue = true; ItemSpriteYFirstValue = 5f; if (interpolationValue < 1) { this.ItemSprite.YUnits = Gum.Converters.GeneralUnitType.Percentage; } setWidthFirstValue = true; WidthFirstValue = 60f; if (interpolationValue < 1) { this.WidthUnits = Gum.DataTypes.DimensionUnitType.Absolute; } if (interpolationValue < 1) { this.XUnits = Gum.Converters.GeneralUnitType.PixelsFromSmall; } if (interpolationValue < 1) { this.YUnits = Gum.Converters.GeneralUnitType.PixelsFromSmall; } break; case VariableState.Selected: setBackgroundRectangleAlphaFirstValue = true; BackgroundRectangleAlphaFirstValue = 255; setBackgroundRectangleBlueFirstValue = true; BackgroundRectangleBlueFirstValue = 0; setBackgroundRectangleGreenFirstValue = true; BackgroundRectangleGreenFirstValue = 0; break; } switch (secondState) { case VariableState.Default: setBackgroundRectangleAlphaSecondValue = true; BackgroundRectangleAlphaSecondValue = 128; setBackgroundRectangleHeightSecondValue = true; BackgroundRectangleHeightSecondValue = 100f; if (interpolationValue >= 1) { this.BackgroundRectangle.HeightUnits = Gum.DataTypes.DimensionUnitType.PercentageOfOtherDimension; } setBackgroundRectangleCurrentVariableStateSecondValue = true; BackgroundRectangleCurrentVariableStateSecondValue = Pirates.GumRuntimes.ColoredRectangleRuntime.VariableState.Default; setBackgroundRectangleWidthSecondValue = true; BackgroundRectangleWidthSecondValue = 90f; if (interpolationValue >= 1) { this.BackgroundRectangle.WidthUnits = Gum.DataTypes.DimensionUnitType.Percentage; } setBackgroundRectangleXSecondValue = true; BackgroundRectangleXSecondValue = 5f; if (interpolationValue >= 1) { this.BackgroundRectangle.XUnits = Gum.Converters.GeneralUnitType.Percentage; } setBackgroundRectangleYSecondValue = true; BackgroundRectangleYSecondValue = 5f; if (interpolationValue >= 1) { this.BackgroundRectangle.YUnits = Gum.Converters.GeneralUnitType.Percentage; } setHeightSecondValue = true; HeightSecondValue = 60f; if (interpolationValue >= 1) { this.HeightUnits = Gum.DataTypes.DimensionUnitType.Absolute; } setItemSpriteHeightSecondValue = true; ItemSpriteHeightSecondValue = 100f; if (interpolationValue >= 1) { this.ItemSprite.HeightUnits = Gum.DataTypes.DimensionUnitType.PercentageOfOtherDimension; } setItemSpriteWidthSecondValue = true; ItemSpriteWidthSecondValue = 90f; if (interpolationValue >= 1) { this.ItemSprite.WidthUnits = Gum.DataTypes.DimensionUnitType.Percentage; } setItemSpriteXSecondValue = true; ItemSpriteXSecondValue = 5f; if (interpolationValue >= 1) { this.ItemSprite.XUnits = Gum.Converters.GeneralUnitType.Percentage; } setItemSpriteYSecondValue = true; ItemSpriteYSecondValue = 5f; if (interpolationValue >= 1) { this.ItemSprite.YUnits = Gum.Converters.GeneralUnitType.Percentage; } setWidthSecondValue = true; WidthSecondValue = 60f; if (interpolationValue >= 1) { this.WidthUnits = Gum.DataTypes.DimensionUnitType.Absolute; } if (interpolationValue >= 1) { this.XUnits = Gum.Converters.GeneralUnitType.PixelsFromSmall; } if (interpolationValue >= 1) { this.YUnits = Gum.Converters.GeneralUnitType.PixelsFromSmall; } break; case VariableState.Selected: setBackgroundRectangleAlphaSecondValue = true; BackgroundRectangleAlphaSecondValue = 255; setBackgroundRectangleBlueSecondValue = true; BackgroundRectangleBlueSecondValue = 0; setBackgroundRectangleGreenSecondValue = true; BackgroundRectangleGreenSecondValue = 0; break; } if (setBackgroundRectangleAlphaFirstValue && setBackgroundRectangleAlphaSecondValue) { BackgroundRectangle.Alpha = FlatRedBall.Math.MathFunctions.RoundToInt(BackgroundRectangleAlphaFirstValue * (1 - interpolationValue) + BackgroundRectangleAlphaSecondValue * interpolationValue); } if (setBackgroundRectangleHeightFirstValue && setBackgroundRectangleHeightSecondValue) { BackgroundRectangle.Height = BackgroundRectangleHeightFirstValue * (1 - interpolationValue) + BackgroundRectangleHeightSecondValue * interpolationValue; } if (setBackgroundRectangleCurrentVariableStateFirstValue && setBackgroundRectangleCurrentVariableStateSecondValue) { BackgroundRectangle.InterpolateBetween(BackgroundRectangleCurrentVariableStateFirstValue, BackgroundRectangleCurrentVariableStateSecondValue, interpolationValue); } if (setBackgroundRectangleWidthFirstValue && setBackgroundRectangleWidthSecondValue) { BackgroundRectangle.Width = BackgroundRectangleWidthFirstValue * (1 - interpolationValue) + BackgroundRectangleWidthSecondValue * interpolationValue; } if (setBackgroundRectangleXFirstValue && setBackgroundRectangleXSecondValue) { BackgroundRectangle.X = BackgroundRectangleXFirstValue * (1 - interpolationValue) + BackgroundRectangleXSecondValue * interpolationValue; } if (setBackgroundRectangleYFirstValue && setBackgroundRectangleYSecondValue) { BackgroundRectangle.Y = BackgroundRectangleYFirstValue * (1 - interpolationValue) + BackgroundRectangleYSecondValue * interpolationValue; } if (setHeightFirstValue && setHeightSecondValue) { Height = HeightFirstValue * (1 - interpolationValue) + HeightSecondValue * interpolationValue; } if (setItemSpriteHeightFirstValue && setItemSpriteHeightSecondValue) { ItemSprite.Height = ItemSpriteHeightFirstValue * (1 - interpolationValue) + ItemSpriteHeightSecondValue * interpolationValue; } if (setItemSpriteWidthFirstValue && setItemSpriteWidthSecondValue) { ItemSprite.Width = ItemSpriteWidthFirstValue * (1 - interpolationValue) + ItemSpriteWidthSecondValue * interpolationValue; } if (setItemSpriteXFirstValue && setItemSpriteXSecondValue) { ItemSprite.X = ItemSpriteXFirstValue * (1 - interpolationValue) + ItemSpriteXSecondValue * interpolationValue; } if (setItemSpriteYFirstValue && setItemSpriteYSecondValue) { ItemSprite.Y = ItemSpriteYFirstValue * (1 - interpolationValue) + ItemSpriteYSecondValue * interpolationValue; } if (setWidthFirstValue && setWidthSecondValue) { Width = WidthFirstValue * (1 - interpolationValue) + WidthSecondValue * interpolationValue; } if (setBackgroundRectangleBlueFirstValue && setBackgroundRectangleBlueSecondValue) { BackgroundRectangle.Blue = FlatRedBall.Math.MathFunctions.RoundToInt(BackgroundRectangleBlueFirstValue * (1 - interpolationValue) + BackgroundRectangleBlueSecondValue * interpolationValue); } if (setBackgroundRectangleGreenFirstValue && setBackgroundRectangleGreenSecondValue) { BackgroundRectangle.Green = FlatRedBall.Math.MathFunctions.RoundToInt(BackgroundRectangleGreenFirstValue * (1 - interpolationValue) + BackgroundRectangleGreenSecondValue * interpolationValue); } if (interpolationValue < 1) { mCurrentVariableState = firstState; } else { mCurrentVariableState = secondState; } }