In the Realm Rush part of the course, there are a lot of variables that have to be tweaked carefully for the perfect balance. Since it would be tedious to always keep going back and forth in the inspector, i had the idea to make a script that holds all the variables needed.
This is how its working out so far…
using UnityEngine;
public class VariablesScript : MonoBehaviour
{
[Tooltip("Location: ")]
[SerializeField] int CostOfPlacingOneTurret = 30;
[Tooltip("Location: ")]
[SerializeField] int RewardForKillingTheEnemy = 20;
[Tooltip("Location: ")]
[SerializeField] int PenaltyOrAmountEnemyWillSteal = 10;
[Tooltip("Location: ")]
[SerializeField] int StartingAmountOfGoldGivenToThePlayer = 150;
[Tooltip("Location: ")]
[SerializeField] int MaximumHealthOfAnEnemy = 10;
[Tooltip("Location: ")]
[SerializeField] int AmountOfDamageDoneToEnemyDueToCollisions = 10;
[Tooltip("Location: ")]
[SerializeField] int HealthIncreasePerEnemyDeath = 10;
[Tooltip("Location: ")]
[SerializeField][Range(0f, 5f)] int SpeedOfTheEnemy = 1;
[Tooltip("Location: ")]
[SerializeField] float TimeItTakesForNextEnemyToSpawn = 3;
[Tooltip("Location: ")]
[SerializeField] int RangeOfTheTurrent;
Turrent turrent;
Enemy enemy;
BankScript bank;
EnemyHealth enemyHealth;
enemyScript enemyScript;
EnemySpawner enemySpawner;
private void Awake()
{
turrent = GetComponent<Turrent>();
enemy = GetComponent<Enemy>();
bank = GetComponent<BankScript>();
enemyScript = GetComponent<enemyScript>();
enemySpawner = GetComponent<EnemySpawner>();
enemyHealth = GetComponent<EnemyHealth>();
}
private void Update()
{
}
}
Now i would need to make every variable PUBLIC so that i can access these in the script. But i feel like there is a better way to do this instead of doing such a tedious process.
Later on, i also plan to make a difficultyScript that dictates and UPDATES some variables like enemy speed, hitpoints etc so that i can adjust the difficulty as the game goes on. So please give me some suggestions about that as well.
The only reason i want to do all this is because i want to keep the code clean and restrict the number of actions one script is performing and make it easy for testing the game.