Developer Wiki - DVSProductions/Cyber-Siege GitHub Wiki

Intro

This page is mainly intended for the developers of this game. If you are not a developer this page may not have any useful information to you but feel free to read it as it may have some useful information for you own projects!

Scenes

Ingame Scene

The ingame scene is the scene that will always be shown when the user is playing a level. It is a dynamic scene that will automatically show a map that is provided to it using our special MapFile format. Upon loading, the map the scene will automatically generate everything inside the map. That includes tiles, the path enemies walk on, and the enemies that will spawn in that level. In order to create such a map file, we provide two core map editing tools. See the Editor Windows section for more details.

Scene layout

In the root of the scene, there must always be the Main Camera object. It runs the Gameboard script as well as the tick event system. Both are core parts of how our game works. The tick event system calls everyone’s OnTick events and allows us to fully separate our game from real-time and FPS. The gameboard is the central part of all game elements. It generates the map layout from a map file and serves as a central place for the current enemies to register themselves. Towers access the gameboard to find enemies in their range. Tiles access the gameboard to get the current information about the status. The Main Camera also has the Map as a child element. This is where all game objects such as tiles, enemies, and shots live. The map will be scaled and moved by the Zoom and Move script, so it is important that all elements inside only use local coordinates.

Editor Windows

Map Editor Window

In your unity editor instance, you will see a new entry in the menu bar called Cyber Siege. If you click this, you will see a dropdown of Editors we provide while not in play mode. Select the one labeled "Map Editor" to get a set of tools with which creating a new map will be a breeze. Other ways to open this window are clicking the map in the hierarchy view and clicking the open map editor button in the inspector and doing the same when having a tile in the map selected.

Map Editor Tools

INSERT IMAGE HERE The Map editor tools list will show you how many tiles inside the map have currently been registered. Below that are many tools to create tiles.

  • Add Spawner
    • Will add a spawner tile on the map
    • Enemies will spawn here and move along the path to the home tile
    • Currently only one is supported. Having more than one may lead to unexpected behavior.
  • Add Tower Tile
    • Creates tower tile on the map
    • Tower tiles are special tiles where the player can place towers
  • Add Path Tile
    • Creates path tile on the map
    • Used to visualize where the enemies will walk
    • Currently not required, but instead are just visual
  • Add Home Tile
    • Creates a home tile on the map
    • Enemies will walk towards Home Tiles. If they reach the home tile the player loses a life
    • Currently only one is supported. Having more than one may lead to unexpected behavior.

Below that there is also the Clear button which will simply remove all tiles from the gameboard.

**Clearing the Map is permanent! ** If you liked the previous layout, make sure to save it using the Map File Compiler tool explained below.

Once you have created a tile on the map, you can click it in the editor window and drag it to the desired location on the map. You may notice that it seems to visually snap to the grid while you can still freely move the tile element you selected around. This is to indicate where the tile will be on the final grid. Once you let go of the tile it will snap to the valid position on the grid.

Please note that tiles shouldn't overlap.

Path Drawing Tool

INSERT IMAGE HERE After creating a beautiful map layout, you would like to make enemies walk on it now. Currently, enemies are sadly not smart enough to do that by themselves, so you need to give them a hand. With the Path Drawing Tool, you can draw a path, starting from the spawner to the home tile. If your map already has a completed path the first button will be replaced with "Path Completed". To change the path now you need to clear it or remove the last point. To start drawing a path, hit the "Start Recording button". It will automatically switch to become the Stop recording button.

As long as you are recording, unity and the scene view will be focused.

If you now move your mouse inside the map in Unity you will see a line from the last point (or the spawner) to your mouse cursor. This line consists of two segments, a green segment which indicates the next valid position for the path as well as a black line that directly connects that position with your mouse cursor. The second line is just there for you to visualize that your cursor is being properly detected. If you now right-click with the mouse anywhere on the map it will save that line and turn it blue. Now the green line starts from the point where your cursor just was. If you ever made a mistake or simply misclicked you can use the remove last point button in the tool window to remove the last point and continue. To finish your path, you should lead it into the home tile. The path editor will automatically detect this condition and stop recording for you. Congratulations, your path is complete.

Map File Compiler

Once you have carefully crafted your map you want to be able to play it. Hitting the play button in unity may lead to a disappointing result of it showing the old map and not the current one. This is because it still has the map file of the old layout stored and loads that on startup. Getting such a map file is easy with the Map file Compiler. Just click the Compile button and you will see a text field with a lot of Base64 gibberish inside. That's your map file! You can put copy it out of that text field and put it wherever you want. To test your map, you can select the main camera in the scene and then in the inspector paste the map file into the Gameboard script under "Map File String". But if you actually don't care about the map file and just want to play the map you can use the second button above it.

Compile To Gameboard is a glorious button.

It will compile your map file and put it into the gameboard directly. This means that once you hit it you can instantly press play and your map will be visible. If you want to edit an old map you saved somewhere you can hit the import button. Another text field will appear, but this time empty. Paste your old map here. Once you did a button will appear below the text field. Hit that button and the compiler will load the old layout.

Importing an old layout will permanently remove your current layout, so consider saving it first.

Wave Editor Window

If you followed the steps described in the Map Editor Window section you may have noticed that in the Cyber Siege menu inside your menu bar, there was also a wave editor option. If you click that option you'll open the wave editor. Here you will be greeted with the last wave layout or just the default map layout. On the top of the window, you will see an overview of the current waves: How many waves have been created already and how long a game with all of these waves would take. Below that you have the add wave button which adds another wave to the end. Below this is the scroll view containing all current waves. They are folded away by default to reduce clutter. If you click the name of a wave, it will unfold showing the enemies it contains the add enemy button, and a summary of this wave.

Enemy section

INSERT IMAGE HERE
This section visualizes a specific type of enemy that will be spawned a certain number of times during the wave. On the left, there is a picture of what the currently selected enemy looks like. By default, it is the basic enemy. Right next to it is the drop-down menu which allows you to switch which enemy type that will be spawned. In the middle of the section, you will see three options.

  • Duration
    • How many seconds the enemies will spawn for.
  • Offset
    • When they will start spawning in seconds.
  • Count
    • How many enemies will get spawned within the duration.

On the right, there is a section with helpful buttons. The delete button will remove this enemy section. The clone will create an identical section.

All enemy sections will run simultaneously. If you wish to alternate between enemies, offset the second enemy type by half the time it takes the first one to spawn an enemy (Duration/Count)

Ingame UI

Tower Selector Ring

The Tower Selector Ring allows the User to select one of various Tower Elements which will create the selected Tower on the TowerTile. It can technically hold infinite objects although 10 seems to be a reasonable maximum. To add elements to the ring you need to Navigate to "Assets/resources/RingMenu" inside the Unity Project View. You need to select the MainRing. Once done you can see a List of "Elements" on the right. To add or remove an element you can simply press the "+" or "-" buttons below or edit the number above. Currently, there are four Elements to choose from. To add one of those Elements to the MainRing simply drag from the Project Explorer into one of the Element Fields.

Ring Element

A Ring Element consists of a TowerPrefab and an Icon. These have to be added manually right now. To create a new Element you can right-click into the Project Explorer and simply add a new Element via "Create>RingMenu>Element".

Server

Our server runs as a module inside a Modular server Software. This server is a HTTP/HTTPS server and is written C#.
The server software is not part of this project, but it is a seperate project available here :Github The server allows for a basic version of a Rest API. The modules are .dll files where every module gets its own virtual Directory in the URL. These modules are able to define custom commands for the servers interactive command line. All requests are processed in a thread pool to improve performance. It also supplies a SDK with lots of tools and the interface every module must implement to be compatible.

Game Server

The game server is a module for this server software. As per spec of the Modular server, it exports a list of paths with a handler which each handle a single url. It processes these requests and then returns status codes and potentially a response, similar to a REST API. Most request handlers we implemented work with URL parameters such as the current users session ID. The parameter is part of the URL, and it uses LiteDB as a database.

The server manages the highscores, it "offers" the updated maps, it allows for transferring your Account (via a pairing code) and it offers cloud saves.

The server is documented in more detail in the Server Documentation

Account

You create an account simply by providing a username.
The account is used to submit you highscore after defeat, it saves your global money and it saves your unlocked maps.
Using the command line of the server you can generate a special pairing code to bring back an account that is "lost".

Losing your account currently only means you lose access to your Username as all maps are currently free.