Pocket City
- 30 Devlogs
- 120 Total hours
A game where you try to manage an ever growing city...
A game where you try to manage an ever growing city...
WORKING AIR DEFENCE + ATTACK HELICOPTERS
So we got working air defence turrets with some predictive aiming, and attack helicopters that shoot missiles at random buildings.
Although you’re unlikely to get 3 attack helicopters at once… for now.
The helicopters blades do spin, they bob up and down, they go towards buildings. They shoot out these missiles, which pathfind their way to the targetted building.
They all have a healthsystem which means that the turrets do some damage on collisions only though, one turret might take a while but two (or the 7 you see below) will MOW them down.
Still have to hook it all up to the Finance Manager, Special Building placement and other boring stuff, but…
I need more IDEAS!! (read this thx)
…for more Military stuff that can be added. Tank wars? Who knows. I was thinking of a military invasion as being one of the rare events which spawns like 10 missiles and 5 attack helicopters and maybe a B2 bomber or some stuff. I also need more allied options, maybe I’ll add like an anti-bomb turret that is specifically for the B2 bomber or something and does 100000 damage. Or maybe your own airbase that spawns an allied helicopter and now you have dogwars. or maybe your own plane. idk
So yes @Adam_Lotfalla this is what the helicopter was for.
Yay more things to worry about!!!
Still have integrations left! I’ll see you (hopefully) tomorrow once that’s done. but its midnight now so goodbye.
Hmmmm…
What’s cooking? (Blender just WON’T count toward my hours but prolly spent 2-3 extra hours here)
The helicopter blades actually spin. And W Unity particle system for the missile.
I NEED YOUR HELP
Pocket City already exists as a game. I know this is stupid and I should have checked this before starting since I had the intention of publishing it to steam but here we are.
If you want more details, or more knowledge about the game check this video out: Video
Oops…
UFOs in an Alien Invasion 💔💔
The second rare event addition to Pocket City!
Get a chunk of your population zapped up by some not so friendly aliens…
Any more ideas, let me know below!
But it was pretty neat to implement. 3D modelled it and everything.
3 hours of doing god knows what. Tried to figure quality settings out and probably did smth else but was too busy with the World Cup to remember what I did. Probably bug fixes and stuff.
Oh yeah and you see a pretty cool ripple pulse thing that propogates through the map.
Although it is a little weak right now but i’ll fix that next time. Super tired. mb
Genuinely the worst thing ever. I STILL can’t figure it out but I had to post my weekly devlog anyways. Can you believe we’re 28 weeks into 2026??!
Here’s the chaos where I accidentally created a “Pocket Empire” (Day 1105)
Watch the video (click the title) if you wanna see how I ended up here and a minor crash out. very minor.
Yeah thanks stardance. 10 hour limit for what. Probably spam filter.
Also MASSIVE BUG(s). One is that the game just randomly deletes all the buildings from a chunk. No idea why, I’ve been at it for so long. Another issue is the stupid vacancy counter which has been broken FOREVER but atleast now it doesn’t go negative. I have a serious feeling I will have to spend a week just POLISHING the game.
Whatever, Currently working through a new feature of allowing you to use your money that you spent so long accumulating to try and fix the chaos that you went through.
This is done through the “Council FX” which I may rename if you guys can think of a better name, and you can see the countless things to do such as:
… and many more as well as the ??? at level 100… who knows what that does. £2.5 million btw. Of course, those levels are the XP, which has finally given that a use.
And no you wont be at level 11000 just like that, i’m just being lazy for testing.
Also rebalanced so that all of the commercial buildings have ~10-15% of their previous employment caps. So that you’re not just spamming residential. It also makes industrial more useful as they have more employers even though they produce less money.
I added Arson and added a Police manager that goes out and solves these crimes. Lots more to come, let me know of any ideas you have!
But before that let me teach you ALL something.
I had a bunch of scripts that all did ABOUT the same thing but with different.
This was FindClosestHospital, FindClosestFireStation and the thing I was adding which was FindClosestPoliceStation.
It felt quire redundant to copy the same lines but instead of Hopsital it was replaced with FireStation or PoliceStation.
//Generic functions
private T FindClosestReachableService<T>(Vector2Int targetPos, Func<T, bool> hasAvailableVehicles, out List<Vector2Int> bestRoute) where T : Building
{
T closestBuilding = null;
bestRoute = null;
int shortestRouteLength = int.MaxValue;
bool foundBuildingOfThisType = false;
foreach (var kvp in gridManager.GetMapGrid())
{
GridManager.GridTile tile = kvp.Value;
if (tile.buildingScript != null && tile.buildingScript is T serviceBuilding)
{
foundBuildingOfThisType = true;
if (!hasAvailableVehicles(serviceBuilding)) continue;
List<Vector2Int> testRoute = CalculateRoadPath(tile.buildingScript.gridPos, targetPos);
if (testRoute == null || testRoute.Count == 0) continue;
if (testRoute.Count < shortestRouteLength)
{
shortestRouteLength = testRoute.Count;
bestRoute = testRoute;
closestBuilding = serviceBuilding;
}
}
}
if (!foundBuildingOfThisType)
{
bestRoute = null;
return null;
}
return closestBuilding;
}
Above is an example of the C# generic.
We have “T” type, and I think this is a good place to learn about them.
Instead of defining the function as returning something like Building, we make T a type. and you can see it passed in a little <T> after the function name. We can also pass in entire functions like Func<T, bool> which is utilised as shown below:
Building bestStation = FindClosestReachableService<PoliceStation>(building.gridPos, ps => ps.HasPolice(), out route);
you can see ps => ps.HasPolice() calls that out. And finally, to define what T is meant to be, I’ve added where T : Building.
You can do this many times, such as by having both a T as well as a U! and you’d have a repeated where T : Building where U: PotatoChips or something idk what U is meant to be bro.
This was my first time using it but it’s pretty cool and if you’re using C# I’d recommend learning it as it saved me like 200 lines of code and changing something 3 times to change the same thing!
And yes, I added a third thing which is Arson! which is a crime based thing, and you have a visual that shows up as a timer. if a police doesn’t solve the crime it sets on fire. It’s not too bad but it adds a use for the police, with much more to come for the police to deal with in the future!
Also added asteroid BOMBARDMENT as a debuff. Yeah it’s brutal. 3 strikes… thats up to 108 tiles DESTROYED and set on fire.
BETTER UI + XP
At the top of the image you can see a little progress bar… yep I’ve added XP now. Got plans for that, probably going to allow you to unlock stuff later. Like the lockdown ability etc.
The UI has been overhauled. The actual images are a touch on the placeholder side apart from the road but it looks pretty good. You cycle between road, zoning and special building placement with 1, 2 and 3. Use R to rotate between the modes like residential, commercial and industrial zoning as well as Utilities & Emergency for the special buildings. Then finally T to rotate between those specific buildings.
Complicated? Maybe? But it’s also a lot faster. I have completely lost my muscle memory of spamming R like the “good old days” though.
Looks good? Bad? Horrible update and the game should never be changed ever again? Best update in the world and I should win £1 trillion? What do you think?
MAKE IT RAIN ASTEROIDS
Pretty long run honestly.
But before that, let’s talk about retrofitting your buildings. Earthquakes are pretty bad. Very bad when you loose your 100k building in a moment. So upgrade it. Yes it’ll cost you 35 to 55k now. But is your peace of mind worth that?
And I added asteroids! These fly down and annihilate everything in a 3 unit radius and then set everything else in the 6 unit radius on fire.
Lots of minor bug fixes as well, trying to get the game really polished now. Some rejigging of the game’s back end, such as creating a new abstract class for employer and reworking the systems to ensure that they run more smoothly and I believe almost finally fixing the unemployment/vacancy problem. I say almost because every 5 runs I see the game yell at me that it didn’t count something correctly but honestly I’ve spent so long on this I don’t even know if it’d be harder to just rewrite the entire employment system.
For more detail, see my video linked below! See if you guys like it, my first proper long form
I Added ASTEROIDS that ANNIHILATE your Adorable City
And boy will this thing cook your economy.
POLITICS!! + Debugging Hell v2
I mean I guess it is? Not too sure.
Event Manager completely overhauled. Double events now no longer have the chance of repeating the same event.
Created a new GameEffects script which just takes a bunch of simple code away from EventManager and plays the basic functions such as the “tax revenue increases” which you see below.
This was quite a headache to create, and I severely underestimated how much time this would take. I have 2 extra nested classes inside of EventManager for Political Question and Political Scenario.
[... inside EventManager.cs ...]
public class PoliticalQuestion
{
public string Question;
public TaskCompletionSource<bool> TaskCompletionSource = new TaskCompletionSource<bool>();
public Action onAccept;
public PoliticalQuestion(string question, Action onAccept)
{
Question = question;
this.onAccept = onAccept;
}
}
public class PoliticalScenario
{
public string description;
public Action runnable;
public PoliticalScenario(string featureDescription, Action functionality)
{
description = featureDescription;
runnable = functionality;
}
}
[Header("Political Question Variables")]
public List<PoliticalQuestion> PendingQuestions = new List<PoliticalQuestion>();
public event Action onQueueChanged;
private PoliticalScenario[] goodFeatures;
private PoliticalScenario[] badFeatures;
The political question is sent off to the UI manager, which displays it as shown below. Then it handles user input pressing Y/Enter or N/Esc to accept the user choice, and returns it back to the Event Manager. Seems simple enough, yet there are many ways to do it but I think that the above implementation works the best out of all the ones that I tried. I attempted to use Game Manager as a middleman but that did not work out - so I resorted to passing an entire class.
The political scenario allows for the string to actually do something, so that the game knows what to process and what the user agreed to without creating a bunch of variables, and can allow for stacked political question events which is nice.
Game’s looking really neat, and the multipliers and stuff can make the game go very crazy very quickly.
Too much of a good thing is a bad thing!!
Debugged the entire system for like a solid 3 hours it was actually bad.
Came first in the UK tho!! I’m back after those 6 exams are done.
Yes I know the UI looks pretty bad but it’s good enough for pre-beta testing.
Oh yeah, speaking of UI everything is more bold. Figured out how to do that.
I HAVE A PLANN
For the spinal sprint toward completion. Should end up taking me to hour 70-75? Then we polish the UI and add a main menu… lacking feature I guess.
Anyways, reorganised the code base and split game manager up, created folders and fixed dependencies for everything.
There is now an event manager, which handles all of the events separately, and as you can see from this simple to-do list (should my next project be the to do list to end all to do lists with calendar integration and stuff???) that I have completed the first bit “Weighted Event system”.
So now nothing has an equal chance of happening! Also as a side effect made adding new effects a lot easier due to the nested WeightedEvents class which was similar to an idea I had in my old minecraft mod plugin and transferred the skills across the languages.
Quite nice neat code actually, that isn’t 600 lines long, so I can quickly show it to you below. It’s very applicable and I believe I have used it twice or three times in the past 4 months alone.
The declarations for the events now look like this, very centralised and easy to add/remove events and modify the weightings. Called in the Start() function.
weightedEvents.Add(new WeightedEvent("Nothing", 20, () => { }));
weightedEvents.Add(new WeightedEvent("Earthquake", 5, Earthquake));
weightedEvents.Add(new WeightedEvent("Fire", 40, SetBuildingOnFire));
weightedEvents.Add(new WeightedEvent("Virus", 20, () => { TriggerVirusOutbreak(); } ));
and the class is just simply storing the name, the weight and a weighted Event.
public class WeightedEvent
{
public string name;
public int weight;
public Action weightedEvent;
public WeightedEvent(string name, int weight, Action weightedEvent)
{
this.name = name;
this.weight = weight;
this.weightedEvent = weightedEvent;
}
}
we do need to store the total weight which happens on the Start() function currently. When playRandomEvent() is called, we increase the cursor by the event’s weight until it is greater than the rolled random number between 0 and the total weight, at which point the class’ event is called.
Broke nothing in the end!
That’s great isn’t it, especially after migrating a bunch of “legacy” code. Hopefully didn’t jinx it.
Okay now i SUCK at my own video game.
Don’t worry it’s hard mode. Also lost 2 hours of work somewhere cuz it didn’t save? Don’t understand how. That’s always great isn’t it.
But still, 62 days in and I’m fried because of one silly mistake I made 40 days ago. Really teaches you consequences I guess.
Spent my time completely overhauling how everything works. You used to make too much money, so I made the revenue even more population based, by making the max revenue a multiplier of the max population.
Completely rewrote the losing population, unemployment and vacancy calculations to prevent strange negative numbers which was irritating me for the past one and a half weeks.
Also overhauled the inflation to use a formula instead of a very rudimentary lookup table from if statements which is staged into a end-game (130 days+) and early game stage with 20% and 2% simple interest respectively (no not compound for once - that would make the game too hard. Extreme mode?)
The game is actually like a good game now. I don’t know how to explain apart from that though.
I FINALLY LOST IN MY OWN GAME!!
Rebalancing the game slowly but surely. Currently added inflation, which increases the price of everything as the days go by. It gets less severe the longer you play but the inflation rate stays high.
The game days now vary, take 5 seconds at the start and slowly get faster and faster toward 1.5s linearly.
The inflation rate also increases with bands as the game progresses so you need to keep up.
This makes the game a good progression, but make one mistake during an earthquake and it might be ggs for you.
There is now finally a game over function… although no restart but don’t worry about it. It just pauses the game and tells you that the game is finished.
Next up: Detailed Finances, Rubbish? (follow thx)
Currently rebalancing the video game to make the game progression more realistic as it is currently extremely difficult at the start and stupidly impossible to die toward the end.
Completely forgot to tell you guys that you can follow my projects on my YouTube: Video
Like & sub if you can… mb for the self promo though.
Sadly I have 6 exams next week so the next 2 weeks are most likely going to be slow ones… not dominating the leaderboards anymore.
Working healthcare!
The game now has a virus… and it spreads pretty quickly. Houses get infected, added to the random event chances on top of earthquakes and fires. I created hospitals that dispatch ambulances as required. Now all services cost money. Using the same A* algorithm from last time, but a little more complex due to the nature of the virus spreading to random buildings. This requires the game to check for any viruses.
I created an UI that displays the day progression, using actions & delegates again. The day length is now no longer fixed, but instead it becomes smaller the longer you stay on the map, to try and add difficulty ramping.
The game is currently very difficult at the start and incredibly easy at the end, so I’m trying to reverse this a bit and make it hard at the start but terrible towards the end.
Also just realised there’s no ending lol - you just become broke and softlock yourself. Never done it to myself which really speaks out about how UNBALANCED the game is.
I think it’s time to work on game balancing now before implementing new features, and over half way to shipping? maybe at 65-80 hours in at this rate?
WORKING PATHFINDING ON THE GRID!
Created new assets so the game looks complete now!
You can see the firetruck going from the Fire station all the way to the burning building where it will extinguish it. Yes, it follows the roads as intended and uses the A* algorithm to figure out the best path. And they shoot water out, so visual feedback for everything.
This was super fun as it was the first time I’ve implemented the A* in a video game on a grid that procedurally generated.
The coal power generator, fire station and fire trucks have models now, I think I made them good enough to fit with the game. Police station and healthcare to still be implemented but it’s looking good so far.
This required creating a new services manager, creating a pathfinding script, updating global services and how everything interacts with the fire, and creating reverse pathfinding and small details.
It’s coming together really cleanly now.
Debugging HELL
I added fires, which you can see in the corner. Unity Particle system actually really cool for that by the way.
This forced me to rewrite how fires work and add new bits to the Building parent class. That was fine.
Had to update the UI to show you that an earthquake was happening, which works more reliably than last time and I figured the ghost error out.
I decided to implement water & energy requirements. Overhauled ChunkManager to allow for this, as each chunk needs enough. If it doesn’t produce enough, it imports from other chunks. If it can’t do that, everyone starts packing it up and leaving. Added this to city stats. Then modelled a cute little water tower as you can see below. Then I added energy, lots of chaos. Trying really hard to avoid circular loops to avoid a stack overflow, but it’s looking pretty good.
User warnings now show up, like when an earthquake happens, or if a building burns down or if you can’t do something or don’t have money for something.
Now I think I have time to do the fun part - creating chaotic fun stuff to make the city feel even more alive. But it’s looking pretty good right now.
It’s getting close to being shipped, almost 40 hours in. Like & follow for the link ;)
Now I really need to sleep. OH NO AND REVISE FOR THE PHYSICS TEST ON TUESDAY
It’s been a really long time since I’ve posted.
Some progress going on here.
Little sneak peak of the fires… yep. You thought the game was gonna be peaceful?
On another 7+ hour sprint today
Clean codebase always pays off (unless you want to keep your job apparently?)
Fixed the vacancies counter, as before I was using = instead of +=. Told you it’s the little things that catch you out.
Created a safer version of the draft forceRemoveElement() that accounts for jobs and residents when destroying a building (houses/shops/industry). This now updates the game realistically, e.g. if you destroy a house, then you reduce from the population. If the residents were employed, then it removes positions from buildings. If they were unemployed, then we remove it from the stats.
Since I am not storing direct references between buildings but creating a game pool for performance, this makes the operations require lots of calling. This could probably be optimised in the future but I will do that near the first release due to the ever-changing code base.
This required updating GameManager.cs to have LosePopulation(), LoseJobs() with a helper RemoveWorkersFromBuildings() function. Luckily the lists in GridMananger that I made like 20 hours ago for “future proofing” came in useful.
Finally, you can press F to show city statistics and it updates in real time.
What’s the difference between these two:
int maxEmployees = 50;
int employees = 25;
float taxRevenue = 1500.0f;
ONE : float revenue = (employees / maxEmployees) * taxRevenue;
TWO: float revenue = (employees * taxRevenue) / maxEmployees;
Mathematically, they’re the same. a/b * c = c/b * a
However, I missed one thing while coding (a lot harder to see when it’s not just this). They’re both integers. now what C# does is it divides 25/50. we get 0.5. but they’re both integers, so it tries to store it as an integer, which floors it to a 0. Therefore, it’ll suddenly jump to max revenue when the company is full. obviously not what was intended.
Option 2 makes you multiply the integer with a float, and stores 25 * 1500 as a float, which can now be nicely divided by 50 to get the value that we inteded.
Sometimes… actually, no MOST of the time it’s the little things that catch you out.
Anyways, this has very much balanced the game. The companies get as many employees as they can, then grow by 1 employee each day. Their revenue scales with the employee count, so now residential houses are useful for once. If anything, essential.
Next up: Road tax, Land tax. This might be the one time you want tax… or maybe it’s too much?
Sometimes, the most productive thing you can do is destroying everything for a clean slate.
So that’s what I did and refactored my codebase, painting my GitHub red. The old city generation code ended up becoming messy spaghetti code that made it difficult to debug and work on it. And that sort of legacy code when I look back in a month is what ends up shelving projects for years on end. This half an hour will save me many in the future.
I also removed the cluster expansion method of building expansion completely as it created annoying expansions that didn’t make sense of everything being 1 square off a road.
Also created a GameManager and moved aspects of GridManager and FinanceManager to the new script, to try and centralise the logic and stop having random bits such as the day manager in the FinanceMananger, which didn’t make an sense.
Also yes, I wasted 20 minutes trying to figure out what was going wrong when I forgot to add GameManager.cs to the scene 💔
It can’t POSSIBLY BE THAT HARD CAN IT?
No but you have to mix up TAGS AND LAYERS. There’s some error you got 5 builds ago but NEVER APPEARED AGAIN. EVEN HOURS INTO TESTING. HOW DID IT FIX ITSELF?!
The UI now updates how much you gained in the past day!
But anyways, you can finally toggle between the layers… after too much debugging (and realising it was just me being stupid).
But it’s okay I’ll hopefully get that laptop from this blood sweat and tears.
Look how gorgeous it looks now!
Did you know it costs more to remove a road than create one?! Strange…
Finally have a working economy in the game now!
It’s VERY unbalanced. You WILL become very rich. And residential is currently useless, and everything just has a set employee count for now. But that will change soon, and we’ll make the game intelligent. Also the game clock is currently in the Finance Manager which is a little odd so maybe I’ll fix that later.
But, I have used actions & delegates to optimise the game handling of the ridiculous amount of scripts for each building that will be running once the cities become larger and larger. Created a UI manager to update the script, which uses the above actions & delegates from the script manager. Created a Finance Manager which led me to have to recode GridManager for monetary support, but that was honestly less painful than it sounds.
I also spent a considerable amount of time debugging last post’s Zoning. The code has multiple ways of producing a building and this caused me to have to go back and go through all of the code line by line to figure all the pathways out and debug it eventually.
And yes, as promised I made it cost money to zone. Every action, such as creating a road and destroying them cost money and using my amazing research skills of using the first google result, destroying a road costs double placing a road!
I think I should sleep. See you soon!
CITY ZONING!
Annoyed that a massive skyscraper decided to spawn right next to a nice cozy cottage? Not anymore!
You can zone areas by residential, commercial and industrial. There is also a “No Build” zone for areas that you just want to keep clear for now.
This will eventually cost you money, because paperwork is really expensive apparently. (And to keep the game balanced of course).
But there’s no money yet. I think you should like & follow to see how the game’s economy works.
Pocket City Dev 5
The terrain was a little bland, so I decided to spice it up with nature.
To fill the grid up, I decided to implement trees. Created a few basic tree grid varieties and implemented it into GridManager.cs. However, this forced me to spawn all of the trees in the Start() function which causes a longer loading time, CPU spike and worst of all it makes it so that after the initial radius no more trees spawn. Increasing the radius exponentially increases the amount of trees being added (because each ring has more grid sections to cover). So i had to pivot.
I created a new Chunk Manager, split the main grid up into 16x16 chunks, and checked the player camera and only loaded the surrounding chunks. This makes trees spawn around the player continuously. However, this would become laggy as it would happen every frame.
Two ways I decided to prevent this:
And that completes the visuals for now. Probably will add more foliage and other variety in the future, but for now this will suffice.
Finally, this has a severe performance penalty. To cater for lower-end devices, I added a toggle which will later come to a settings menu for ~4x the performance without impacting gameplay. Optimisations, such as chunkloading and LODs will be added later to increase the performance with trees, but that will come after the core game is finalised.
Hello everyone!
The city is finally generating. They automatically generate alongside roads or try grow in clusters with each other. Game looks pretty sweet.
Almost 9 hours in, I think it’s time to get some sleep now.
Coming first in the UK leaderboard is pretty honourable.
Anyways, working on Pocket City and we’ve almost got generation of buildings and I’ve got a lot of things lined up for this project. I really need that framework 12 💔. The roads have a cursor and you can destroy and create them in a row as well, camera movement is more polished with a sprint key. Got all the building assets and everything ready.
What a entry to stardance & hackclub!
Procedural road addition, so that when you add a tile (which is still done through code currently), it will decide which road layout to add, be it an intersection, 4 way, 3 way, a road turn or anything else.
Added clean camera movement with WSAD + scroll as well.
Hello! I’m working on creating a top-down 2D-styled but 3D game where you control a city. I’ve got this grid layout so far and it works fabulously and I somehow got the rotations correct on the first try 🤣