As promised, here's the first post regarding my mysterious "Miniproject" which in all honesty is bigger than AwesomeRPG.
Unlike the AwesomeRPG posts, I won't simply be posting whole classes and explaining the code, but instead will be discussing ideas and plans for the game (Aptly names "Pandaz!") as well as discussing specific functions and snippets of code.
I'll try to include both a bit of discussion and a bit of code in each post, but I can't necessarily guarantee that I'll have new material of both kinds every week.
So firstly to introduce you to Pandaz!
Pandaz! is an online strategy game about growing bamboo (which acts both as food and currency) raising a panda army and doing combat with other panda armies.
It functions both as an Idle game (Such as Cookie Clicker) and as a Strategy game.
The idea is you plant bamboo, and based on how much bamboo you have planted, your bamboo increases at a certain rate.
Thanks to online-ness and servers this happens when not in-game too.
Originally the plan was that the bamboo that is automatically "grown" over time would add to your planted count, and you then had to "harvest" it to turn it into spendable bamboo, but I then realised that this would mean as your bamboo grows, the speed at which it grows increases with it, removing the need to check in every once in a while to plant more bamboo.
So to clarify that there are 2 kinds of bamboo:
Bamboo - Currency, can be turned into planted bamboo
Planted Bamboo - Not currency, cannot be turned back into bamboo but generates bamboo automatically over time.
Bamboo can be spent on Pandas and panda upgrades.
There are currently 5 types of Pandas, originally these were:
But I felt this was a bit too "western" for Pandas, so now it's:
Each type of Panda is strong against one other type, and weak against one other type.
Here's a professional graphic that I totally didn't use MS Paint for:
Spearman > Cavalry > Archer > Monk > Ninja > Spearman
Pandas receive a 100% strength bonus against the type they are strong against, but suffer a 50% strength penalty against the type they are weak against.
All types have the same strength, difference is purely what they're good against. (For now)
I'll discuss the combat system itself more next week, for now let's talk code!
Today I want to talk about something I've never really done before in C#: Launchers.
What is a Launcher?
A launcher is a window, program or form that opens before your main game.
This is more common in online games as it verifies that you are running the latest version and allows you to login etc etc.
Currently the launcher code for Pandaz! is geared towards singleplayer, and simply allows you to either browse to and load a save file, or start a new game.
Here's what it looks like:
As you can see, it's very simple.
I'm not going to discuss how to do the whole Browse... thing and file selection like that, as that's not what we're here to talk about. Instead I'm going to skip the "making of the launcher" and focus on implementing it.
There are 3 main kinds of launcher:
Internal Launchers, like the Pandaz! Launcher, is built into the code itself, and runs from the same .exe as the game.
External Launchers, like the Minecraft Launcher, is an external .exe that checks for updates and logs you in (sometimes) and upon clicking "play" launches the game's .exe file.
Vendor Launchers are launchers that also allow you to buy games. A lot of Vendor Launchers these days simply contain all the games made by that specific company.
Examples of this are the Battle.net launcher by Blizzard and the Glyph Launcher by Trion.
Steam is also a vendor launcher.
I'll discuss Internal Launchers now, and External Launchers at a later date.
By the time you have enough products and fans to need a Vendor Launcher of your own, I expect you'll know how to make one.
The Internal Launcher in Pandaz! case is a simple Windows Form. If you've ever used Visual Studio 2010's default Windows Form Application Template, you may have noticed this line in program.cs:
This is pretty self explanatory, it runs the application.
It takes 1 Form as an arg, and that Form is the form that opens first.
In this case we simply change that to
Load.cs being the name of my launcher's class.
In Load.cs we have all of the usual button logic and such common with this type of Windows Form.
We also have a helper method:
GameInst is a field defined at the top of the class like so:
public Game GameInst;
and "Game" is the name of the main form; the form I want the launcher to run.
So all this small method does is it hides "this" (the launcher) then creates a new instance of "Game", the form we want to run, then shows it and finally hands it the instance of GameSave that was made by the launcher.
The value of "save" is defined as new GameSave(); in the case of "New Game" being clicked, and the loaded data in the case of a save file being loaded.
As I said, it's a very simple concept.
Anyway that's it for today's post!
Next week I'll discuss the Combat system and talk about some of the mathemagics behind the game's logic.
Don't forget to keep an eye out for the rest of Player.cs explained on Saturday!