Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private int[] hullUpgLevels = { 100, 150, 225, 325, 450 };
- private int[] hullUpgCost = { 0, 10, 25, 50, 100 };
- public static int hullLvlIndex = 0;
- // so that i can just reference it from saving
- //also these 2 things always point to the same thing so irrelevant
- private int hullUpgCostIndex = 0;
- [SerializeField] private GameObject[] hullBars = new GameObject[4];
- [SerializeField] private Image[] fuelBars = new Image[4];
- [SerializeField] private Image[] finsBars = new Image[4];
- [SerializeField] private Image[] engineBars = new Image[4];
- private void Start()
- {
- }
- //so this script talks to "playerstats" instance
- //lets debug to see whats up waitbe
- // I can delete playerstats rn and it would fine, everything is still in Player, I just put playerstats for testing purposes
- //just to be sure, what this upgrade is supposed to do is change the player's max health to something larger yes?
- // Increase max health
- public void UpgradeHull()
- {
- if (hullUpgCostIndex < hullBars.Length)
- {
- //its probably this, sec
- //want to check price to next element in array, but not move to it yet
- //post-pre fix operators assign 1 more / 1 less, doing + 1 doesn't change index value
- if (CurrencyManager.Currency >= hullUpgCost[hullUpgCostIndex + 1])
- {
- CurrencyManager.Currency -= hullUpgCost[++hullUpgCostIndex];
- //logic error is you're having 100 as the 1st upgrade (remember 0 count)
- //so the first time this runs thru it evaluates 100 as the "next jump"
- //fix:
- //think about this in a general level
- //that would increment it beforehand, ill explain in a bit
- //this is talking about UPGRADES
- //your base level is fine to have as the 0'th upgrade
- //but when you upgrade, you increase it to 1 not to 0
- //fix:
- PlayerStats.Instance.maxHealth = hullUpgLevels[++hullLvlIndex];
- //now the upgrade here is, we want to toggle the bar whose level we upgraded
- //if its an array, it plays nicely with our indices
- //first update is 0'th element, second update is 1st element, ...
- //problem here too is that it's loading lvl X, but it will toggle lvl X - 1
- //need to put more thought into it
- hullBars[hullLvlIndex - 1].SetActive(true);
- //reason its - 1 is because of the reason above, when we're on 1st update
- //its the 0'th element that we're toggling
- //this approach is fine, use arrays in ur favor
- //hullFillBar1.enabled = true;
- //hullUpgCostIndex++;
- //hullLvlIndex++;
- }
- }
- }
- // Increase max fuel
- void UpgradeFuelTank()
- {
- }
- // Increase turn power
- void UpgradeFins()
- {
- }
- // Increase thruster speed
- void UpgradeEngine()
- {
- }
- public void Load()
- {
- Debug.Log("Loaded Data.");
- hullLvlIndex = SaveManager.LoadData().hullLvl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement