Sie sind auf Seite 1von 63

Windows Gaming Application

(“Shootout Enemy”)

A project submitted in partial fulfillment of the


Requirements for the award of the degree of

Bachelor of Technology in
Computer Science

Submitted by

Chaitanya Sharma
Roll No. 14015001004

Keshav Saini
Roll No. 1515001903

Under the guidance of

Mr. Ram Kumar

Department of Computer Science and Engineering

International Institute of Technology and Management

Murthal

April 2018

Page | 1
CANDIDATE DECLARATION

We hereby certify that the work which is being presented in this project entitled “Shootout
Enemy” is authentic record of my work carried out under the guidance of Mr. Ram Kumar.
The matter embodied in this report has not been submitted to any other University/ Institute
for the award of any degree or diploma. I have followed all the guidelines provided to me by
the Institute in writing this thesis. I have also conformed to the norms and guidelines given in
the Ethical Code of Conduct of the Institute.

CHAITANYA SHARMA KESHAV SAINI

(14015001004) (15015001903)

Page | 2
ACKNOWLEDGEMENT

Before we get into thick of things, we would like to add few words of appreciation for the
people who have been a part of this project right from its inception. This project has been one
of the significant academic challenges we have faced and without the support, patience and
guidance of the people involved, this task would not have been completed. It is to owe our
deepest gratitude.

It has been our privilege to have Mr. Gaurav Gautam (H.O.D) of C.S.E and Mr. Ram Kumar,
as our mentor who has assisted us for the commencement of the project. The success of this
project is a result of sheer hard work and determination put in by us with the help of our
mentor.

We are extremely grateful and indebted to all my teachers, my parents and my siblings for
being pillars of strength, for their unfailing moral and encouragement. We treasure their
blessings and good wishes and dedicated this study to them.

Page | 3
ABSTRACT

Our project is basically a zombie game. Zombie as enemies that u need to shoot they follow
you everywhere. We have different objectives like pickup gun, ammo for your gun and shoot
those enemies. We have many different UI to make this game more user friendly UI’s like
score count UI, Gun Information UI and Ammo count UI. For enemy Movement and
attacking we are using AI (Artificial Intelligence) so enemy can track the player and move
towards him or can easily follow him anywhere. The First-Person Shooter (FPS) is a popular
game form, with examples appearing on many different platforms. The genre has an almost
two decade history and is represented by hundreds of commercial titles. While there has been
extensive study of the FPS genre, this has tended to focus on particular games, or at best a
limited set of examples. In order to provide a wider context for such work this paper surveys
566 separate FPS titles, across a range of platforms. The titles are compared by year of
release, platform and game setting. Characteristics of avatars within the surveyed titles are
also examined, including race, gender and background, and how these vary across platform
and time. The analysis reveals definite trends, both historically and by platform.

We are using Unity3D game development engine for developing this game. There are lots of
game engine in market like Unity3D, Unreal Engine, Blender, C4 Engine, Frostbite Engine
etc. But the Unity3D have the best features in it like Graphic, Physics, Scripting and the most
important is cross-platform.

Page | 4
List of Figures

Fig. Name Page no.

Fig. 1.1 Animation in Game 10

Fig. 6.1 GameObject 19

Fig. 6.2 Transform 19

Fig. 6.3 Camera 20

Fig. 6.4 GUI Layer 21

Fig. 6.5 Flare Layer 21

Fig. 6.6 Audio Listener 21

Fig. 10.1 List of assets and files 29

Fig. 10.2 Splash Screen Objects 30

Fig. 10.3 Main Menu Scene Objects 30

Fig. 10.4 Level Scene Objects 31

Fig. 10.5 High Score Scene Objects 32

Fig. 10.6 Game Over Scene Objects 32

Fig. 10.7 Splash Screen 56

Fig. 10.8 Main Menu Screen 57

Fig. 10.9 In Game Scene 58

Fig. 10.10 In Game Scene 58

Fig. 10.11 In Game Scene 58

Fig. 10.12 High Score Screen 59

Fig. 10.13 Credits Screen 60

Page | 5
Table of Contents

Candidate’s Declaration .................................................................................................................. 2

Acknowledgement .......................................................................................................................... 3

ABSTRACT .................................................................................................................................... 4

List of Figures ................................................................................................................................. 5

Table of Contents ......................................................................................................................... 6-8

1. Project Introduction .................................................................................................................... 9

1.1 A.I. in Game ........................................................................................................................ 10

1.2 Animation in Game ............................................................................................................. 10

2. First Person Shooter(FPS) ........................................................................................................ 11

2.1 Game Design ....................................................................................................................... 11

2.2 Combat and power-ups ....................................................................................................... 12

2.3 Level Design ....................................................................................................................... 13

2.4 Multiplayer .......................................................................................................................... 13

3. Introduction to the Platform ...................................................................................................... 13

3.1 Game Engine ...................................................................................................................... 14

3.2 Types of Game Engine........................................................................................................ 15

3.2.1 XNA Game Studio(Microsoft) ................................................................................... 15

3.2.2 Unreal Engine(Epic Games) ....................................................................................... 15

3.2.3 Unity(Unity Technology).............................................Error! Bookmark not defined.

4. Unity 3D Game Engine ............................................................................................................. 16

4.1 Features of Unity................................................................................................................. 16

4.2 Games develop in Unity 3D ............................................................................................... 17

4.3 Supported Platform ............................................................................................................. 17

Page | 6
5. Objectives of the Project ........................................................................................................... 18

6. Unity Components .................................................................................................................... 19

6.1 GameObjects ....................................................................................................................... 19

6.2 Transform ............................................................................................................................ 19

6.3 Camera ................................................................................................................................ 20

6.4 GUI Layer ........................................................................................................................... 21

6.5 Flare Layer .......................................................................................................................... 21

6.6 Audio Listener .................................................................................................................... 21

7. JavaScript .................................................................................................................................. 22

7.1 JavaScript Overview ........................................................................................................... 22

7.2 Simple examples ................................................................................................................. 23

7.3 Features of JavaScript ......................................................................................................... 24

8. Assumption and Dependencies ................................................................................................. 25

8.1 Construction of Game ......................................................................................................... 25

8.2 Integration of Android ........................................................................................................ 25

9. C# or C Sharp............................................................................................................................ 26

9.1 Features of C# ..................................................................................................................... 26

9.2 Integrated Development Environment(IDE) for C# ........................................................... 27

9.3 Creating Hello World Program ........................................................................................... 27

9.4 Writing C# Program on Linux or MacOS........................................................................... 28

10. Work Done .............................................................................................................................. 29

10.1 Coding .......................................................................................................................... 33-55

10.2 Screenshots .................................................................................................................. 56-60

11. Conclusion .............................................................................................................................. 61

Page | 7
10. Future Scope ........................................................................................................................... 62

10. References ............................................................................................................................... 63

Page | 8
1. Project Introduction

Overview:-

The project is on FPS Game which means First-person shooter Game and the name of the
game is “Shootout Enemy”. This game is developed in Unity3D and for scripting is
written in the JavaScript. There are lots of games which are FPS game like:-

 Call of Duty: WWII


 Destiny
 Prey
 Resident Evil 7:
 Call of Duty: Infinite Warfare
 Titan fall 2
 Battlefield 1 and So on.

This game is basically a zombie game. Zombie as enemies that u need to shoot they
follow you everywhere. We have different objectives like pickup gun, ammo for your gun
and shoot those enemies. We have many different UI to make this game more user
friendly UI’s like score count UI, Gun Information UI and Ammo count UI.

For enemy Movement and attacking we are using AI (Artificial Intelligence) so enemy
can track the player and move towards him or can easily follow him anywhere.

I’m using Unity3D game development engine for developing this game. There are lots of
game engine in market like Unity3D, Unreal Engine, Blender, C4 Engine, Frostbite
Engine etc. But the Unity3D have the best features in it like Graphic, Physics, Scripting
and the most important is cross-platform.

Page | 9
1.1 A.I. in Game -

In video games, artificial intelligence is used to generate responsive or intelligent behaviors


primarily in non-player characters (NPCs), similar to human-like intelligence. The techniques
used typically draw upon existing methods from the field of artificial intelligence (AI).
Video games today have devolved into a microcosm of the celebrity world. Oh, the beautiful
blonde with the perfect body can captivate audiences with the right lines, but alone, without
the props of a script, she’s as brain-dead as the zombies who follow her love life.

1.2 Animation in game -


Computer animation is the process used for generating animated images. The more general
term computer-generated imagery (CGI) encompasses both static scenes and dynamic
images, while computer animation only refers to the moving images. Modern computer
animation usually uses 3D computer graphics, although 2D computer graphics are still used
for stylistic, low bandwidth, and faster real-time renderings. Sometimes, the target of the
animation is the computer itself, but sometimes film as well.
To create the illusion of movement, an image is displayed on the computer monitor and
repeatedly replaced by a new image that is similar to it, but advanced slightly in time (usually
at a rate of 24, 25 or 30 frames/second). This technique is identical to how the illusion of
movement is achieved with television and motion pictures. For 3D animations, all frames
must be rendered after the modeling is complete.

Fig: 1.1

Page | 10
2. First Person Shooter(FPS)

First-person shooter (FPS) is a video game genre centered around gun and other weapon-
based combat in a first-person perspective i.e. the player experiences the action through the
eyes of the protagonist. The genre shares common traits with other shooter games, which in
turn makes it fall under the heading action game. Since the genre's inception, advanced 3D
and pseudo-3D graphics have challenged hardware development, and multiplayer gaming has
been integral.

The first-person shooter genre has been traced as far back as Maze War, development of
which began in 1973, and 1974's Spasim. Later, and after more playful titles like MIDI Maze
in 1987, the genre coalesced into a more wantonly violent form with 1992's Wolfenstein 3D,
which has been credited with creating the genre's basic archetype, that subsequent titles were
based upon. One such title, and the progenitor of the genre's wider mainstream acceptance
and popularity was Doom, perhaps one of the most influential games in this genre. For many
years, the term Doom clone was used to designate this genre due to Doom's influence. In
1998's Half-Life—along with its 2004 sequel Half-Life 2—enhanced the narrative and puzzle
elements. In 1999, the Half-Life mod Counter-Strike was released and, together with Doom,
is perhaps one of the most influential first-person shooters. GoldenEye 007, released in 1997,
was a landmark first-person shooter for home consoles, while the Halo series heightened the
console's commercial and critical appeal as a platform for first-person shooter titles. In the
21st century, the first-person shooter is the most commercially viable video game genre, and
in 2016, shooters accounted for over 27% of all video game sales. Several first-person
shooters have been popular games for sports and competitive gaming competitions as well.

2.1 Game Design -


Like most shooter games, first-person shooters involve an avatar, one or more ranged
weapons, and a varying number of enemies. Because they take place in a 3D environment,
these games tend to be somewhat more realistic than 2D shooter games, and have more
accurate representations of gravity, lighting, sound and collisions. First-person shooters
played on personal computers are most often controlled with a combination of a keyboard
and mouse. This system has been claimed as superior to that found in console games, which
frequently use two analog sticks: one used for running and sidestepping, the other for looking
and aiming. It is common to display the character's hands and weaponry in the main view,
with a head-up display showing health, ammunition and location details. Often, it is possible
to overlay a map of the surrounding area.

Page | 11
2.2 Combat and power-ups -
First-person shooters often focus on action game play, with fast-paced and bloody firefights,
though some place a greater emphasis on narrative, problem-solving and logic puzzles. In
addition to shooting, melee combat may also be used extensively. In some games, melee
weapons are especially powerful, a reward for the risk the player must take in maneuvering
his character into close proximity to the enemy. In other situations, a melee weapon may be
less effective, but necessary as a last resort. "Tactical shooters" are more realistic, and require
teamwork and strategy to succeed, the player often commands a squad of characters, which
may be controlled by the game or by human teammates.

First-person shooters typically give players a choice of weapons, which have a large impact
on how the player will approach the game. Some game designs have realistic models of
actual existing or historical weapons, incorporating their rate of fire, magazine size,
ammunition amount, recoil and accuracy. Other first-person shooter games may incorporate
imaginative variations of weapons, including future prototypes, "alien technology" scenario
defined weaponry, and/or utilizing a wide array of projectiles, from industrial labor tools to
laser, energy, plasma, rocket and grenade launchers or crossbows. These many variations
may also be applied to the tossing animations of grenades, rocks, spears and the like. Also,
more unconventional modes of destruction may be employed from the viewable user’s hands
such as flames, electricity, telekinesis or other supernatural constructions. However,
designers often allow characters to carry varying multiples of weapons with little to no
reduction in speed or mobility, or perhaps more realistically, a pistol or smaller device and a
long rifle or even limiting the player to only one weapon at a time. There are often options to
trade up, upgrade or swap out in most games. Thus, the standards of realism vary between
design elements. The protagonist can generally be healed and re-armed by means of items
such as first aid kits, simply by walking over them. Some games allow players to accumulate
experience points similar to those found in role-playing games, which can unlock new
weapons and abilities.

Page | 12
2.3 Level Design -

First-person shooters may be structurally composed of levels, or use the technique of a


continuous narrative in which the game never leaves the first-person perspective. Others
feature large sandbox environments, which are not divided into levels and can be explored
freely. In first-person shooters, protagonists interact with the environment to varying degrees,
from basics such as using doors, to problem solving puzzles based on a variety of interactive
objects. In some games, the player can damage the environment, also to varying degrees: one
common device is the use of barrels containing explosive material which the player can
shoot, destroying them and harming nearby enemies. Other games feature environments
which are extensively destructible, allowing for additional visual effects. The game world
will often make use of science fiction, historic (particularly World War II) or modern military
themes, with such antagonists as aliens, monsters, terrorists and soldiers of various types.
Games feature multiple difficulty settings; in harder modes, enemies are tougher, more
aggressive and do more damage, and power-ups are limited. In easier modes, the player can
succeed through reaction times alone; on more difficult settings, it is often necessary to
memorize the levels through trial and error.

2.4 Multiplayer -
First-person shooters may feature a multiplayer mode, taking place on specialized levels.
Some games are designed specifically for multiplayer gaming, and have very limited single
player modes in which the player competes against game-controlled characters termed "bots".
Massively multiplayer online first-person shooters allow thousands of players to compete at
once in a persistent world. Large scale multiplayer games allow multiple squads, with leaders
issuing commands and a commander controlling the team's overall strategy. Multiplayer
games have a variety of different styles of match.

The classic types are the death match (and its team-based variant) in which players score
points by killing other players' characters; and capture the flag, in which teams attempt to
penetrate the opposing base, capture a flag and return it to their own base whilst preventing
the other team from doing the same. Other game modes may involve attempting to capture
enemy bases or areas of the map, attempting to take hold of an object for as long as possible
while evading other players, or death match variations involving limited lives or in which
players fight over a particularly potent power-up. These match types may also be
customizable, allowing the players to vary weapons, health and power-ups found on the map,
as well as victory criteria. Games may allow players to choose between various classes, each
with its own strengths, weaknesses, equipment and roles within a team.

Page | 13
3. Introduction to the Platform

Unity is an all-purpose game engine that supports 2D and 3D graphics, drag and drop
functionality and scripting through C#.
Two other programming languages were supported: Boo, which was deprecated with the
release of Unity 5 and UnityScript(JavaScript) which was deprecated in August 2017 after
the release of Unity 2017.1. The engine targets the following graphics APIs: Direct3D on
Windows and Xbox One; OpenGL on Linux, macOS, and Windows; OpenGL ES on Android
and iOS; WebGL on the web; and proprietary APIs on the video game consoles.

Additionally, Unity supports the low-level APIs Metal on iOS and macOS and Vulkan on
Android, Linux, and Windows, as well as Direct3D 12 on Windows and Xbox One. Within
2D games, Unity allows importation of sprites and an advanced 2D world renderer.

For 3D games, Unity allows specification of texture compression and resolution settings for
each platform that the game engine supports, and provides support for bump mapping,
reflection mapping, parallax mapping, screen space ambient occlusion (SSAO), dynamic
shadows using shadow maps, render-to-texture and full-screen post-processing effects. Unity
also offers services to developers, these are: Unity Ads, Unity Analytics, Unity Certification,
Unity Cloud Build, Unity Every play, Unity IAP, Unity Multiplayer, Unity Performance
Reporting and Unity Collaborate.

3. 1 Game Engine
A game engine is a software development environment designed for people to build video
games. Developers use them to create games for consoles, mobile devices, and personal
computers. The core functionality typically provided by a game engine includes a rendering
engine ("renderer") for 2D or 3D graphics, a physics engine or collision detection (and
collision response), sound, scripting, animation, artificial intelligence, networking, streaming,
memory management, threading, localization support, scene graph, and may include video
support for cinematics. The process of game development is often economized, in large part,
by reusing/adapting the same game engine to create different games or to make it easier to
port games to multiple platforms.

Page | 14
3.2 Types of Game Engine

3.2.1 XNA Game Studio (Microsoft) -

Microsoft XNA is one of the best opportunities in the game industry right now. It’s a .NET
programming package that lets you make any small to medium sized game you’re capable of
coding, and then it allows you to share your creation with the world on Xbox Live. How cool
is that? It’s like a cheat code or a cool friend who lets you bypass the long line at a club; the
exposure of Xbox Live isn’t a free perk but it’s something that’s hard for the others on this
list to match.

3.2.2 Unreal Engine (Epic Games) -

This is pretty much the undisputed best game engine in the current era of the game industry.
With literally hundreds of games – even MMO games – that have used it in the past, the
Unreal Engine is capable of creating any game for any genre with any budget. While it’s by
no means something an amateur should tackle solo to make the game of their dreams, it is
however a great tool for creating the 3D level of your dreams.

Unreal Tournament 2004 comes with UnrealEd – the Unreal Engine’s level editor – bundled
in for free, and after one or two nights of reading and watching tutorials online you’ll be able
to create your own 3D level that you and your friends can play online. It lets you use
hundreds of objects and textures from the game to create your own levels, but importing your
own data is also an option. Those interested in just the FPS angle should also check out
Valve’s Hammer Editor, which is another valuable game bundle worth having and knowing.

3.2.3Unity (Unity Technology) -

With the humongous rise of handheld electronics in recent years, the usage of Unity has
soared and has even stolen a bit of thunder from the rest on this list. It’s similar to the Torque
and Blender game engines – which are also really worth checking out – and it’s capable of
creating games for PC, Mac, Wii, Xbox 360, and PS3, but its popularity in the past year has
been largely due to its use in developing iPad and iPhone games. It’s so popular right now
that I actually plan to take my own advice and learn Unity in the coming months to stay up to
date with the game industry!

Page | 15
4. Unity 3D Game Engine

Unity is a cross-platform game engine developed by Unity Technologies. which is primarily


used to develop video games and simulations for computers, consoles and mobile devices.
First announced only for OS X, at Apple's Worldwide Developers Conference in 2005, it has
since been extended to target 27 platforms.

Six major versions of Unity have been released. At the 2006 WWDC show, Apple named
Unity as the runner up for its Best Use of Mac OS X Graphics category.

4.1 Features of Unity:-


 2D
 3D
 Graphics
 Physics
 Scripting
 Multiplayer and Networking
 Audio
 Animation
 Timeline
 UI
 Navigation and Path finding
 Virtual Reality
 Open-source repositories
 Asset Store Publishing
 Platform-specific
 Experimental

Page | 16
4.2 Games develop in Unity3D are:-

 Deus Ex: The Fall


 Wasteland 2
 Rust
 Temple Run Trilogy
 Assassin’s Creed: Identity
 Kerbal Space Program and So on….

4.3 Supported Platform


Unity supports building to 27 different platforms. The platforms are listed in the following:
iOS, Android, Tizen, Windows, Universal Windows Platform, Mac, Linux, WebGL,
PlayStation 4, PlayStation Vita, Xbox One, Wii U, 3DS, Oculus Rift, Google Cardboard,
Steam VR, PlayStation VR, Gear VR, Windows Mixed Reality, Daydream, Android TV,
Samsung Smart TV, tvOS, Nintendo Switch, Fire OS, Facebook Gameroom, Apple ARKit,
Google ARCore, and Vuforia.

Unity formerly supported 7 other platforms including its own Unity Web Player. Unity Web
Player was a browser plugin that was supported in Windows and OS X only, which has been
deprecated in favor of WebGL.

Unity is the default software development kit (SDK) for Nintendo's Wii U video game
console platform, with a free copy included by Nintendo with each Wii U developer license.
Unity Technologies calls this bundling of a third-party SDK an "industry first".

Page | 17
5. Objectives of the project

The objective of this project is to develop an interactive Android app which


provides:-

 Develop a computer game that is exciting and easy to play.

 To jump into a game development environment which is way more


different than developing native computer applications

 To use and access various third party libraries like game room, visual
studio, etc.

 Develop a computer software application that can be installed on


windows platform.

 To jump into the virtual world and decrease the rate of stress.

 Create a game which is more efficient to user.

 Create an easy navigated and realistic game for windows platform.

Page | 18
6. Unity Components

Components are the nuts & bolts of objects and behaviors in a game. They are the functional
pieces of every GameObject.

6.1 GameObjects

The GameObject is the most important concept in the Unity Editor. Every object in your
game is a GameObject. This means that everything you can think of to be in your game has to
be a GameObject. However, a GameObject can’t do anything on its own; you need to give it
properties before it can become a character, an environment, or a special effect.

Fig: 6.1

6.2 Transform

The Transform component determines the Position, Rotation, and Scale of each object in the
scene. Every GameObject has a Transform.

Fig: 6.2

Page | 19
6.3 Camera

Cameras are the devices that capture and display the world to the player. By customizing and
manipulating cameras, you can make the presentation of your game truly unique. You can
have an unlimited number of cameras in a scene. They can be set to render in any order, at
any place on the screen, or only certain parts of the screen. Cameras are essential for
displaying your game to the player. They can be customized, scripted, or parented to achieve
just about any kind of effect imaginable. For a puzzle game, you might keep the Camera
static for a full view of the puzzle. For a first-person shooter, you would parent the Camera to
the player character, and place it at the character’s eye level. For a racing game, you’d
probably have the Camera follow your player’s vehicle.
We can create multiple Cameras and assign each one to a different Depth. Cameras are drawn
from low Depth to high Depth. In other words, a Camera with a Depth of 2 will be drawn on
top of a Camera with a depth of 1. You can adjust the values of the Normalized View Port
Rectangle property to resize and position the Camera’s view onscreen. This can create
multiple mini-views like missile cams, map views, rear-view mirrors, etc.

Fig: 6.3

Page | 20
6.4 GUI Layer

A GUI Layer Component is attached to a Camera to enable rendering of 2D GUIs. When a


GUI Layer is attached to a Camera it will render all GUI Textures and GUI Texts in the
scene. GUI Layers do not affect UnityGUI in any way.
We can enable and disable rendering GUI in a single camera by clicking on the check box of
the GUI Layer in the Inspector.

Fig: 6.4

6.5 Flare Layer

The Flare Layer Component can be attached to Cameras to make Lens Flares appear in the
image. By default, Cameras have a Flare Layer already attached.

Fig: 6.5

6.6 Audio Listener

The Audio Listener acts as a microphone-like device. It receives input from any given Audio
Source in the scene and plays sounds through the computer speakers. For most applications it
makes the most sense to attach the listener to the Main Camera. If an audio listener is within
the boundaries of a Reverb Zone reverberation is applied to all audible sounds in the scene.
Furthermore, Audio Effects can be applied to the listener and it will be applied to all audible
sounds in the scene.

Fig: 6.6

Page | 21
7. JAVASCRIPT

7.1 JavaScript Overview

JavaScript ("JS" for short) is a full-fledged dynamic programming language that, when
applied to an HTML document, can provide dynamic interactivity on websites. It was
invented by Brendan Eich, co-founder of the Mozilla project, the Mozilla Foundation, and the
Mozilla Corporation.

JavaScript is incredibly versatile. You can start small, with carousels, image galleries,
fluctuating layouts, and responses to button clicks. With more experience, you'll be able to
create games, animated 2D and 3D graphics, comprehensive database-driven apps, and much
more!

"JavaScript" is a trademark of Oracle Corporation in the United States. It is used under


license for technology invented and implemented by Netscape Communications and current
entities such as the Mozilla Foundation.

JavaScript itself is fairly compact yet very flexible. Developers have written a large variety of
tools on top of the core JavaScript language, unlocking a vast amount of extra functionality
with minimum effort. These include:

 Browser Application Programming Interfaces (API) — APIs built into web browsers,
providing functionality like dynamically creating HTML and setting CSS styles, collecting
and manipulating a video stream from the user's webcam, or generating 3D graphics and
audio samples.
 Third-party APIs to allow developers to incorporate functionality in their sites from other
content providers, such as Twitter or Facebook.
 Third-party frameworks and libraries you can apply to your HTML to allow you to rapidly
build up sites and applications.

However, becoming comfortable with JavaScript is a little harder than becoming comfortable
with HTML and CSS. You may have to start small and keep working in small consistent
steps.

Initially only implemented client-side in web browsers, JavaScript engines are now
embedded in many other types of host software, including server-side in web servers and
databases, and in non-web programs such as word processors and PDF software, and in
runtime environments that make JavaScript available for writing mobile and desktop
applications, including desktop widgets.

Page | 22
7.2 Simple examples

Variables in JavaScript can be defined using the var keyword.


 var x; // defines the variable x and assigns to it the special value "undefined" (not to
be confused with an undefined value)
 var y = 2; // defines the variable y and assigns to it the value 2
 var z = "Hello, World!"; // defines the variable z and assigns to it a string entitled
"Hello, World!"

However, most runtime environments have a console object that can be used to print output.
Here is a minimalist Hello World program in JavaScript:

 console.log("Hello World!");

A simple recursive function:

function factorial(n) {
if (n === 0 || n === 1) {
return 1; // 0! = 1! = 1
}
return n * factorial(n - 1);
}

factorial(3); // returns 6

Page | 23
7.3 Features of JavaScript

The following features are common to all conforming JavaScript implementations, unless
explicitly specified otherwise.

 Universal support: All modern Web browsers support JavaScript with built-in
interpreters.

 Imperative and structured: JavaScript supports much of the structured programming


syntax from C (e.g., if statements, while loops, switch statements, do while loops,
etc.). One partial exception is scoping: JavaScript originally had only function
scoping with var. ECMAScript 2015 added keywords let and const for block scoping,
meaning JavaScript now has both function and block scoping.

 Dynamic: As with most scripting languages, JavaScript is dynamically typed; a type


is associated with each value, rather than just with each expression. For example, a
variable that is at one time bound to a number may later be re-bound to a string.
JavaScript supports various ways to test the type of an object, including duck typing.

 Run-time evaluation: JavaScript includes an eval function that can execute statements
provided as strings at run-time.

 Vendor-specific extensions: JavaScript is officially managed by Mozilla Foundation,


and new language features are added periodically. However, only some JavaScript
engines support these new features:

Page | 24
8. Assumptions and Dependencies

The final destination of our game's operation will be the Android mobile device. However,
Unity will be responsible for both the construction of the game and its integration within the
Android framework.

8.1 Construction of the Game

Unity includes many built-in components which will expedite the process of game
development immensely. These include:

 Physics Engine
 Collision Detection and Handling
 Input Recognition
 Object Creation and Transform Manipulation (position and rotation of game
objects)
 Scene Integration (transition of one level to the next)
 Model Attachment (representing game objects with 3D models from external
programs)

8.2 Integration with Android

Unity3D's build settings simplify the process of transferring our game to the Android
mobile device. After completing the project, or during any intermediary step for
testing, we can select Android from the list of options, build the project, and upload it
to one of our own devices. A separate license is required for this functionality, which
has already been obtained by one of the members of our group.

Page | 25
9. C# or C Sharp

C# is a modern, general-purpose, object-oriented programming language developed by


Microsoft and approved by European Computer Manufacturers Association (ECMA) and
International Standards Organization (ISO).
C# was developed by Anders Hejlsberg and his team during the development of .Net
Framework.
C# is designed for Common Language Infrastructure (CLI), which consists of the executable
code and runtime environment that allows use of various high-level languages on different
computer platforms and architectures.
The following reasons make C# a widely used professional language −

 It is a modern, general-purpose programming language


 It is object oriented.
 It is component oriented.
 It is easy to learn.
 It is a structured language.
 It produces efficient programs.
 It can be compiled on a variety of computer platforms.
 It is a part of .Net Framework.

9.1 Features of C# are -

Although C# constructs closely follow traditional high-level languages, C and C++ and
being an object-oriented programming language. It has strong resemblance with Java, it has
numerous strong programming features that make it endearing to a number of programmers
worldwide.
Following is the list of few important features of C# −

 Boolean Conditions
 Automatic Garbage Collection
 Standard Library
 Assembly Versioning
 Properties and Events
 Delegates and Events Management

Page | 26
 Easy-to-use Generics
 Indexers
 Conditional Compilation
 Simple Multithreading
 LINQ and Lambda Expressions
 Integration with Windows

9.2 Integrated Development Environment (IDE) for C#

Microsoft provides the following development tools for C# programming −

 Visual Studio 2010 (VS)


 Visual C# 2010 Express (VCE)
 Visual Web Developer

The last two are freely available from Microsoft official website. Using these tools, you can
write all kinds of C# programs from simple command-line applications to more complex
applications. You can also write C# source code files using a basic text editor, like Notepad,
and compile the code into assemblies using the command-line compiler, which is again a part
of the .NET Framework.

Visual C# Express and Visual Web Developer Express edition are trimmed down versions of
Visual Studio and has the same appearance. They retain most features of Visual Studio. In
this tutorial, we have used Visual C# 2010 Express.

9.3 Creating Hello World Program

A C# program consists of the following parts −

 Namespace declaration
 A class
 Class methods
 Class attributes
 A Main method
 Statements and Expressions

Page | 27
Example of simple Hello World Program -

using System;

namespace HelloWorldApplication {

class HelloWorld {

static void Main(string[] args) {

/* my first program in C# */

Console.WriteLine("Hello World");

Console.ReadKey();

9.4 Writing C# Programs on Linux or Mac OS

Although the.NET Framework runs on the Windows operating system, there are some
alternative versions that work on other operating systems. Mono is an open-source version of
the .NET Framework which includes a C# compiler and runs on several operating systems,
including various flavors of Linux and Mac OS.

The stated purpose of Mono is not only to be able to run Microsoft .NET applications cross-
platform, but also to bring better development tools for Linux developers. Mono can be run
on many operating systems including Android, BSD, iOS, Linux, OS X, Windows, Solaris,
and UNIX.

Page | 28
10. Work Done

 List of Assets and files used in ShootOut Enemy:-

Fig: 10.1

Page | 29
 GameObjects Used in Different Scenes

1) Splash Screen Objects -

Fig: 10.2

2) Main Menu Scene Objects -

Fig: 10.3

Page | 30
3) Level Scene Objects -

Fig: 10.4

Page | 31
4) High Score Scene Objects -

Fig: 10.5

5) Game Over Scene Objects -

Fig: 10.6

Page | 32
10.1 Coding

1) Splash Screen

 SplashToMenu.cs -

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class SplashToMenu : MonoBehaviour


{

// Use this for initialization


void Start ()
{
StartCoroutine (SplashFinish ());

IEnumerator SplashFinish ()
{
yield return new WaitForSeconds (10.6f);
SceneManager.LoadScene (1);
}

2) Main Menu

 MainMenuOptions.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class MainMenuOptions : MonoBehaviour

Page | 33
{

public void PlayGame ()


{
SceneManager.LoadScene (2);
}

public void HighScore ()


{
SceneManager.LoadScene (4);
}

public void Credits ()


{
SceneManager.LoadScene (5);
}

void Start ()
{
Cursor.visible = true;
GlobalHealth.PlayerHealth = 10;
}

public void ExitGame ()


{
Application.Quit ();
}

 Reset.js
function Start () {
GlobalScore.score = 0;
GlobalAmmo.CurrentAmmo = 0;
GlobalAmmo.LoadedAmmo = 0;

Page | 34
3) Level 001

 FirstPersonController

using System;
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;
using UnityStandardAssets.Utility;
using Random = UnityEngine.Random;

namespace UnityStandardAssets.Characters.FirstPerson
{
[RequireComponent(typeof (CharacterController))]
[RequireComponent(typeof (AudioSource))]
public class FirstPersonController : MonoBehaviour
{
[SerializeField] private bool m_IsWalking;
[SerializeField] private float m_WalkSpeed;
[SerializeField] private float m_RunSpeed;
[SerializeField] [Range(0f, 1f)] private float m_RunstepLenghten;
[SerializeField] private float m_JumpSpeed;
[SerializeField] private float m_StickToGroundForce;
[SerializeField] private float m_GravityMultiplier;
[SerializeField] private MouseLook m_MouseLook;
[SerializeField] private bool m_UseFovKick;
[SerializeField] private FOVKick m_FovKick = new FOVKick();
[SerializeField] private bool m_UseHeadBob;
[SerializeField] private CurveControlledBob m_HeadBob = new CurveControlledBo
b();
[SerializeField] private LerpControlledBob m_JumpBob = new LerpControlledBob(
);
[SerializeField] private float m_StepInterval;
[SerializeField] private AudioClip[] m_FootstepSounds; // an array of footstep sou
nds that will be randomly selected from.
[SerializeField] private AudioClip m_JumpSound; // the sound played when c
haracter leaves the ground.
[SerializeField] private AudioClip m_LandSound; // the sound played when ch
aracter touches back on ground.

private Camera m_Camera;


private bool m_Jump;
private float m_YRotation;
private Vector2 m_Input;
private Vector3 m_MoveDir = Vector3.zero;
private CharacterController m_CharacterController;
private CollisionFlags m_CollisionFlags;
private bool m_PreviouslyGrounded;

Page | 35
private Vector3 m_OriginalCameraPosition;
private float m_StepCycle;
private float m_NextStep;
private bool m_Jumping;
private AudioSource m_AudioSource;

// Use this for initialization


private void Start()
{
m_CharacterController = GetComponent<CharacterController>();
m_Camera = Camera.main;
m_OriginalCameraPosition = m_Camera.transform.localPosition;
m_FovKick.Setup(m_Camera);
m_HeadBob.Setup(m_Camera, m_StepInterval);
m_StepCycle = 0f;
m_NextStep = m_StepCycle/2f;
m_Jumping = false;
m_AudioSource = GetComponent<AudioSource>();
m_MouseLook.Init(transform , m_Camera.transform);
}

// Update is called once per frame


private void Update()
{
RotateView();
// the jump state needs to read here to make sure it is not missed
if (!m_Jump)
{
m_Jump = CrossPlatformInputManager.GetButtonDown("Jump");
}

if (!m_PreviouslyGrounded && m_CharacterController.isGrounded)


{
StartCoroutine(m_JumpBob.DoBobCycle());
PlayLandingSound();
m_MoveDir.y = 0f;
m_Jumping = false;
}
if (!m_CharacterController.isGrounded && !m_Jumping && m_PreviouslyGroun
ded)
{
m_MoveDir.y = 0f;
}

m_PreviouslyGrounded = m_CharacterController.isGrounded;
}

private void PlayLandingSound()

Page | 36
{
m_AudioSource.clip = m_LandSound;
m_AudioSource.Play();
m_NextStep = m_StepCycle + .5f;
}

private void FixedUpdate()


{
float speed;
GetInput(out speed);
// always move along the camera forward as it is the direction that it being aimed a
t
Vector3 desiredMove = transform.forward*m_Input.y + transform.right*m_Input.
x;

// get a normal for the surface that is being touched to move along it
RaycastHit hitInfo;
Physics.SphereCast(transform.position, m_CharacterController.radius, Vector3.do
wn, out hitInfo,
m_CharacterController.height/2f, Physics.AllLayers, QueryTriggerInt
eraction.Ignore);
desiredMove = Vector3.ProjectOnPlane(desiredMove, hitInfo.normal).normalized
;

m_MoveDir.x = desiredMove.x*speed;
m_MoveDir.z = desiredMove.z*speed;

if (m_CharacterController.isGrounded)
{
m_MoveDir.y = -m_StickToGroundForce;

if (m_Jump)
{
m_MoveDir.y = m_JumpSpeed;
PlayJumpSound();
m_Jump = false;
m_Jumping = true;
}
}
else
{
m_MoveDir += Physics.gravity*m_GravityMultiplier*Time.fixedDeltaTime;
}
m_CollisionFlags = m_CharacterController.Move(m_MoveDir*Time.fixedDeltaT
ime);

ProgressStepCycle(speed);
UpdateCameraPosition(speed);

Page | 37
m_MouseLook.UpdateCursorLock();
}

private void PlayJumpSound()


{
m_AudioSource.clip = m_JumpSound;
m_AudioSource.Play();
}

private void ProgressStepCycle(float speed)


{
if (m_CharacterController.velocity.sqrMagnitude > 0 && (m_Input.x != 0 || m_In
put.y != 0))
{
m_StepCycle += (m_CharacterController.velocity.magnitude + (speed*(m_IsW
alking ? 1f : m_RunstepLenghten)))*
Time.fixedDeltaTime;
}

if (!(m_StepCycle > m_NextStep))


{
return;
}

m_NextStep = m_StepCycle + m_StepInterval;

PlayFootStepAudio();
}

private void PlayFootStepAudio()


{
if (!m_CharacterController.isGrounded)
{
return;
}
// pick & play a random footstep sound from the array,
// excluding sound at index 0
int n = Random.Range(1, m_FootstepSounds.Length);
m_AudioSource.clip = m_FootstepSounds[n];
m_AudioSource.PlayOneShot(m_AudioSource.clip);
// move picked sound to index 0 so it's not picked next time
m_FootstepSounds[n] = m_FootstepSounds[0];
m_FootstepSounds[0] = m_AudioSource.clip;
}

Page | 38
private void UpdateCameraPosition(float speed)
{
Vector3 newCameraPosition;
if (!m_UseHeadBob)
{
return;
}
if (m_CharacterController.velocity.magnitude > 0 && m_CharacterController.isG
rounded)
{
m_Camera.transform.localPosition =
m_HeadBob.DoHeadBob(m_CharacterController.velocity.magnitude +
(speed*(m_IsWalking ? 1f : m_RunstepLenghten)));
newCameraPosition = m_Camera.transform.localPosition;
newCameraPosition.y = m_Camera.transform.localPosition.y -
m_JumpBob.Offset();
}
else
{
newCameraPosition = m_Camera.transform.localPosition;
newCameraPosition.y = m_OriginalCameraPosition.y - m_JumpBob.Offset();
}
m_Camera.transform.localPosition = newCameraPosition;
}

private void GetInput(out float speed)


{
// Read input
float horizontal = CrossPlatformInputManager.GetAxis("Horizontal");
float vertical = CrossPlatformInputManager.GetAxis("Vertical");

bool waswalking = m_IsWalking;

#if !MOBILE_INPUT
// On standalone builds, walk/run speed is modified by a key press.
// keep track of whether or not the character is walking or running
m_IsWalking = !Input.GetKey(KeyCode.LeftShift);
#endif
// set the desired speed to be walking or running
speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed;
m_Input = new Vector2(horizontal, vertical);

// normalize input if it exceeds 1 in combined length:


if (m_Input.sqrMagnitude > 1)
{
m_Input.Normalize();
}

// handle speed change to give an fov kick

Page | 39
// only if the player is going to a run, is running and the fovkick is to be used
if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.
velocity.sqrMagnitude > 0)
{
StopAllCoroutines();
StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOV
KickDown());
}
}

private void RotateView()


{
m_MouseLook.LookRotation (transform, m_Camera.transform);
}

private void OnControllerColliderHit(ControllerColliderHit hit)


{
Rigidbody body = hit.collider.attachedRigidbody;
//dont move the rigidbody if the character is on top of it
if (m_CollisionFlags == CollisionFlags.Below)
{
return;
}

if (body == null || body.isKinematic)


{
return;
}
body.AddForceAtPosition(m_CharacterController.velocity*0.1f, hit.point, Force
Mode.Impulse);
}
}
}

 GunFire.js

var Flash : GameObject;

function Update() {
if (GlobalAmmo.LoadedAmmo >= 1){

if(Input.GetButtonDown("Fire1")) {
var gunsound : AudioSource = GetComponent.<AudioSource>();
gunsound.Play();
Flash.SetActive(true);

Page | 40
MuzzleOff();
GetComponent.<Animation>().Play("Gun_Shot");
GlobalAmmo.LoadedAmmo -= 1;
}
}
}

function MuzzleOff(){
yield WaitForSeconds(0.1);
Flash.SetActive(false);
}

 HandGunDamage.js
var DamageAmount : int;
var TargetDistance : float;
var AllowedRange : float = 60;
var Hit : RaycastHit;
var TheBullet : GameObject;
var TheBlood : GameObject;
var TheBloodGreen : GameObject;

function Start(){
DamageAmount = 5;
}

function Update () {
if(GlobalAmmo.LoadedAmmo >= 1 ){
if(Input.GetButtonDown("Fire1")) {

var Shot : RaycastHit;


if (Physics.Raycast (transform.position, transform.TransformDirection(Vector3.fo
rward), Shot)) {
TargetDistance = Shot.distance;
if (TargetDistance < AllowedRange) {

//Shot.transform.SendMessage("DeductPoints", DamageAmount, SendMe


ssageOptions.DontRequireReceiver);
if (Physics.Raycast (transform.position, transform.TransformDirection(Ve
ctor3.forward), Hit)){

if(Hit.transform.tag =="Zombie"){
Instantiate(TheBlood, Hit.point, Quaternion.FromToRotation(Vector3
.up, Hit.normal));
}

if(Hit.collider.tag =="ZombieHead"){

Page | 41
DamageAmount = 10;
Instantiate(TheBlood, Hit.point, Quaternion.FromToRotation(Vector3
.up, Hit.normal));
}

if(Hit.transform.tag =="Spider"){
Instantiate(TheBloodGreen, Hit.point, Quaternion.FromToRotation(V
ector3.up, Hit.normal));
}

if(Hit.transform.tag == "Untagged"){
Instantiate(TheBullet, Hit.point, Quaternion.FromToRotation(Vector3.up,
Hit.normal));
}
}
Shot.transform.SendMessage("DeductPoints", DamageAmount, SendMessa
geOptions.DontRequireReceiver);
DamageAmount = 5;
}
}
}
}

 AmmoPickup.js
var AmmoSound : AudioSource;
var ObjectiveLabel : GameObject;
var ObjectiveComplete : GameObject;

function OnTriggerEnter(col : Collider){

ObjectiveLabel = GameObject.Find("Canvas/ObjectivesLabel");

if(col.tag == "ThePlayer"){
//Debug.Log(col);
AmmoSound.Play();

GlobalAmmo.CurrentAmmo += 10;
if(ObjectiveLabel.activeSelf){
ObjectiveComplete.SetActive(true);
}

this.gameObject.SetActive(false);

}}

Page | 42
 PauseMenu.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityStandardAssets.Characters.FirstPerson;

public class PauseMenu : MonoBehaviour


{
public static bool GameIsPaused = false;
public GameObject pauseMenu;
public GameObject pauseBackGround;
public GameObject[] zombies;
public GameObject thePlayer;
public GameObject gunMachanics;
public GameObject M9;
public GameObject pauseCamera;
//public GameObject abc;

// Update is called once per frame


void Update ()
{
if (Input.GetButtonDown ("Cancel")) {

//SceneManager.LoadScene (1);

if (GameIsPaused && pauseMenu.activeSelf) {


Resume ();
} else {
Pause ();
}

public void Resume ()


{
Debug.Log ("Resumed");
pauseBackGround.SetActive (false);
pauseMenu.SetActive (false);
Time.timeScale = 1f;
thePlayer.GetComponent<FirstPersonController> ().enabled = true;

Page | 43
M9.SetActive (true);

foreach (GameObject holder in zombies) {


holder.SetActive (true);
}
}

void Pause ()
{
pauseBackGround.SetActive (true);
pauseMenu.SetActive (true);
Time.timeScale = 0f;
thePlayer.GetComponent<FirstPersonController> ().enabled = false;
Cursor.visible = true;

M9.SetActive (false);
foreach (GameObject holder in zombies) {
holder.SetActive (false);
}
GameIsPaused = true;
}

public void Menu ()


{
SceneManager.LoadScene (1);
}

 CrossAnimate.js
var UpCurs : GameObject;
var DownCurs : GameObject;
var RightCurs : GameObject;
var LeftCurs : GameObject;

function Update() {
if(GlobalAmmo.LoadedAmmo >= 1){
if (Input.GetButtonDown("Fire1")){
UpCurs.GetComponent("Animator").enabled=true;
DownCurs.GetComponent("Animator").enabled=true;
LeftCurs.GetComponent("Animator").enabled=true;
RightCurs.GetComponent("Animator").enabled=true;
WaitingAnim();
}
}
}

Page | 44
function WaitingAnim(){
yield WaitForSeconds(0.1);
UpCurs.GetComponent("Animator").enabled=false;
DownCurs.GetComponent("Animator").enabled=false;
LeftCurs.GetComponent("Animator").enabled=false;
RightCurs.GetComponent("Animator").enabled=false;
}

 GlobalAmmo.js

import UnityEngine.UI;

static var CurrentAmmo : int;


var InternalAmmo : int;
var AmmoDisplay : GameObject;

static var LoadedAmmo : int = 0;


var InternalLoaded : int;
var LoadedDisplay : GameObject;

function Update(){
InternalAmmo = CurrentAmmo;
InternalLoaded = LoadedAmmo;
AmmoDisplay.GetComponent.<Text>().text = "" + InternalAmmo;
LoadedDisplay.GetComponent.<Text>().text = "" + LoadedAmmo;
}

 Pickup9mm.js

var TheDistance : float = PlayerCasting.DistanceFromTarget;


var TextDisplay : GameObject;

var FakeGun : GameObject;


var RealGun : GameObject;
var AmmoDisplay : GameObject;
var PickUpAudio : AudioSource;

var ObjectiveLabel : GameObject;


var ObjectiveComplete : GameObject;

function Update(){
TheDistance = PlayerCasting.DistanceFromTarget;

Page | 45
}

function OnMouseOver(){
if(TheDistance <= 0.0002){
TextDisplay.GetComponent.<Text>().text = "Take 9mm Pistol";

}
if(Input.GetButtonDown("Action")){
if(TheDistance <= 1){
TakeNineMil();
if(ObjectiveLabel.activeSelf){
ObjectiveComplete.SetActive(true);

}
}
}
}

function OnMouseExit(){
TextDisplay.GetComponent.<Text>().text = "";
}

function TakeNineMil(){
PickUpAudio.Play();
transform.position = Vector3(0,-1000, 0);
FakeGun.SetActive(false);

RealGun.SetActive(true);
AmmoDisplay.SetActive(true);

 GlobalScore.js

static var CurrentScore : int;


var InternalScore : int;

var ScoreText : GameObject;


static var score : int;
var highScore : int;
static var Show1 : int;
static var Show2 : int;
static var Show3 : int;

function Start(){
Show1 = PlayerPrefs.GetInt("HighScore1");

Page | 46
Show2 = PlayerPrefs.GetInt("HighScore2");
Show3 = PlayerPrefs.GetInt("HighScore3");
Debug.Log(PlayerPrefs.GetInt("HighScore1"));
Debug.Log(Show2);
Debug.Log(Show3);
}

function Update(){

ScoreText.GetComponent.<Text>().text = "" + score;


highScore = score;

if(score >= Show1){


PlayerPrefs.SetInt("HighScore3",Show2);
PlayerPrefs.SetInt("HighScore2",Show1);

PlayerPrefs.SetInt("HighScore1",score);

if(score < PlayerPrefs.GetInt("HighScore1") && score > PlayerPrefs.GetInt("HighScore3"


) || (score == PlayerPrefs.GetInt("HighScore2"))){
PlayerPrefs.SetInt("HighScore3",Show2);
PlayerPrefs.SetInt("HighScore2", score );

if(score < PlayerPrefs.GetInt("HighScore2") && score == PlayerPrefs.GetInt("HighScore3


"))
PlayerPrefs.SetInt("HighScore3", score );

 GlobalHealth.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class GlobalHealth : MonoBehaviour


{

public static int PlayerHealth = 10;


public int InternalHealth;
public GameObject HealthDisplay;

Page | 47
void Update ()
{
InternalHealth = PlayerHealth;
HealthDisplay.GetComponent<Text> ().text = "Health: " + PlayerHealth;
if (PlayerHealth == 0) {
SceneManager.LoadScene (3);

 Cutscene01.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Cutscene01 : MonoBehaviour


{

public GameObject ThePlayer;


public GameObject Cam1;
public GameObject Cam2;
public GameObject TheUI;
public GameObject nearZombie;

// Use this for initialization


void Start ()
{
StartCoroutine (CutSceneBegin ());
}

IEnumerator CutSceneBegin ()
{
yield return new WaitForSeconds (5.1f);
Cam2.SetActive (true);
Cam1.SetActive (false);
yield return new WaitForSeconds (10.1f);
ThePlayer.SetActive (true);
TheUI.SetActive (true);
nearZombie.SetActive (true);
Cam2.SetActive (false);

Page | 48
 TimeLeft.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class TimeLeft : MonoBehaviour


{
public Text timerText;
public float timerStartAt = 120.0f;
public GameObject ThePlayer;
bool startTimer = false;

void Update ()
{

if (Input.GetButton ("Vertical")) {

startTimer = true;

if (timerStartAt <= 0) {
//timerStartAt = 0.0f;
SceneManager.LoadScene (3);
}

if (startTimer) {
timerStartAt = timerStartAt - Time.deltaTime;
//Debug.Log (timerStartAt);

string minutes = ((int)timerStartAt / 60).ToString ();


string seconds = (timerStartAt % 60).ToString ();

timerText.text = minutes + ":" + seconds;


}

Page | 49
 ZombieFollow.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ZombieFollow : MonoBehaviour


{

public GameObject ThePlayer;


public float TargetDistance;
public float AllowedRange = 30;
public GameObject TheEnemy;
public float EnemySpeed;
public int AttackTrigger = 0;
public RaycastHit Shot;

public int IsAttacking;


public GameObject ScreenFlash;
public AudioSource Hurt01;
public AudioSource Hurt02;
public AudioSource Hurt03;
//public GameObject zombieAttackSound;
public AudioSource attackSound;
public int PainSound;

void Update ()
{
transform.LookAt (ThePlayer.transform);
if (Physics.Raycast (transform.position, transform.TransformDirection (Vector3.forward
), out Shot)) {
TargetDistance = Shot.distance;
if (TargetDistance < AllowedRange) {
EnemySpeed = 0.1f;
//Debug.Log (AttackTrigger);
if (AttackTrigger == 0) {
TheEnemy.GetComponent<Animation> ().Play ("Walking");
transform.position = Vector3.MoveTowards (transform.position, ThePlayer.trans
form.position, Time.deltaTime * 3);

}
} else {
EnemySpeed = 0.0000f;
TheEnemy.GetComponent<Animation> ().Play ("Idle");
}

Page | 50
if (AttackTrigger == 1) {
Debug.Log (AttackTrigger);
if (IsAttacking == 0) {
StartCoroutine (EnemyDamage ());
}

EnemySpeed = 0.0000f;
TheEnemy.GetComponent<Animation> ().Play ("Attacking");
}

void OnTriggerEnter (Collider col)


{
if (col.tag == "ThePlayer") {
AttackTrigger = 1;
}
}

void OnTriggerExit (Collider col)


{
if (col.tag == "ThePlayer") {
AttackTrigger = 0;
}
}

IEnumerator EnemyDamage ()
{
IsAttacking = 1;
//attackSound = zombieAttackSound.GetComponent<AudioSource> ();

PainSound = Random.Range (1, 4);


yield return new WaitForSeconds (0.9f);
attackSound.Play ();
ScreenFlash.SetActive (true);
GlobalHealth.PlayerHealth -= 2;

if (PainSound == 1) {
Hurt01.Play ();

if (PainSound == 2) {
Hurt02.Play ();

if (PainSound == 3) {
Hurt03.Play ();

Page | 51
}

yield return new WaitForSeconds (0.05f);


ScreenFlash.SetActive (false);
yield return new WaitForSeconds (1);
IsAttacking = 0;

 EnemyScript.js

var EnemyHealth : int = 10;


var TheZombie : GameObject;
public var Score : GameObject;
static var scoreValue = 1;
var numberOfZombieDie = 0;
var enemyDie = false;

var ObjectiveLabel : GameObject;


var ObjectiveComplete : GameObject;

function DeductPoints (DamageAmount : int){


EnemyHealth -= DamageAmount;
}

function Update (){

if (EnemyHealth <= 0){


ObjectiveComplete = GameObject.Find("Canvas/ObjectivesLabel/Objective03/BlueTick");
ObjectiveLabel = GameObject.Find("Canvas/ObjectivesLabel");

this.GetComponent("ZombieFollow").enabled=false;

if(ObjectiveLabel.activeSelf){
ObjectiveComplete.SetActive(true);

Page | 52
TheZombie.GetComponent.<Animation>().Play("Dying");
EndZombie();
}

function EndZombie(){
yield WaitForSeconds(3);
numberOfZombieDie = 1;

GlobalScore.score = GlobalScore.score + scoreValue;


//Debug.Log(numberOfZombieDie);
Destroy(gameObject);

4) Game Over

 GOToMenu.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class GOToMenu : MonoBehaviour


{

// Use this for initialization


void Start ()
{
StartCoroutine (Holds ());
GlobalHealth.PlayerHealth = 10;
}

IEnumerator Holds ()
{
yield return new WaitForSeconds (3.0f);

SceneManager.LoadScene (1);

Page | 53
}

 Reset.js

function Start () {
GlobalScore.score = 0;
GlobalAmmo.CurrentAmmo = 0;
GlobalAmmo.LoadedAmmo = 0;

5) High Score

 HighScoreJs.js

#pragma strict
import UnityEngine.UI;
import UnityEngine.SceneManagement;

var highScoreText1 : GameObject;


var scoreHolder1 : Text;
var highScoreToPrint1 : int;

var highScoreText2 : GameObject;


var scoreHolder2 : Text;
var highScoreToPrint2 : int;

var highScoreText3 : GameObject;


var scoreHolder3 : Text;
var highScoreToPrint3 : int;

function Start () {
highScoreText1 = GameObject.Find("Canvas/First/High Score");
scoreHolder1 = highScoreText1.GetComponent.<Text>();

highScoreToPrint1 = PlayerPrefs.GetInt("HighScore1");
scoreHolder1.text = highScoreToPrint1.ToString();

Page | 54
highScoreToPrint2 = PlayerPrefs.GetInt("HighScore2");
scoreHolder2.text = highScoreToPrint2.ToString();

highScoreToPrint3 = PlayerPrefs.GetInt("HighScore3");
scoreHolder3.text = highScoreToPrint3.ToString();

//Debug.Log(PlayerPrefs.GetInt("HighScore1"));
}

function Update () {
if(Input.GetButtonDown("Cancel")){
SceneManager.LoadScene(1);

}
}

function Reset(){
PlayerPrefs.DeleteAll();
scoreHolder1.text = "0";
scoreHolder2.text = "0";
scoreHolder3.text = "0";
}

6) Credits

 CredToMenuC.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class CredToMenuC : MonoBehaviour


{

void Start ()
{
StartCoroutine (ReturnToMenu ());
}

IEnumerator ReturnToMenu ()
{
yield return new WaitForSeconds (11);
SceneManager.LoadScene (1);
}

Page | 55
void Update ()
{
if (Input.GetButtonDown ("Cancel")) {
SceneManager.LoadScene (1);
}
}

10.2 Screenshots

a) Splash Screen

Fig: 10.7
(Splash Screen)

Page | 56
b) Main Menu Screen

Fig: 10.8
(Main Menu Screen)

Page | 57
c) In Game Scene

Fig: 10.9
(In Game Scene)

Fig: 10.10

Page | 58
Fig: 10.11

d) High Score Screen

Fig: 10.12
(High Score Screen)

Page | 59
e) Credits Screen

Fig: 10.13
(Credits Screen)

Page | 60
11. Conclusion

This is my minor project on “Shootout enemy”. I’ve learned a lot through this project. This
project has sharpened our concept of Game engine, animation and the software-hardware
interface.

I’ve learned a lot about different documentation. The piece of software I’ve developed is
intended to serve the gamers of the world. The success of this project may give pleasure to
billions of game lovers among the universe. This project not only tested our technical skills
but also our temperament. There were times that we almost lost hope but we recovered
through constant concentration and hard work. If any kind of suggestion, improvements,
more efficient development idea please feel free to communicate with me.
I learnt so many things and gain a lot of knowledge about development field of games.

Page | 61
12. Future Scope

YES. There is always a room for improvement and we left so many business
logic implementations like –
Here is the list of possible improvements:

 Full version without bugs because it is still in beta version.


 Sensor bug enhancement.
 More levels.
 Google Cardboard Version.
 New Weapons.
 Camera switcher or background switcher for low battery consumption.
 Custom ghosts which give access to the user to set there photo as a ghost.
 More enhanced user interface for better gaming experience.
 Multiplayer facility for both online and offline gaming.
 Vibration and effects will be added for better and real gaming experience.
 We can add a switch to toggle on-off AR gaming experience.
 We can add different types of guns with level.

Page | 62
13. References

 Github : https://github.com/github
 Youtube : https://www.youtube.com/user/Unity3D
 Unity 3D : https://unity3d.com/
 Jimmy Vegas youtube :
https://www.youtube.com/watch?v=0fGB2H1AGP8&list=PLZ1b66Z1KFKh-
auyvzNkOBFLWf6dH6iEH
 MisterNinjaBoy youtube : https://www.youtube.com/user/misterninjaboy/about
 Prog Knowledge : https://www.tutorialspoint.com/csharp/index.htm
 Prog Knowledge : https://www.w3schools.com/js/

Page | 63

Das könnte Ihnen auch gefallen