Reskin Walkthrough
This page will explain how you would go about implementing a new 'skin' in the game. Specifically, we will be implementing a farming-themed skin.
Important: Make sure Unity isn't set to compile for 'WebGL Platform'. To check this, go to your build-settings (File->Build Settings...). If it is set to WebGL, click on 'Dedicated Server' and press the 'Switch Platform' button in the lower right-hand corner of the window.
Defining the Game Version
You'll need to add
FarmingGame
to the 'GameVersion' enum in 'Assets/Scripts/CompanyMap/Master.cs'
Adding Building Sprites
In 'Assets/Scripts/CompanyMap/Master.cs', add
[Header("Farming Game")] public Sprite SpriteFarmhouse; public Sprite SpriteField; public Sprite SpriteChickenCoop; public Sprite SpriteBarn;
When you now open the 'Assets/Scenes/Pearhub'-scene and click on '_Master' in the Hierarchy, you should see the sprite variables you just added in the Inspector.
Now create a new folder in 'Assets/Images/CompanyMap' and name it according to the skin you are creating. Since we are creating a farming-themed skin, we will be naming the folder 'FarmingGame'.
Then drag the building images into the newly-created folder.
Note that newly added Sprites must be set to be centered bottom center, so that they will align with all other sprites.
After the images have been added to the project, drag the images into their respective variable-slots in the Inspector of _Master. Note that, if you're using SVGs, you will need to click on the arrow to the right of the image and drag the sprite-file instead of the SVG-file.
Adding the Stats
You need to add stats that every employee has. To do this, create a folder called 'FarmingGame' in 'Assets/Scripts/CompanyMap/Employee/StatTypes'. Then create
AgricultureStat.cs AnimalHusbandryStat.cs ForestryStat.cs MechanicsStat.cs
scripts inside of that folder.
Note that you should create exactly 4 stats, as this is the number the game was designed and tested with. However, it is technically possible to have more of fewer. If you want to experiment with the number of stats, you should thoroughly test everything before shipping.
Once you've created the scripts, open them and replace
: MonoBehaviour
with
: StatType
After you've done that, your IDE should underline the class-name and warn you that you need to implement inherited methods. If you hover over the class name with your mouse-cursor (or press Ctrl+. while your text cursor is on it), you should be prompted to implement those methods.
Simply follow that suggestion by your IDE and it will automatically create all methods required.
After you've done this, all your methods will throw 'NotImplemented' exceptions. You'll need to replace these exceptions with whatever makes sense for your stat type.
If you don't know what a method is for, you can hover over the method name with your mouse-cursor to get a brief summary of what the method should do. You can also look at how other stat types implemented that method.
Once you've defined your stat types, you need to register them in 'Scripts/CompanyMap/Employee/StatTypes/StatTypeInstanceManager.cs'. To do this, add the following lines to the 'RegisterAll' method:
// Farming Game Register<AgricultureStat> (Master.GameVersion.FarmingGame, 1); Register<AnimalHusbandryStat> (Master.GameVersion.FarmingGame, 2); Register<ForestryStat> (Master.GameVersion.FarmingGame, 3); Register<MechanicsSkill> (Master.GameVersion.FarmingGame, 4);
(The number to the right of the comma is the stat's unique ID.)
If you should ever need to remove a stat after you've shipped the game, make sure that you don't override it's ID with a different stat. If, for example you want to replace Forestry with tractor-driving, comment-out the
Register<AnimalHusbandryStat> (Master.GameVersion.FarmingGame, 2);
line and add a
Register<TractorDrivingStat> (Master.GameVersion.FarmingGame, 5);
beneath MechanicsSkill.
Adding the Building Type Definitions
Create a 'FarmingGame' folder in 'Assets/Scripts/CompanyMap/Building/BuildingTypes' and create
Farmhouse.cs, Field.cs, ChickenCoop.cs, Barn.cs
scrips inside that 'FarmingGame' folder.
Once you've created the scripts for your new building types, you'll need to edit them. Firstly, you should replace the
: MonoBehaviour
with
: BuildingType
After you've done that, your IDE should underline the class-name and warn you that you need to implement inherited methods. If you hover over the class name with your mouse-cursor (or press Ctrl+. while your text cursor is on it), you should be prompted to implement those methods.
Simply follow that suggestion by your IDE and it will automatically create all methods required.
After you've done this, all your methods will throw 'NotImplemented' exceptions. You'll need to replace these exceptions with whatever makes sense for your building type.
If you don't know what a method is for, you can hover over the method name with your mouse-cursor to get a brief summary of what the method should do. You can also look at how other building types implemented that method.
Once you've defined your building types, you need to register them in 'Scripts/CompanyMap/Building/BuildingTypes/BuildingTypeInstanceManager.cs'. To do this, add the following lines to the 'RegisterAll' method:
// Farming Game Register<Farmhouse> (Master.GameVersion.FarmingGame, 1); Register<Field> (Master.GameVersion.FarmingGame, 2); Register<ChickenCoop> (Master.GameVersion.FarmingGame, 3); Register<Barn> (Master.GameVersion.FarmingGame, 4);
(The number to the right of the comma is the building type's unique ID.)
If you should ever need to remove a building type after you've shipped the game, make sure that you don't override it's ID with a different building type. If, for example you want to replace Farmhouse with Tractor, comment-out the
Register<Farmhouse> (Master.GameVersion.FarmingGame, 2);
line and add a
Register<Tractor> (Master.GameVersion.FarmingGame, 5);
beneath Barn.
Changing the skin
Select the '_Master' GameObject in the hierarchy and switch the 'Current Game Version' variable in the inspector to 'FarmingGame' (the name you created earlier).
Now, when you start the game, you should see that your changes have taken effect.
Localisation
Currently, the labels of the buildings in the store still print the translation-string. To change this, we'll need to add translations for the languages we want to support.
Go to 'Assets/Resources/localisation' and right-click on a file, then open it in your file-browser (Explorer in Windows).
Your file-browser will open. Now, right-click on the language-file you want to edit and open it with a Spreadsheet-editor (e.g. LibreOffice Calc, Microsoft Excel). Set the separator to 'Semicolon' (;) and disable all other separators.
Add the translation-strings of the buildings you created in the first column and their translation in the second column. You can add the rows anywhere you like, though it might be a good idea to keep the localisation-files organised.