The Code

Step 1

The empty project

Screen Shot 2017-03-27 at 12.53.21

Step 2

The ground – a 3D Plane

Screen Shot 2017-03-27 at 12.56.06

Step 3

Adding in the model, dragging in a maya file into the assets folder.

Screen Shot 2017-03-27 at 12.58.01

Step 4

The asset is now in the assets folder.

Screen Shot 2017-03-27 at 12.58.17

Step 5

Check the inspector settings – I need Normals to be calculated to create a smooth effect on the model (rather than low poly)

Screen Shot 2017-03-27 at 12.58.34

Step 6

Putting the player into the scene. The player seems massive compared to my floor… I also set the position to 0,0,0

Screen Shot 2017-03-27 at 13.04.10.png

Step 6.5

Creating an empty gameObject called Player1 and putting the HighPoly Model inside.

Screen Shot 2017-03-27 at 13.23.54.png

Step 7

Scaling up the floor. Re-naming player so that it is easier to identify.

Screen Shot 2017-03-27 at 13.07.44.png

Step 8

Creating a c# script by right clicking in the project window.

Screen Shot 2017-03-27 at 13.09.42.png

Step 9

Calling the script Player.

This script will hold all the player values.

  • PlayerColour
  • LanternColour
  • PlayerHealth

Screen Shot 2017-03-27 at 13.15.02.png

Step 10

Adding a rigidBody to the player (found under Add Component > Physics). Gravity needs to be turned on.

Also adding a BoxCollider

Screen Shot 2017-03-27 at 13.23.48.png

Step 11

The box collider is made to fit the character (see green edge)

Screen Shot 2017-03-27 at 13.27.33.png

Step 12

Adding tiles, I imported a maya tile I had made

Screen Shot 2017-03-27 at 13.32.03.png

Step 13

I created a prefab and attached the model to it – tile.

I then made lots of tiles

Screen Shot 2017-03-27 at 14.08.19.png

Step 14

Creating a script called tile.

Screen Shot 2017-03-27 at 13.47.38.png

With variables:

  • tileColour

Screen Shot 2017-03-27 at 13.48.13.png

Step 15

Creating an Empty GameObject called Enemy

Screen Shot 2017-03-27 at 13.50.03.png

Step 16

Create a script for the enemy.

Screen Shot 2017-03-27 at 13.51.11.png

Create enemy variables:

  • enemyHealth

Screen Shot 2017-03-27 at 13.51.34.png

Step 16.5

I made a Pulse Script to store information on the type of attack the enemy will have.

Screen Shot 2017-03-27 at 14.21.50.png

The pulse has the variables:

  • pulseDelay
  • pulseAwake
  • pulseAttackValue

Screen Shot 2017-03-27 at 14.23.24.png

Step 17

I made an Empty Game Object called Players (to keep things tidy) – and put Player1 in the gameObject.

Screen Shot 2017-03-27 at 14.10.11.png

Step 18

Creating the Hamsas. I made another prefab called Hamsa and attached a model to it, and scaled it slightly.

Screen Shot 2017-03-27 at 14.16.15.png

Step 19

I then created an empty gameObject called Hamsas and put in a couple of Hamsa prefabs

Screen Shot 2017-03-27 at 14.16.07.png

Step 20

I then created hamsa script.

Screen Shot 2017-03-27 at 14.19.00.png

With their variables:

  • hamsaColour
  • hamsaHealth
  • hamsaAttackValue

Screen Shot 2017-03-27 at 14.19.50.png

Step 21

I made a colour script to hold all the colours that will be used in the game.

Screen Shot 2017-03-27 at 14.27.08.png

This will use a dictionary – colours

Screen Shot 2017-03-27 at 14.28.41.png

Step 22

Add some colours to the colour dictionary.Screen Shot 2017-03-27 at 14.39.28.png

Step 23

Create a movement script

Screen Shot 2017-03-27 at 14.41.04.png

This has variables:

  • speed
  • vertical Instruction
  • horizontal Instruction

Screen Shot 2017-03-27 at 14.43.47.png

Step 24

Create a collect script.

Screen Shot 2017-03-27 at 14.47.22.png

With variable:

  • Collect Instruction

Screen Shot 2017-03-27 at 14.46.35.png

Step 25

Attach the movement script to the player, by dragging it onto the gameObject player1.

Screen Shot 2017-03-27 at 14.50.23.png

Step 26

Add some script to Movement:

  • Move

Screen Shot 2017-03-29 at 15.00.52.png

Step 27

Adding some script to Pulse

  • PulseAttack
  • countDown

Screen Shot 2017-03-29 at 15.04.10

Step 28

Add TakeDamage to the player script – so that the Pulse script is talking to something.

Screen Shot 2017-03-29 at 15.05.27

Step 29

Add some more player (so that there are four). I just copy and pasted the player I had already made.

  • I will need to change the controllers for each of these players at some point

Step 30

Add the Hamsa script to the hamasa. Or add to one and then click Apply (in the prefab bit) to change all of them.

Screen Shot 2017-03-29 at 15.10.27.png

Step 31

In the pulse attack, need to add Hamsa’s to the list of things to remove health from.

Screen Shot 2017-03-29 at 15.13.11

Step 32

Need to give the hamsa’s health and a TakeDamage function.

Screen Shot 2017-03-29 at 15.15.55.png

Step 33

Create a delegate in the Hamsa script, to handle sending the damage information to the Hamsa’s and players. This replaces the Send.Message functionality with a nicer piece of code.

This contains:

  • public delegate PulseDamage
  • public static event PulseDamage with a function called timeUp

Screen Shot 2017-03-29 at 18.46.53.png

Step 34

Add the other part of the delegate to the Hamsa and Player information.

You need a:

  • OnEnable
  • OnDisable
  • Name of the function that runs because pulse.timeUp has happened – TakeDamage.

Note// This uses the same code – is it worth having a manager for these two things – so that code is not replicated?

Screen Shot 2017-03-29 at 18.48.40Screen Shot 2017-03-29 at 18.48.28

Step 35

Further reading on delegates and events

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s