Professional Documents
Culture Documents
Technical Document
Developments tool
Unity
Light the way will be developed using Unity 5 Game engine. The game engine supports
development for both 2D and 3D games, along with the ability to publish to a wide range of
platforms with ease. Unity has a power physics system which we will take advantage of to
create our game. The game engine uses a component system allowing for efficient reuse of
code and scripts, this will help to speed up the development of our games core mechanics
allowing us to spend more time on puzzle and level design.
Currently created, we have a basic version of a level creator which uses a BMP. asset to
generate the level using pixel sampling. Depending on whether it is necessary we will use this to
generate the levels and save them in Unity. Using this method will mean that the objects within
the level are consistently laid out and bugs/glitches caused by slight misplacements are
minimised. This will not account for all aspects of the level such as each specific objects colour
or any extra scenery layers we will be added to make the levels seem more unique.
Data Dictionary
Identifier
Data Type /
Component
Class / Location
Description
sprite
GameObject
baseColour
ColourType(enum)
GameObject
currentColour
ColourType(enum)
GameObject
body
RigidBody2D(unity)
GameObject
boxCol
BoxCollider2D(unity)
GameObject
cirCol
CircleCollider2D
(unity)
GameObject
width
int
Block/
MovingBlock
height
int
Block/
MovingBlock
width
int
Barrier /
MovingBarrier
the number of
blocks/MovingBlocks in
the X axis
height
int
Barrier /
the number of
blocks/MovingBlocks in
the Y axis
thrustVelociy
Vector2(unity)
JumpPad
jumped
bool
playerCharacter
if the playerCharacter
has hit a jumpPad
currentState
PlayerState(enum)
playerCharacter
posOne
Vector2(unity)
Bounce
posTwo
Vector2(unity)
Bounce
speed
float
Bounce
directionMove
Vector2(unity)
Bounce
currentState
FlyingEnemyState
(enum)
FireFly / LightBug
startPos
Vector2
Patrol
distance
float
Patrol
randomPos
Vector2
Patrol
speed
int
Patrol
direction
Vector2
Chase
speed
int
Chase
int
Chase
currentState
SlunkState
Slunk
currentState
SwitchState
Switch/
SpecialSwitch
ray
RayCast(unity)
Mirror
cirCast
CircleCast(unity)
Mirror
currentState
TrapDoorState
TrapDoor
rayOne
rayCast(unity)
LightSource
rayTwo
rayCast(unity)
LightSource
rayThree
rayCast(unity)
LightSource
created on collision
between spotLight and
rayOne/rayTwo. used to
generate polygon mesh
and arc
mesh
Mesh(unity)
LightSource
lightCirc
CircleCast(unit)
LightSource
arc
Handle.Arc(unity)
LightSource
TurretState
Turret
velocity
Vector2
Bullet
Code Description
Classes
1. GameObject - (interface)
All object will inherit from this abstract class. It will hold the object's position, base colour, current
colour and a rigidBody2D component. Not all game objects will use the core game mechanic of
colours but it will be incorporated within our base interface should we choose to allow the player
to interact in this way with such objects later in the development process. RigidBody2D is one
of Unitys physic components used for 2D games. It can be used to handle game physics such
as collisions and motion.
2. Block : GameObject
A rectangle used to create solid terrain and platforms for the game's characters to navigate.
When used for terrain all blocks will have a base colour of black; meaning the player can not
interact with it using the light mechanic.
3. MovingBlock : GameObject
A platform that will move between two points. This block will have a base colour of black;
meaning the player can not interact with it using the light mechanic. it will have a Bounce script
attached which will make the block move back and forth between 2 points.
4. Barrier
A collection of Blocks of the same base colour and size, this will give the illusion of a normal
Block but coloured. Upon colliding with a spotlight of the same colour the collision of the each
blocks RigidBody2D will be turned off. This will appear as though a large full-sized Block is
being carved by the light.
5. MovingBarrier
A horizontal or vertical wall of MovingBlocks of the same base colour and size that will move
between two points in the same direction. Upon colliding with a spotlight of the same colour the
collision of the blocks rigidBody2D will be turned off.
6. SpotLight: GameObject
A circle of colour the player can place into the game world by pressing and holding the screen.
when the Spotlight interacts with another object with a colour it will change that object's colour
as described in the design document until the Spotlight is removed.
7. PlayerCharacter :GameObject
The character the player must guide through the environment to the goal. The playerCharacter
have several states: WALK, CLIMB, FALLING, DEAD. In the WALK state the character will
move in a direction along the X axis until it collides with an object it can not pass through, at that
point it will turn around and move in the other direction. whilst in the WALK state it will have the
walking animation.The player will enter the CLIMB state if they collide with a ladder. In this state
the playerCharacter move horizontally up the ladder if at the bottom or down the ladder if
colliding with the top of the ladder. In this state the climb animation will be displayed. The
playerCharacter will return to the WALK state once it has reached the bottom or top of the
ladder. it will continue walking in the same direction it was moving when it collided with the
ladder. The playerCharacter will enter the FALLING State if it becomes airborne. This will
trigger the falling animation. Upon landing on the a platform the playerCharacter can not pass
through the it will return to the WALK state. The playerCharacter will enter the DEAD state on
collision with a gameobject that has DeathOnCollision Script attached. This will start the death
animation trigger game over to be displayed. will It will have to following scripts attached: climb,
jump, changeBaseColour.
The playerCharacter can only ever have a base colour of WHITE, RED, GREEN, BLUE,
MAGENTA, YELLOW or CYAN. This is because the other colours (PINK, SKYBLUE and
TURQUOISE) will not mix again with RGB and these colours are only possible temporarily as
the currentColour(when a Spotlight touches the PlayerCharacter).
8. Slunk : GameObject
A grounded enemy which will run at the playerCharacter when the playerCharacter is within
its chase radius. If the playerCharacter collides with a slunk the PlayerCharacter dies. The
slunk has several states; IDLE, RETREAT, CHASE, DEAD, FALLING. The Slunk will begin in
the IDLE state. In the IDLE state the enemy will patrol a platform or area. The slunk will enter
the RETREAT state if the play places a light on or close to the slunk. In the RETREAT state the
slunk will run away from light. The slunk will always enter the CHASE state when
playerCharacter is within its attack radius AND in line of sight of the slunk, even if in RETREAT
STATE. The slunk will return to the idle state from the CHASE state if the playerCharacter
leaves the Slunks line of sight OR its attack radius. The Slunk will return to the IDLE state from
the RETREAT state if the players light is removed from the screen or if it is a safe distance from
the light. The Slunk will enter the DEAD state if it remains in a light source for a continuous 3
seconds. In the DEAD state it will stay in the position it was in when it entered the state. If the
playerCharacter collides with the Slunk in the DEAD state the playerCharacter will not die.
The Slunk will return to the idle state after a short period of time. The slunk will move into the
FALLING state when it is not touching the ground. The FALLING state is functionally identical to
the IDLE state however the animation would be changed to the falling animation until the Slunk
reaches the ground.
9. Fireflies: GameObject
A flying enemy that alters the colour of a light on collision.They have a set baseColour at the
beginning of the level. Fireflies have two states: IDLE, CHASE. In the IDLE state Fireflies will
hover in a given area. Fireflies will enter the CHASE state if a light source is within a given
radius. In this state they will move towards the center of the light source. The fireflies will
prioritise the players light source over others.
10
11
13. Switch:GameObject
An object that characters can interact with on collision. Switchs have two states: ON and OFF. A
switch enters the ON state when a character collides with it. When active all Barriers of the
same colour will be removed for a short period of time. While in the ON state the player cannot
interact with the switch using a spotLight. After the time period has expired the switch will
revert to the OFF state and all objects removed by the Switch will return.
14. SpecialSwitch:GameObject
An object that can only be interacted with by light sources. Special Switch have two states: ON
and OFF. At the start of a level a SpecialSwitch is in the OFF state. To switch to the ON a light
source of contrasting colour must be placed over the SpecialSwitch. Once in the ON state all
barriers of the same colour will be removed from the level. The switch stays in this state for the
rest of the level.
12
15. Mirror:GameObject
Mirrors will reflect light in a beam-like way when interacted with by a LightSource. This will
involve a raycast coming from it until it reaches a solid block. When a light touches the mirror
the beam will activate as a thick line of the same colour of the light on the raycast. This will be
done by creating a same colour CircleCast from the start to the end of the raycast in the colour.
The player will be able to rotate the mirror by touching it and dragging it in a circle. This will
change the direction of the raycast and thus the direction of the light beam.
16. Miasma
A rigidBody2D that prevents the player from placing a spotLight.
17. Teleporter:GameObject
The teleporter interacts with light. The currentColour of the teleporter is changed by using the
Spotlight, but only whilst placed over it, otherwise it defaults to its base colour. When interacted
with the teleporter will move a colliding PlayerCharacter or Slunk to another teleporter of the
same currentColour. This is done by editing the PlayerCharacters position variable to that of
the other portal. The teleporter may have a permanent base colour at the levels start.A
Teleporter as two states: ACTIVE and INACTIVE. A teleport is in the ACTIVE state whenever
there are two teleporters of same colour on screen. while the Teleporter is ACTIVE a player can
move between the two ACTIVE teleporters and they will both display an active teleporter
animation. If there is not another teleporter of the colour same colour in the level the the teleport
is INACTIVE.
18. Tinter:GameObject
The tinter is an object that interacts with the PlayerCharacter. It also has a base colour set at the
start, which can only be WHITE, RED, GREEN or BLUE (This is to avoid it being possible to set
the PlayerCharacters baseColour as a colour that would normally require 2 mixes). The
currentColour can be altered using the SpotLight. When the player character collides with the
Tinter the PlayersCharacter baseColour is changed to that of the tinter.
19. Spike:GameObject
This object interacts with the PlayerCharacter. On collision the PlayerCharacters state is set
to the DEAD state and the level resets.
20. JumpPad:GameObject
When the playerCharacter collides with a jumpPad it is given a horizontal and vertical velocity.
Propelling the playerCharacter upwards and in the direction it was walking.
13
22. Trapdoor
Trapdoor has two states: TRIGGERED, SET. At the start of the level all trapdoors will be in the
SET state. when a character collides with the trapdoor it will switch to the TRIGGERED state. At
the start of the TRIGGERED state an animation of the trapdoor opening will run and the fog of
war hiding the pit will disappear. The sprite will remain in on an open frame for the remained of
the level and the fog of war will not return.
14
23. LightSource
15
24. RotatingLightSource
This is the same as the LightSource (22.)however the light can rotate around its source point
(this is shown as the Pink point on the diagrams). It will work in the same way but have limiting
values in its properties to determine the how much it will rotate and its origin direction.
16
17
Bounce
Makes an game object bounce between to loactions at a set speed
Vector2 pos1
Vector2 pos2
int direction = 1;
int speed = 5; //Example TO BE ALTERABLE
Vector2 directionMove = (pos1.position - pos2.position).UnitVector()*speed
void Bounce() //Called each frame
{
MoveObject(directionMove)
if(Object.RigidBody.IntersectsWith(pos1) ||Object.RigidBody.IntersectsWith(pos2))
{
direction = direction * -1
}
}
Patrol
Make a character patrol an area. moving a random distance in a direction within
a set space
Vector2 startPos = Vector2D(100,100) //Example TO BE WORKED OUT WHEN PLACED
float distance = 50 //Example TO BE ALTERABLE
Vector2 randomPos;
randomPos.position = Vector2(startPos.X+((rand%distance)-(distance/2)))
18
DeathOnCollision
Attached to game cause the playerCharacter to die on Collision, triggering
gameover
void DeathOnCollision(RigidBody2D collidedWith) // Called on collision
{
if(collidedWith() == PlayerCharacter.RigidBody2D)
{
PlayerCharacter.Die()
}
}
Chase (Slunk Example)
Vector2 direction
speed = 5; //Example TO BE ALTERABLE
void Chase
{
if(AttackRadius.collidedWith() = PlayerCharacter.RigidBody2D.position)
{
direction = (Player character.RigidBody2D.position)
MoveObject((direction - currentPosition).UnitVector()*speed)
}
}
Climb
void Climb
{
if (PlayerCharacter.collidedWith() = Ladder.RigidBody2D)
{
Vector2D CurrentDirectionV = PlayerCharacter.currentVelocity
PlayerCharacter.currentVelocity = Vector2D(0,5)
while(PlayerCharacter.collidedWith() = Ladder.RigidBody2D)
{
19
Jump
Causes the playerCharacter to jump with a given velocity
float xJump = 10 //Example TO BE ALTERABLE
float yJump = 30 //Example TO BE ALTERABLE
bool Jumped = false;
void Jump
{
if (PlayerCharacter.collidedWith() =JumpPad.RigidBody2D)
{
if(Jumped == false)
{
PlayerCharacter.currentVelocity += Vector2(xJump, yJump)
Jumped = true
}
}
else
{
Jumped = false
}
}
IsContrastingColour
Checks if two colours are contrasting. if combined together make white
Enumeration ColourType
bool isContrastingColour(ColourType Colour1, ColourType Colour2)
{
switch(Colour1)
case(ColourType.RED)
if(Colour2 == RED || Colour2 == YELLOW || Colour2 == MAGENTA
|| Colour2 == PINK || Colour2 == WHITE || Colour2 == PURPLE
|| Colour2 == ORANGE || Colour2 == LIME)
{
return false
}
else
{
20
21
22
playerCharacter
LightSources
Switch
Slunk
SpecialSwitch
Barrier
Block
Tinter
Spikes
Goal
FireFly
Turrets
LightBug
Mirror
Teleporter
JumpPad
TrapDoor
Miasma
Optional
23