public PurchaseShipInfoUI(PurchaseShipsScreen purchaseShipsScreen, PlayerShipData playerShipData, Vector2 position, Vector2 size, string dataAsset = "Sprites\\UI\\Menus\\default", BaseObject parent = null) : base(position, size, 0, 0, 0, 0, dataAsset, parent) { PurchaseShipsScreen = purchaseShipsScreen; PlayerShipData = playerShipData; Opacity = 0.5f; }
public void UpdateUI(PlayerShipData playerShipData) { // Change this later to merely change the data rather than destroying and creating new data if (playerShipData != PlayerShipData) { PlayerShipData = playerShipData; AddUI(); } }
private void OnSelectedShipChanged(PlayerShipData newShip) { RefreshStatsColor(); if (newShip == representedShip) { HighlightButton(); } else { UnhighlightButton(); } }
/// <summary> /// Selects the specified <paramref name="ship"/>. /// <para> /// Returns a <see cref="bool"/> which indicates whether it was successful, and a <see cref="string"/> with the error message if unsuccessful. /// </para> /// </summary> /// <param name="ship">The ship to select.</param> /// <returns>A <see cref="bool"/> which indicates whether it was successful, and a <see cref="string"/> with the error message if unsuccessful.</returns> public (bool, string) SelectShip(PlayerShipData ship) { (bool success, string error) = SaveState.SelectShip(ship.Id); if (success) { SelectedShipChanged?.Invoke(ship); } else { Logger.LogError(error); } return(success, error); }
private void ShowShipInfo(object sender, EventArgs e) { Image shipImage = sender as Image; PlayerShipData playerShipData = shipImage.StoredObject as PlayerShipData; PurchaseShipInfoUI currentShipInfo = UIManager.GetObject <PurchaseShipInfoUI>("Selected Ship Info"); if (currentShipInfo == null) { AddScreenUIObject(new PurchaseShipInfoUI(this, playerShipData, new Vector2(Viewport.Width - 150, ScreenCentre.Y), new Vector2(300, Viewport.Height)), "Selected Ship Info", true); } else { currentShipInfo.UpdateUI(playerShipData); } }
private void RefreshStatsColor() { // Color stats based on the chosen ship. PlayerShipData chosenShip = GameManager.SaveManager.GetSelectedShip(); if (chosenShip) { RefreshStatColor(healthLabel, chosenShip.Health, representedShip.Health); RefreshStatColor(accelerationLabel, chosenShip.Speed, representedShip.Speed); RefreshStatColor(shieldLabel, chosenShip.Shield, representedShip.Shield); } else { healthLabel.color = Color.white; accelerationLabel.color = Color.white; shieldLabel.color = Color.white; } }
public bool IsShipOwned(PlayerShipData ship) => SaveState.IsShipOwned(ship.Id);
/// <summary> /// Returns a <see cref="bool"/> that indicates whether the <paramref name="ship"/> is the selected one. /// </summary> /// <param name="ship">The ship to check if it is the selected one.</param> /// <returns>A <see cref="bool"/> that indicates whether the <paramref name="ship"/> is the selected one.</returns> public bool IsShipChosen(PlayerShipData ship) => ship == GetSelectedShip();
public void LoadPlayerInfo(PlayerShipData playerData) { playerHP = playerData.Health; UIhp.text = playerHP.ToString(); }