Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 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();
     }
 }
Exemplo n.º 3
0
 private void OnSelectedShipChanged(PlayerShipData newShip)
 {
     RefreshStatsColor();
     if (newShip == representedShip)
     {
         HighlightButton();
     }
     else
     {
         UnhighlightButton();
     }
 }
Exemplo n.º 4
0
        /// <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);
        }
Exemplo n.º 5
0
        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);
            }
        }
Exemplo n.º 6
0
        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;
            }
        }
Exemplo n.º 7
0
 public bool IsShipOwned(PlayerShipData ship) => SaveState.IsShipOwned(ship.Id);
Exemplo n.º 8
0
 /// <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();
Exemplo n.º 9
0
 public void LoadPlayerInfo(PlayerShipData playerData)
 {
     playerHP = playerData.Health;
     UIhp.text = playerHP.ToString();
 }