コード例 #1
0
        public void ShipSelected(ShipMetadata shipMetadata)
        {
            _shipMetadata = shipMetadata;

            if (shipMetadata != null && SelectedShipPanel != null)
            {
                if (ShipCostText != null)
                {
                    ShipCostText.text = shipMetadata.Cost;
                }
                if (ShipMassText != null)
                {
                    ShipMassText.text = shipMetadata.Mass;
                }
                if (ShipNameText != null)
                {
                    ShipNameText.text = shipMetadata.Name;
                }
                if (ShipThumbnail != null)
                {
                    ShipThumbnail.sprite = Sprite.Create(
                        shipMetadata.Thumbnail,
                        new Rect(0f, 0f, 256f, 256f),
                        Vector2.zero);
                }
                if (!shipMetadata.KonstructorMetadata.CanSpawn)
                {
                    DisableBuildButton();
                    ShowAlert(_konstructor.InsufficientResourcesErrorText);
                }
                else
                {
                    EnableBuildButton();
                }

                ShowColumns();
                ClearResources();
                UpdateResources();

                if (!SelectedShipPanel.activeSelf)
                {
                    SelectedShipPanel.SetActive(true);
                }
            }
        }
コード例 #2
0
 public void BuildShip()
 {
     if (_konstructor != null &&
         _shipMetadata != null &&
         _shipMetadata.KonstructorMetadata.CanSpawn)
     {
         try
         {
             _konstructor.LaunchVessel();
             HideColumns();
             HideSelectedShip();
             _shipMetadata = null;
         }
         catch (Exception ex)
         {
             ShowAlert(ex.Message);
         }
     }
 }