Beruflich Dokumente
Kultur Dokumente
(“Shootout Enemy”)
Bachelor of Technology in
Computer Science
Submitted by
Chaitanya Sharma
Roll No. 14015001004
Keshav Saini
Roll No. 1515001903
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.
(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
Page | 5
Table of Contents
Acknowledgement .......................................................................................................................... 3
ABSTRACT .................................................................................................................................... 4
Page | 6
5. Objectives of the Project ........................................................................................................... 18
7. JavaScript .................................................................................................................................. 22
9. C# or C Sharp............................................................................................................................ 26
Page | 7
10. Future Scope ........................................................................................................................... 62
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:-
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 -
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.
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 -
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
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.
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.
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
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.
Page | 16
4.2 Games develop in Unity3D are:-
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
To use and access various third party libraries like game room, visual
studio, etc.
To jump into the virtual world and decrease the rate of stress.
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
Fig: 6.4
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
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
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 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
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!");
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.
Run-time evaluation: JavaScript includes an eval function that can execute statements
provided as strings at run-time.
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.
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)
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
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
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.
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 {
/* my first program in C# */
Console.WriteLine("Hello World");
Console.ReadKey();
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
Fig: 10.1
Page | 29
GameObjects Used in Different Scenes
Fig: 10.2
Fig: 10.3
Page | 30
3) Level Scene Objects -
Fig: 10.4
Page | 31
4) High Score Scene Objects -
Fig: 10.5
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;
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;
Page | 33
{
void Start ()
{
Cursor.visible = true;
GlobalHealth.PlayerHealth = 10;
}
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.
Page | 35
private Vector3 m_OriginalCameraPosition;
private float m_StepCycle;
private float m_NextStep;
private bool m_Jumping;
private AudioSource m_AudioSource;
m_PreviouslyGrounded = m_CharacterController.isGrounded;
}
Page | 36
{
m_AudioSource.clip = m_LandSound;
m_AudioSource.Play();
m_NextStep = m_StepCycle + .5f;
}
// 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();
}
PlayFootStepAudio();
}
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;
}
#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);
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());
}
}
GunFire.js
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")) {
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;
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;
//SceneManager.LoadScene (1);
Page | 43
M9.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;
}
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;
function Update(){
InternalAmmo = CurrentAmmo;
InternalLoaded = LoadedAmmo;
AmmoDisplay.GetComponent.<Text>().text = "" + InternalAmmo;
LoadedDisplay.GetComponent.<Text>().text = "" + LoadedAmmo;
}
Pickup9mm.js
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
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(){
PlayerPrefs.SetInt("HighScore1",score);
GlobalHealth.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
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;
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;
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);
Page | 49
ZombieFollow.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
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");
}
IEnumerator EnemyDamage ()
{
IsAttacking = 1;
//attackSound = zombieAttackSound.GetComponent<AudioSource> ();
if (PainSound == 1) {
Hurt01.Play ();
if (PainSound == 2) {
Hurt02.Play ();
if (PainSound == 3) {
Hurt03.Play ();
Page | 51
}
EnemyScript.js
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;
4) Game Over
GOToMenu.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
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;
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;
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
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:
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