Devlog #45 - HubSystem - UpgradeSystem, rewriting of the system, Enum type/scriptable object --- Industry Ui

 ***HubSystem - introduced and upgraded upgradeSystem now with scriptable objects - same as cityEnum in previouslog. Industry Ui finished. *** 



HubSystem:

Its actually pretty similar model to what I did with the cityTierEnum. Now we have her hubTier , or in this example we are using hubType, because there is 5 different types of Hubs.


For those who don't know, hub is like a transportHub, which holds trucks. That is the logicistical part of this game, so if you want to use more trucks, you need a place to have them, and thus you have to upgrade the hub. 

Same as before, the original hubSystem used the old way of upgrading, so we had 

hub Struct and we said, size =1;

then in hub System we said something like , 

hub.maxTrucks = size *5; 

then the upgrade would be 


handleHubUpgrade ()
{
    hub.size +=1;
}


But we changed this for many reasons, except it is hard coded, the growth is always linear. And even if we did make it non linear, for example , hub.maxWorkers  = size * 5 * tier ; we would still get linear but slightly unpredictable behaviour, plus we couldn't just say and decide the name of those hubTypes, ( Small hub, medium Hub, logistical center...etc) as well as upkeep cost, amount of Trucks, ( maybe we want first to have 5 second 15, third 30, and 50) , and also later when we get assets made then the images will change depending on the Type.


So with Enums again and scriptable object we created a database for which will hold all these values. and then just call when we need it and again upgrade it with using the enum. Just an example : 

public static void HandleHubUpgrade(ref HubState hub, HubDatabase hubDatabase)
{
if (hub.hubType >= HubType.CentralLogisticsPark) return;

//konvertovanje i dodavanje novog enuma u hubType enum, bez koriscenja tier-ova.
hub.hubType = (HubType)((int)hub.hubType + 1);
hub.isUpgrading = false;

UpdateHubInformation(ref hub, hubDatabase);

}


Relatively simple fix, but on the long run way better.


So how it acutally works? very Exciting!!! ***SPOILER ALERT **** 

So first run this method, charge the money and say isUpgrading= true, right? but what does it do?

So the system i designed is very simple, it takes certain amount of days to upgrade. The bigger the Hub the longer it takes (construction..its realistic..hah) so, then, somehow we have to make it each day deduct a day before it can create it. But the money is already taken as we noticed.


So what we did, is simply attach the same structure on the Tick for each day, and it only asks this :

if (hub.isUpgrading) UpgradeTick(ref hub);


If true, the Upgrade tick deducts the -1 to the total days needed for upgrade, until it goes to zero, at which point it handles actual upgrade, as we already had before  hub.hubType = (HubType)(int)HubType +1;
and resets the isUpgrading to false,and thats it! Simple yet very clean and organized. Only thing is left to do is in the inspector to adjust and balance later how many days and the cost.

Problem that appeared: The cost for upgrade, i first put it into the inspector for heac Hub, instead for hubType+ 1. Let me expain, hubType small hub has upgrade of 15000 , medium Hub costs 30k. But when we call the price for Upgrade from the first to second the price reads fromthe currentHub, so we read the 15k instead of 30k. After trying lots of +1 -1 and other nonsense, the easy SIMPLE (freaking) SOLUTION was to simply put the price of Upgrade and make the "constructionCost' as a new variable inside the hubData. Yeah its dumb. but I am learning as well. Love it.




___________________________________________________________________________


Industry UI- Just attached to the system we had (That will need rework asap..the system.....in next devlog) 

-it takes all the info, just shows it, but its updated, and now it looks real slick. Althought there are some errors still, and tweaks will be made, also the charts hhave to be made. If you remember, snapshots, (reminder, a list of structs that have variables like, currentTurn, currentProduction, productPrice, and that is memorized each day). so the chart later will show the progress of production, the changes of the price etc..just fun DATA , for me at least.


So from the original draft, to the interface that fits with the rest of this game!!

how cool? But agian, needs more polishing, and more information better organized..


Thank you!! 


Comments

Popular posts from this blog

Devlog #47 - TaxSystem/FinanceSystem ,Update-FIx -LoanFixes-- TruckSystem Update - Upgrade/BuyNEwTruck - Costs Prices introduced / OfficeSystem CreateNewOffice, upgrade office - other Fixes

Devlog #46 - HubSystem - CreatNewHub added, HubBuild Ui + INdustrySystem Update - -INdustryTierData to be combined with the IndustryData and IndustryState struct -

Devlog #49-50 - Asset System-NEW system, *Game Design* -construction costs update - LoanSystem- fix-redesign-upgrade,Bug fixes-storeSystem,AutoAdvance Day, Market system, Truck System cost redesign, refactored, Ui bug fixes