Monday, 23 November 2015

UI Card Game part 3

The final stage of the game, was the actual game mechanic itself. With the cards randomly shuffling upon starting the game, all I had to do was set the card backs to display as opposed to the front. I needed to set cards to flip upon being clicked and check if it matched the ID of the next card being flipped. If so then the cards needed to remain upright, otherwise flip them back.

To do this I needed a method in the card behaviour that passed the cards information to the game manager upon it being clicked. When two cards have been clicked and passed their information, a co-routine to compare the cards is started. If the two cards match, the tally for pairs needed to win increased, bringing the player one step closer to finishing and they then remain unclickable. If they don't match, both cards are flipped back and made clickable again.
Card game partway through

The final thing to do was provide a win screen when the player matched every card. This was easily done by checking if the pair tally equaled 8 or not. If so then a delegate message is sent to display the win overlay image and I even added music to make it more of a celebration.
Finished game with win display

Saturday, 21 November 2015

Street Scene: Initial Street Building & Mind map

After the first week working on my street scene, I've planned out the layout and done some basic work an a few buildings. I decided on the five major buildings I was going to make and also wanted to add a few extra filler buildings to flesh out the scene. The smaller teal coloured buildings are the filler buildings that will have the same generic size and shape but a slightly different decorative roof board and decals. The far left building is going to become a church with a bell tower and stained glass windows. The light pink building will become a general store, the yellow one is the train station, deep purple will be a doctors and the big darker pink building is the saloon. I have plans for different props, to add more detail to the scene, such as barrels, crates, shacks and foliage.
Street scene in 3DS Max

I've imported the street model into Unity and edit it from there, so any changes I make in 3DS Max instantly appear for me to explore in-game. This way I can check scaling and the feel of things with ease as soon as I've made them. This also allows me to easily integrate my game mechanics with the street scene such as moving doors and interactive pieces when I get to that stage.
Street scene in Unity

This was also the stage where I turned my brainstorm into a mind map. This wasn't very difficult seeing as my brainstorm for this project was relatively clear in the first place, but it still gives me a well laid out feel for my whole plan.

Mind map

Thursday, 19 November 2015

Transparency and Decals

Transparency is used on textures to make parts of textures see through to make them more realistic. The degree of transparency goes from 1-0 where 1 is fully opaque and 0 is fully transparent. To make use of transparency you have to create an alpha source for the texture. Anything you want the player to see should be white, whilst anything you want to disappear and be see-through should be in black. Transparency is used mainly for fences, windows and even foliage.

To test it out we had to find a chain link texture and take it into Photoshop. The actual fence part needed to be made white with the space around the edge and inside made black so it becomes see through.
Chain link alpha source

We then added the original texture to the diffuse section in the material editor in 3DS and applied the alpha source to the opacity setting. This then applies the texture and the opacity meaning you get the effect of a chain link fence that you can see through.
Added texture and alpha source into 3DS Max

I then decided to add it into a scene in Unity to see if it looked the same and the effect works exactly as it did in 3DS Max.
My fence in Unity with transparency still working

We were then taught that transparency can be used for decals. This is the process of adding a texture to an object that already has a texture, in order to give it some more detail. The decal won't cover up the entirety of the original texture, it simply adds something more on top of it. Examples would be stains, dirt and graffiti on surfaces. I made a graffiti decal and then created the alpha source for it which was more difficult seeing as it was multiple lines for text rather than an overall shape. Eventually I managed to do it and applied both in the material editor, exactly how I did for the fence texture.
Graffiti on wall in 3DS Max

As I said earlier, foliage can be created by using alpha sources to make the space between and around leaves/plants transparent. We were shown how to create a leaf and then curve it slightly for realism and adding a lot of these leaves together gives the appearance of a small tropical plant. Another way to create foliage is to use the same texture multiple times with them at different sizes/angles and we used this to create a bush. The final piece of foliage made was a tree that I rotated multiple times to give a more 3D effect.
Foliage textures with alpha source

For home study I was tasked with creating some particle effects in Unity which is a something I've never tried before. In order to make a particle effect I had to add a particle system to my scene. This is a default effect producing white orbs at a steady state, in which a huge amount of settings can be changed. The 3 particle effects I created were: an explosion, exhaust fumes and a glowing golden ball of light. These 3 effects varied in size, speed, emission shape, lifetime and textures.
The explosion needed to be fast expanding and quick to end with the particle size decreasing as it blasts out. The exhaust fumes puffed out at a steady speed both rising and disappearing over time. The golden orb is quick and compact in a spherical shape with the particles fading quickly.
My particles in a GIF

Wednesday, 18 November 2015

Dark Arts 3: Delegates and Co-routines

Delegates are used as a reference to a method with specific parameters. We can use them if we have multiple versions of a method that we need to choose from and how to handle each one. To define the delegate all you need is:  public delegate <Type>   MethodName(<Type> variable);
Another good use of delegates is a messaging system between classes. A list of delegates can be created as a way to keep track of the receivers, that way we always know where the message will be going. The 'listeners' can then chose whether or not they act on the message depending on what it is.
Example of using delegates for message system

A co-routine is a method that can be paused and continued later. This is very useful to script events and create situations where something is waited for or triggered at a certain time. Using a co-routine that contains yield is what causes it to continue in the next frame from where it left off in the last one, rather than starting from scratch. This is what I've done in order to fade out the bullet holes in previous projects I've done so it's good to find out I did it to a proper standard. A co-routine can also be stopped at any time but only by calling it's name, giving you even greater control on how it carries out.
Co-routine that fades and resets colour

Monday, 16 November 2015

UI Card Game Part 2

With the main menu sorted from last week, the next objective was actually adding cards to the game scene. Rather than layout every card individually and be limited to the space available, we were taught a clever way to set up the scene so that cards are generated upon playing the game. In order to do this I needed to add a background to the game scene, which is what would control the card position and generation for me. The component that allows me to preset the positions and spacing of the cards is a 'Grid Layout Group', which has cell sizing and spacing values. I needed to add a few cards initially and set the cell size to fit the card, then adjust the spacing to my liking. From there I set the starting position (top left), alignment (middle centre) and constraint count i.e. number of rows(4).
Components in the background object

Once the card layout was done I could clear all cards off the scene and start on the generating scripts. To start a card face is needed so we created a card model class that creates the variables, then a behaviour class which assigns them to the card. The next step was having a game controller that creates a grid list for cards to be generated into and then fills it. However this on it's own would put each matching pair together, so we need something to shuffle the cards around. We were provided with a complex method that made use of the generics we were taught two weeks ago by Richard. The method uses the 'RNGCryptoServiceProvider' class which is essentially a random number generator. From what I can gather, it uses this to generate a byte for a box position and then assign a card to that space. The finished product of this week is a game screen filled with shuffled cards.
Shuffled cards in game

Shuffling code

Saturday, 14 November 2015

Street Scene Project & Brainstorm

All of the game design work in recent weeks has been building up to be put in a GDD, where somebody can look through it and get an idea of exactly what my game is and how it should look. That section has been finished now and in it's place I have a new project. This is to construct an interactive street scene that is created in 3DS Max, then has a game created around it in Unity. Straight away my idea was to make the western high street I had planned for my game design process. I had already put plenty of thought and planning into how everything would look, so adjusting it slightly into a more open street would be no trouble and I'd love to see how it turns out. My inspiration for the design is going to follow the town of Armadillo from Red Dead Redemption, therefore this is almost going to be the guide I try to recreate. I won't be making the buildings look identical and will have my own take on them, the town layout is simply my aim.
The town of Armadillo from Red Dead Redemption

As for the game aspect, I'd like to have a story based, walking simulator. As the entire point of the street scene is to make it look great, I'd much rather have the character explore the area and appreciate the scene rather than run around ignoring everything because they're too focused on a crazy objective of some form. I've planned out the story of a middle aged man who lost his wife and children along with his farm and home. With nothing left in the town he heads down the street towards the train station but along the way players will encounter glowing orbs of light. Upon walking into them, they will hear a voice recording where parts of the characters tragic backstory is revealed. The player needs to find every glowing light before they can head to the train station and leave town. The glowing light look that I'm aiming for is similar to the ones that appear in 'Everybody's gone to the Rapture'.
Lights from Everybody's Gone to the Rapture

Thursday, 12 November 2015

Sound Design: NanoStudio and CGD Ident

In the final week of sound work we were shown the most complicated program yet, NanoStudio. This is the most industry standard program we've used so far and it's easy to see why with the amount of settings and editing options that can be used on it. First of all we set to just learning the layout and what different settings did, but then we were given the task of mixing a track. NanoStudio has a list of premade tracks to showoff what can be done, so I had to open one of them and then play around changing as much as I could without adjusting the actual notes being played. Fair to say I had plenty of options to toy with so spent the next 20 mins adjusting as much as I could. I recorded the changes I made using OBS and then overlaid the music to create a small video of the outcome.


After sorting all of that out, we were given an ident for the CGD course. An ident is essentially a tiny clip with sound used to represent (identify) a company/brand. An example would be BBC2 and the different clips of the number 2 they show in between shows. Another is whenever you load up a games console and get the tiny splash screen to begin with. Our new task was to take the video clip and change the sound to something new and different that we could make in any program we wanted. I chose to use Audacity and add in audio because it's easy to manipulate sound and get it just how you want it. In order to separate the video from the sound I had to use Adobe Audition and in order to put the two together required the use of Premier. When I finished the sound and wanted to add it to the video I was at home so used a website called wevideo which unfortunately added a watermark and advert at the end.
Original CGD Ident

 My Finished Ident