Hello there,
I am Floris Weers, CEO of WeersProductions. We are happy to announce our upcoming game: Rule Your School!
A short summary of what you can do in the game:
-
Design and build your own school. What kind of school do you want to build?
-
Hire teachers, train them and configure their loans. Make sure they are happy and don’t run away!
-
Gather new students if your school is big and good enough.
-
Keep your students happy and healthy. Select what food is available in the canteen and set their prices. Everything affects everything. Make sure you make the right decisions!
-
Newspapers, students and teachers will ask or mail you. How will you respond to their questions and how will it affect your school?
-
See detailed statistics about your students and teachers to know how to respond to certain events!
-
Unlock more objects and more possibilities as you play, to make sure your school is up to date!
-
Enjoy the classic mode where you start from the bottom, or go with sandbox and build the school of your dreams out of the box!
Learn more about Rule Your School here.
But how did we do it and what are we going to update?
Pathfinding:
We wanted a lot of characters calculate individual paths without lag. Therefore we created a 2D path finding system using the A* algorithm. A character requests a path and sends a delegate as parameter.
PathRequestManager.RequestPath(currentCoords, targetCoords, OnPathFound);
currentCoords: The coordinates the character is right now.
targetCoords:The coordinates of the goal the character wants to go to.
OnPathFound: A delegate function
public void OnPathFound(Vector2[] NewPath, bool PathSuccesfull)
{
//Do stuff with our path if it is succesfull.
}
The path finder controller will create a second thread. This thread will calculate all paths that are requested and will add the result path to a queue. A coroutine will check if the result queue is not empty, if it isn’t it will call all delegates and pass the result path.
That way the path is calculated on a different thread, but the delegate is called on the Unity thread. With this system, the path finding is not creating any hiccups.
Building objects:
In Headmaster over 150 objects are ready for you to use in your school. This means we needed a system that allowed us to easily add or remove objects.
A base class BuildObject contains different variables like: BuildingName, Costs.
Various child classes are:
Walls
The user builds a wall to create a classroom. The user drags the walls to make the classroom bigger. If two rooms are connected to each other, one of the walls is set to inactive.
Windows/Doors
A wallobject can be replaced by a window/door. The wallobject is set to inactive, if the user wants to remove the door/window the wallobject will be set active again. A variable CanWalkThrough is used in the pathfindingsystem to check if a character can walk through it. Doors will have this set to true, windows to false.
Floors
The user builds all objects on a grid of simple planes. When building floors, the material of the selected plane will be set to the selected floor. To make sure not hundreds of material instances are created, the sharedMaterial (https://docs.unity3d.com/ScriptReference/Renderer-sharedMaterials.html) array is used in the renderer. If the user double clicks on a grid, it will check if the user clicks inside a classroom, if he/she did the complete room will be filled with the selected floor.
Wallpapers
When building a wallpaper, clicking on a wallobject will change the room’s wallpaper. The user can only change the wallpaper on the inside. If any wallobject is replaced by a window/door, the window/door will also get the new wallpapermaterial.
Building (a normal object like a chair)
A building contains an array of coordinates that it needs for building space. These are local coordinates. If a chair+table would need two blocks of space, the array would be:
0,0;0,1
While dragging the building around it checks if these coordinates, translated to world coordinates, are free. If they are, the building can be placed there.
Extensions
To make sure we could handle a lot of objects, we made an editor extension. It shows a list of objects that are in the game and pressing on one of them gives details. The editor extension has an icon creator in it, so every object icon has the same angle and is easily generated.
Save system:
The whole map has to be saved. This means quite a lot of data. We wanted to make sure it was readable for the human eye for debugging purposes. We created our own text based save system.
Example: we want to save the ID of the building at coordinate 23,18 along with the rotation of the building.
ID = 4
Rotation = 2
SaveLoad.SaveBuilding(new vector2(23,18),ID,Rotation);
public static void SaveBuilding(Vector2 Coordinates, int BuildingType, int Rotation)
{
string SaveName = string.format("Grid#{0},{1}",Coordinates.x, Coordinates.y);
SaveSimple(SaveName + "#BuildingType", BuildingType);
SaveSimple(SaveName + "#Rotation", Rotation);
}
This is simplified version of the saveBuilding function.
This information is now added to a save queue, so we can save it to disk whenever we want (for example when the user presses ‘save’).
If the user has saved a file with the following data will be made:
Grid
#
23,18
#
BuildingType = 4
Rotation = 2
#
#
If we want to load the data we call:
SaveName = “Grid#23,18”
SaveLoad.LoadSimple<int>(string.Format("{0}#BuildingType", SaveName))
And
SaveLoad.LoadSimple<int>(string.Format("{0}#Rotation", SaveName))
This would give us the BuildingType and the rotation.
Because it is string based it is not the fastest save system, it is a very easy one though.
Student animations:
Every student has his own Animator Controller and is mecanim based. All animations move the root bone to make the animations look more realistic. In the Animator Controller a lot of parameters are available that allow us to define what animation it should do. E.G.: Dancing, Sitting, but also MoveSpeed. The speed of every animation is controlled by a parameter AnimationSpeed. That way when the user speeds the game up, every animation is going faster.
Different menu’s:
In Rule Your School a lot of different menu UI will show up. We’ve two canvasses. One for all menu’s and one for world space canvas with messages from the students or teachers.
The UIController contains an Enumerator with all available menus. When the user clicks on a button, this is used to close the last menu and start the new menu.
Music system:
In the game there is always music playing on the background, unless the user has decided to put it off ;).
To control all music and the different playlists the user can activate using radio objects, an editor extension is created. We can define the content of each playlist and set fade in and outs. This way the user will never get bored of the music! Each playlist has the property to play random or in sequence. That gives us the full freedom to make the playlist how we want it.
Of course a lot more decisions are made, but that’s for next time! If you have any questions, feel free to ask and I will try to answer them!
Check our website for more information http://www.weersproductions.com about who we are and what you can do in the game!
~WeersProductions