GGC – Big Game Project

This week a rushed to get a stable version of the digital game, which we showed during Gotland Game Conference (GGC). Even though I did as much as I could without crashing, the build still had some bugs during GGC which I had to fix each day after GGC. One of the changes we did the day before GGC was that instead of having a server computer, the server computer could act as a player. That way we didn’t extra computers for server. It did however create a few bugs which we did not catch in time for GGC. If the server would play an information card, a card would be created each frame, causing major slowdowns.

On the last day of GGC when I arrived to set up our equipment, I noticed that I couldn’t find any servers. I checked the console in unity and noticed that I couldn’t connect to the Unity master servers. The only way we could solve that was by reprogramming some of the scripts so that the game would use a private connection by letting players typing in IP-addresses instead. We realized that it would take too much time to do that so we focused on showing people our board game version instead.

Menu

Beta and bugs – Big Game Project

This has been a long and hectic week as we have had to finish a beta build and work on the feedback we had gotten from that beta testing session. There has been a lot to fix as this was the first time other people got to test the game and we noticed a lot of bugs we hadn’t noticed before. Besides a lot of bug fixing, I have also started working on a rulebook for the table top version, added two new cards and some needed features such as checking my and the opponents discard piles.

The most important feedback we got from the beta testing session was that it was hard for new players to know what was going on due to the fact that a lot of actions happened automatically in the background. There was almost no visual feedback of was what happening. There were also some game breaking bugs that are important to fix.

Checking the opponents discard piles was a problem I had trouble fixing at first as I needed to send a list of gameobjects to the other player. But instead I fixed it by sending different RPCs, depending on what was in my pile, and let a script which handles all the network code, add gameobjects to its own separate list, which it then could copy to the other player.

NewBoard

Cards – Big Game Project

For the majority of my time this week, I have been working on implementing a lot of different cards for the game and I made twelve cards in total. These are the cards people can buy for resources and then use to play them when they draw the cards. There are different cards in different categories. Some help you gain resources or cards; some help you manage your deck and some are used to sabotage your opponent in some way. Some cards have been easier than others to implement. The cards that I had most trouble with creating were the ones that had a lot of interaction with the enemy player and other cards. An example is a card called “Wiretap” and it says: “Reveal this when your opponent buys a card. Gain a copy of that card. Place it in the discard pile.” That card also has a mechanic we call stealth. It is similar of how trap cards work in Yu-Gi-Oh in the way that they are placed faced down and are revealed and activated when the opponent has met certain conditions. A player can have a maximum of three stealth cards, so if a player has three wiretaps in play, a player can earn three cards in one round. There is a lot the game must send to the other player such as if a player is wiretapped or not, how many wiretaps are in play and what cards are being bought. Because I’m not very experienced in networking, I have made a lot of different functions that sends what card a player buys if they are wiretapped. This is not optimal and the code can be hard to read, so that I something I might fix in the future.

The easier cards to implement were the ones that didn’t do very much other than drawing cards or giving resources. Take “Junk Treasure” for an example. It says “You gain two temporary resources. You gain a NULL card. Place it in your hand.” The hand is a list of cards, so a NULL card object is added to that list and the resources is just an integer which is increased by two. The only networking for this card is to show the other player that I played this card.

board

More Networking! – Big Game Project

So this week, I got a lot of work done. I had trouble with the networking part of our game last week, but after getting some tips on how I should go about solving it, I fixed what I worked on for half a week in just one day instead. There is now a Game object called controller which has a controller script attached to it that handles all the RPCs that are sent to the other players. Instead of the player scripts sending actions to the other person, the actions are sent to the controller which tells all players that this actions happens.

Players are able to purchase cards during game play in our game and then play with those cards when they are drawn. Purchasing and playing cards are the other things I have been working on a lot this week. An example of how purchasing a card works is that if I am player one and it is my turn, I can click on any pile I want if I have the resources for it. One of the cards I can buy is “Strong Stuff” which increases my resources by one and makes me draw a card. If I click on that card and I have the money for it, the game object “Strong Stuff” alongside the cards in my hand will be added to my list of discarded cards. This will also be sent to the controller script so that the other player knows what action I did and then end my turn and enable the other players turn. The process is almost the same for when playing cards but instead of checking the cost there are other conditions. There are now six other cards excluding “Strong Stuff”.

I also got to build and test the game on an android tablet late this week. The only problem that occurred was that the texture atlas we used for all the cards was to big for the tablet to handle. I had not thought of this before so the texture we used was 4096×4096 in size but all the cards came out completely black. We will have to use smaller atlases for the tablet version as we want the game to work on as many different types of tablets as well. This probably should not be a problem but it can be worth keeping that in mind in the future for other projects while working on multiple platforms.

Purchase cards

Multiplayer Gameplay – Big Game Project

I have been working on fixing basic multiplayer gameplay this week. What this means is that I wanted to make so two players can join a server, take turns to do actions, update each others hands and what they play. I had a lot of trouble getting the hand to update properly at first and the cards were stacking on top of one another and you had to drag them to fix it instead of it automatically sorting themselves. At first I thought I had some wrong settings in the inspector, but it turned out that all I had to do was call a function called Reposition on the grid of cards whenever the players drew cards.

The next major problem I had, was that old instantiated cards would not destroy when players drew new cards and on the next turn they would have ten cards instead of five. I had made a script called “destroyCard” that would destroy the game object every time a new hand is drawn, but I do not know what went wrong because a random amount of cards would be destroyed every time. Instead I made a script that would destroy all the child objects of a parent object. The cards are part of a game object grid which is the parent of the cards. I would then loop through the children of the grid (the cards) and destroy them one by one.

Then I came to the part which still is not fixed. I do not want players to play simultaneously, but in turns. Right now, the player who joins the server first is the one who gets to go first. At the end of a players turn, I do an RPC (Remote Procedure Call) which should set the second players turn to true and the first players turn to false but these variables will not change for some reason. I have gotten a lot of different errors because I have tried to solve the problem in a lot of different ways suggested by people on the Unity forums. When I think I have solved the problem I get a new error. If this problem persists I may have to try to solve it in a different approach from what I’ve done now, but I do not know how yet and therefore I will have to think about it under the weekend.

cards

NGUI – Big Game Project

This week, I have spent some time cleaning up a lot of code to make it more readable for others and fixing a lot of bugs. In our card game there are three main piles where cards go trough each turn. The main deck, the hand and the discard pile. Players draw cards and put them in to their hands and then discards them by playing them and when the deck has no cards, the discard pile is shuffled in to the deck again. We had problems where cards were the wrong amount of cards sometimes would be put in to the wrong piles. This is now fully fixed so soon a single player will be able to play the game by himself.

But I spent most of my time this week trying to figuring out how the NGUI-package from the assett store works. We want to use this package to display the piles of cards I mentioned earlier. It could simplify the process in the long run, but right now I am having a hard time wrapping my head around it. The biggest advantage of using NGUI is how it easy it is to make texture atlases. They are like one big texture with smaller textures inside of it. This way, the game doesn’t have to load a lot of different textures, but use one for many objects. As smart phones are weaker than a lot of PC’s and we are targeting smart phones, this is a good idea for better performanceImage.

Unity Master Server – Big Game Project

Unfortunately, I’ve been ill this week and because of that, I haven’t been able to do as much work as I otherwise would have. But I tried doing as much as I could anyways so I wouldn’t get too far behind schedule. I have finally finished setting up a master server for the game so players can find available games to play without having to know the servers IP addresses. Players can now choose between creating a private a server where the game is hidden and players connect by typing in the IP address or creating a public server so other players can easily find them. The game is currently using the unity master server which should only be used for testing purposes so I should probably be looking for other options as well. Amazon offers this service for free for a year so that is probably a good option later on and there shouldn’t be that much code to change either.

Here are a couple of images of how it looks like right now:

menu server connect publicservers launchserver

Unity Networking – Big Game Project

Last week I had to do a lot of research about networking in unity and that’s what I spent most of my time on. I have never programmed something involving networking so the whole subject was a bit foreign to me. Fortunately, there are many great tutorials online and very good documentation provided by Unity Technologies for me to study. I was actually able to implement a system where players can create servers where two players may join. These players can then press space to send message to each other using “RPC’s”. This was just to try out if I could make one action visible for the other player to find out if they were actually connected.

The concept of RPC’s (Remote Procedure Calls) is something I had trouble grasping at first, but it turned out it wasn’t that hard to understand after all. They are almost the same as normals functions but with a few minor but important differences. They need one more extra parameter to know on what machines to run the functions on and the more parameters an RPC needs , the more network bandwidth involved will be used.

I’m now trying to create a master server so players are able to find public servers without having to know the IP address for the player who created the server. There are different services available for this but I’m not quite sure what I should use. Unity is able to provide a master server for testing purposes, but I have also found a great guide online where I can learn some more about different ways to set up a stable master server.