Thursday, November 14, 2013

TCP and Threading

NOTE: I completed this work the week of October 28 - November 1. But I got behind on my blog posts so I just split up my previous work by weeks.

As mentioned back in the blog post about Database Design ( http://benvdevelopment.blogspot.com/2013/10/database-design.html ) Parse can only respond to requests and cannot directly send data to a player. This makes it difficult to build a responsive game by using Parse alone.

The solution is to have the clients take to each other through a peer to peer connection. This way when a player plays a card or ends their turn they can inform their opponent that they need to ask the server what has changed. This ensures that the game is responsive without removing the security of having a server validate all actions taken by players.

Unfortunately, in Unity the networking is not built to handle peer to peer networking so I had to write my own code using the C# TcpListener class and sockets. In order, for this networking code to work effectively I also had to make it threaded - so I created a thread utility heavily inspired by the Loom thread utility documented http://unitygems.com/threads/ .

Card Collection Management

NOTE: I completed this work the week of October 21 - October 25. But I got behind on my blog posts so I just split up my previous work by weeks.

Since our project is a collectible card game one of the most important features of the game, other than the core game play itself is the ability for players to see and manage their card collection. This is where the card collection screen show below comes into play.






The card collection screen - shows all cards that are in the game that can be put into a deck. In addition, cards which the player owns has a number underneath them signaling how many of that card the player owns.

Cards are also split into pages of a maximum of six cards that can be navigated through. In a finished product we would want to be able to search and filter the collection but that is not likely to get done during this semester.


Also, on the right side of the collection is a deck view control. Which is a reusable control that shows the different decks the player has built. This control will be the topic of its own post later as it is currently not entirely finished.


Each card is represented in a consistent way as shown in the image below: