Exemple #1
0
        public static bool TryGetObjectsOfType <T>(out T[] objectsFound) where T : Object
        {
            objectsFound = Object.FindObjectsOfType <T>();
            if (objectsFound == null || objectsFound.Length == 0)
            {
                Logger.LogError($"Couldn't find any objects of type '{typeof(T).Name}'.");
            }

            return(objectsFound != null && objectsFound.Length > 0);
        }
Exemple #2
0
        public static bool TryGetObjectsWithTag(string tag, out GameObject[] objectsFound)
        {
            objectsFound = GameObject.FindGameObjectsWithTag(tag);
            if (objectsFound == null)
            {
                Logger.LogError($"Couldn't find any objects with tag '{tag}'.");
            }

            return(objectsFound != null);
        }
        public ActivePowerup GetActivePowerup(int index)
        {
            if (index < 0 || index >= ActivePowerupsCount)
            {
                Logger.LogError($"There's no active powerup at index({index}).");
                return(new ActivePowerup());
            }

            return(activePowerups[index]);
        }
Exemple #4
0
        public static bool TryGetObjectOfType <T>(out T objectFound) where T : Object
        {
            objectFound = Object.FindObjectOfType <T>();
            if (objectFound == null)
            {
                Logger.LogError($"Couldn't find an object of type '{typeof(T).Name}'.");
            }

            return(objectFound != null);
        }
Exemple #5
0
        public EnemySpawnInfo GetEnemy(int index)
        {
            if (index < 0 || index >= EnemyCount)
            {
                Logger.LogError($"The index ({index}) was out of bounds of the 'enemiesToSpawn' array.");
                return(null);
            }

            return(enemiesToSpawn[index]);
        }
 private void Start()
 {
     if (startWeapon == null)
     {
         Logger.LogError("No start weapon was specified. Please assign a start weapon.");
     }
     else
     {
         ChangeWeapon(startWeapon);
     }
 }
        /// <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);
        }
Exemple #8
0
        private void RefreshUI()
        {
            if (!representedShip)
            {
                Logger.LogError("Failed to refresh UI. Missing reference to player ship data.");
                return;
            }

            icon.sprite            = representedShip.Sprite;
            nameLabel.text         = representedShip.DisplayName;
            healthLabel.text       = representedShip.Health.ToString();
            accelerationLabel.text = representedShip.Speed.ToString();
            shieldLabel.text       = representedShip.Shield.ToString();
            priceLabel.text        = representedShip.Price.ToString();

            // Check if owned and then hide the price if it is.
            CheckOwnedState();
            HighlightButton();
            RefreshStatsColor();
        }
        private void Awake()
        {
            GameObject playerObject = GameObject.FindWithTag("Player");

            if (!playerObject)
            {
                Logger.LogError("Could not find player object.");
                return;
            }

            if (!playerObject.TryGetComponent(out healthComponent))
            {
                Logger.LogError("Could not find Health component on player object.");
            }

            if (!playerObject.TryGetComponent(out shieldComponent))
            {
                Logger.LogError("Could not find Shield component on player object.");
            }
        }