I’m making my first game and I try to learn as I go, but i wish to get the best workflow so I don’t struggle too much on the future.
Right now i’m trying to write a script to purchase upgrades so the player can unlock different abilities or other stuff, and I thought about building a game manager script to encapsulate all of these possible upgrades in a single class called “unlockedUpgrade”. The code is bare bones, but it goes something like this:
public class unlockedUpgrade
{
public string nameOfUnlock;
public int levelToUnlock;
public bool canBeUnlocked;
public int neededPixels;
public bool isUnlocked;
public unlockedUpgrade(string name, int lvl, bool canBe, int pix, bool isUnlo)
{
// what is the name of the upgrade?
name = nameOfUnlock;
//Which level does the player have to be to unlock this upgrade?
levelToUnlock = lvl;
// does the player meet the requirements to unlock this upgrade?
canBeUnlocked = canBe;
// how many currency (points, gold, coins, etc) does the player need to unlock this upgrade?
neededPixels = pix;
// is this upgrade already unlocked or purchased?
isUnlocked = isUnlo;
}
// Example for one of these.
// Upgrade is defined as 'firebullet' but the string names it as 'Bullet'
// players need to be at level one to unlock
// upgrade is available to purchase
// player needs 10 points to unlock
// upgrade is not yet unlocked.
public unlockedUpgrade firebullet = new unlockedUpgrade("Bullet", 1, true, 10, false);
}
my plan is to define these sub classes to easily organize the conditions and parameters for a bunch of different abilities. is this a good way to do it?