You are on page 1of 102

A.

I(Alien Invasion) Guard: Android-Based Tower Defense Game

A Thesis
Presented to the Faculty of
Information and Communications Technology Program
STI College Marikina

In Partial Fulfilment
of the Requirements for the Degree
Bachelor of Science in Information Technology

Raysoli M. Macakiling
Ian T. Oladive

December 2020

STI College Marikina i


ACKNOWLEDGEMENTS

This project development would not be possible without the help and support of these
people, especially the thesis adviser, Mr. Dave Lord M. Rubaya; thesis coordinator, Mr.
Frederic D. Yulo, MIM; and proofreader, Ms. Gem Darlah M. Alcarado, LPT for their
guidance, effort, never-ending patience, understanding and encouragement during the
project development.

The proponents mostly appreciated their family for their unconditional love, financial
support, and sacrifices to make this project happen. To friends and classmates for
helping, prayers, moral support, and giving them inspiration. In addition, the
proponents would like to thank the professors who helped, share their knowledge, and
give advices about the project development. Moreover, the proponents would like to
express their sincerest gratitude to each other for not giving up this project
development.

Last but not the least, to the Almighty God, for giving them strength, countless
blessings, hope and knowledge to finish this project.

STI College Marikina ii


ABSTRACT

Title of research: A.I(Alien Invasion) Guard

Researchers: Raysoli M. Macakiling


Ian T. Oladive

Degree: Bachelor of Science in Information Technology

Date of Completion: January 2021

Key words: Strategy Game, Tower Defense, 3D Game, Sci-Fi

A.I(Alien Invasion) Guard is a tower defense game where the player must erect
defensive structures such as towers, turrets, and other available structure against
incoming forces that has the goal to get to the other side and survive each level to finish
the game. This study aims to develop an offline action game that will let the users play
anytime without using internet connection. The goal of this study is to help users
improve critical thinking, strategic coordination, and situational awareness. A.I(Alien
Invasion) Guard is a three-dimensional (3D) offline game since it does not require
frequent update, heavy graphics, high Random Access Memory (RAM) and large
amount of memory. It features five stages, which the player must finish the previous
stage to unlock another stage. The game has a instruction module where it explains how
to play. The proponents conducted a survey and it shows that the system is useful.

STI College Marikina iii


TABLE OF CONTENTS

Page
Title Page i
Endorsement Form for Proposal Defense ii
Approval Sheet iii
Acknowledgements iv
Abstract v
Table of Contents vi
List of Tables vii
List of Figures viii
List of Appendices ix
Introduction 1
Background of the problem 2
Overview of the current state of technology 3
Objectives of the study 4
Scope and limitations of the study 6
Literature Review 7
Review of related literature, studies or systems 7
Synthesis 15
A.I(Alien Invasion) Guard 16
Results and Discussions 32-51
Conclusions and Recommendations 52
References 53
Appendices 56

STI College Marikina iv


LIST OF TABLES

Table Page
1 System Requirements 12
2.1-2.10 Tables of Pre-survey 32-42
3.1-3.10 Tables of UAT 43-50

STI College Marikina v


LIST OF FIGURES

Figure Page
1.1-1.18 System Design 13-23
2.1-2.3 Storyboard 24-26
3 Methodology of the Study 27
4.1-4.4 Hierarchical Input Process Output 29
5.1-5.2 Flowchart 30
6 Entity Relationship Diagram 31
7.1-7.10 Charts of Pre-survey 32-42
8.1-8.10 Pie charts of UAT 43-51
9.1-9.5 Online Survey for 10 years old and above 67-71
10.1-10.3 Online UAT for 10 years old and above 72-74

STI College Marikina vi


LIST OF APPENDICES

Appendix Page
A. Gantt chart of activities 49-50
B. User’s Manual 67-73
C. User Acceptance Testing and Pre-Survey 80-90
D. Curriculum Vitae of Researchers 91-93
E. Source Code 94-97

STI College Marikina vii


INTRODUCTION

Smartphone is a class of mobile phone that has multi-purpose computing capabilities.


They are distinguished from featuring phones by their stronger hardware and extensive
operating system for multimedia function like photos, music, video, camera, and
gaming. Majority of these devices run on any operating systems like Android, iOS,
Blackberry, Windows OS, etc. Most smartphones that are sought within the market is
appraise with their gaming capabilities and specs. For everyday life with time to spare,
games in phone are the best way to spend it.

The leading operating system today for smartphones is the Android Operating System.
They have been the best-selling OS worldwide on smartphone since 2011 and on tablets
since 2013. Most gaming phones is run by Android. It is an open-source operating
system specifically designed for smartphones and tablets. It delivers a complete set of
software for mobile devices by acting as a middleware and accommodating key mobile
applications.

Android games are popular today and can rival computer games in terms of its
playability. As the games are portable and can be played as the smartphone meets the
minimum requirement for the game, users can enjoy it anywhere. There are many types
of games, such as role-playing, arcade, educational, and tower defense games. This type
of games can be played both on offline and online. Mostly, offline games rely on
reliability for having no server shut down while online games are fun because of the
interaction with other players.

3D or Three Dimensional is a relating to or denoting a film or video game that creates


an impression of depth and solidity, typically by means of stereoscopic techniques. 3D
gaming is interactive computer entertainment that is graphically presented in the three
dimensions of height, width, and depth. Usually, it has a more immersive experience to
offer compared to 2D games. Also, compared to 2D games which is limited to linear

STI College Marikina viii


movements, its counterpart, 3D games, is unrestricted and has world movement. Lastly,
the versatility of its games is better than 2D games.
Tower defense games is a subgenre of strategy game where it has the objective where
you prevent a wave or horde of enemies to reach their goal at the end of the path. A
player can build certain defensive structures that will help defend the goal and stop the
wave or enemies to reach the next level. These games were one of the first game genre
to capture mobile gaming users. Because of its simplicity yet deep gameplay, it is fun
to play for all ages.

Background of the problem

The proponents considered A.I(Alien Invasion) Guard as the proposed system. There
are many tower defense game in the market already. The proponents will develop an
offline tower defense game that the target users with at least 10 years old can play
anytime without the use of internet connection. The proponents considered creating the
game using Unity using 3d models and game objects and intended for smartphones with
the Android OS.

General Objective
The proponents need to design and develop a game application intended for Android
Operating System using Unity platform that is intended for at least 10 years old which
they can play anytime without the use of internet connection.

This project is intended to solve the following specific problems:


1. How to design and develop a module that features different stages for five
levels?

The game should consist of five levels with each level increasing difficulty. This is
to challenge the player and to give a sense of achievement after completing the
game.
2. How to design and develop a module for optional adjust or an option module?

STI College Marikina 2


The game should consist a module for the user to adjust the background sounds and
see the credits of the game.

3. How to design and develop a generated pathway for the waves of enemies in
the game?

The game should follow the intended path during playtime and does not wonder of
to other places unless intended by the proponents.

4. How to design and develop a function that will allow the user to build defensive
turrets to use during playtime?

The game should only allow the user to place defensive turrets at the intended places
by the proponents.

5. How to design and develop a function that will allow the user to upgrade or sell
his defensive turrets in-game?

The user should be allowed to upgrade or sell his/her defensive turrets during
playtime to help him/her clear the level.

6. How to design and develop a module that generate in-game currency?

There are little numbers of tower defense games that will generate different in game
currency to use in the game. The proponents considered putting this in the system to
add a new feature.

7. How to design and develop a function that will save and load the player’s status
in-game automatically?

The user will want to save the game’s progress in case of quitting the game and
continuing it later.

Overview of the current state of the technology

A lot of action game can be played online or offline on Android. The proposed system
“A.I(Alien Invasion) Guard” has same game mechanics with Global Defense: Zombie

STI College Marikina 3


War. The Global Defense: Zombie War is a tower defense game that has a in-game
turret upgrades. The game brings a mind-stimulation strategy making where waves of
enemies come to race to the goal. In the game, the player builds turrets that will defend
against different kinds of zombies to survive the level. The player can upgrade the
turrets as the game goes on. There are 9 different types of turrets, 2 defense modes and
3 difficulty levels and 100 different kind of stages for the player to conquer and enjoy.

A.I(Alien Invasion) Guard is tower defense game. The player needs to defend the stage
by surviving the waves of enemies that are being sent to the goal. The player can buy
turrets that from the shop panel to defend from the waves. The player can upgrade the
tower to fight fast and sturdy waves. Once the enemies reach the end point, a life will
be deducted to the player until all life is lost, thus the player loses. The player can pause
and continue the game.

General Objective

This section includes description of the general and specific objectives of the study. The
objective of the study is to design and develop A.I(Alien Invasion) Guard for Android
operating system users using Unity as a platform and using 3d game objects for the
game. The proponents created a tower defense game for at least 10 years old where the
user can play it anytime without the use of internet connection.

Specific Objectives

• To design and develop a module that features different stages for five levels

The proponents designed and developed a game that has five different levels. The
players can proceed to another level when the previous level is accomplished. The
players can enjoy different stages to give a sense of achievement after completing the
game.

• To design and develop a module for optional adjust or an option module

The proponents designed and developed a module that has an optional adjustments or
an option module with a list of credits of the game.

STI College Marikina 4


• To design and develop a generated pathway for the waves of enemies in the
game

The proponents designed and developed a generated pathway for the waves to follow.
This ensures the user that enemies will proceed according to the path laid in the game.

• To design and develop a function that will allow the user to build defensive
turrets to use during playtime

The proponents developed a game node where the defensive turrets can be built for
the player to use in defending against the enemy.

• To design and develop a function that will allow the user to upgrade or sell
his/her defensive turrets in-game

The proponents developed a feature where the placed defensive turrets can be clicked
and options to upgrade or sell the turret is possible.

• To design and develop a module that generate in-game currency

The proponents designed and developed an in-game currency for the user to use in
upgrading the turrets.

• To design and develop a funtion that will save and load the player’s status in-
game automatically

The proponents designed and developed a game that will save the progress of the user
in the game.

STI College Marikina 5


Scope and Limitations of the study

The following are the scope and limitations of the project.

Scope

The proposed game “A.I(Alien Invasion) Guard” is designed to be played in Android


operating system. The goal is to create an offline strategy game which promotes.

1. Main Menu

This is the main interface of the game. It will include the title of the game, play, options,
and exit.

• Play Button

It allows the user to play and select the kind of game modes to begin with. There are
four kind of buttons in this form.

o Select Level – This button will show the player, how many levels need
to play to finish the game.

o Record – This button shows the tower appearance and its description.

o Instruction – This button tells the player how to play the game and what
are the function of each buttons.

2. Option

This allows the user to edit the effects volume and background music of the game.

a. Sound Level – This menu lets the user adjust what they hear from the
characters and the actions happening in the game.

3. Quit – It closes the application.

STI College Marikina 6


Limitation

1. The game does not contain in-app purchase.

The game does not sell any real life purchases to help you progress in the game.

2. The game is single player only

Players cannot play against other players

3. The game is intended for Android phones only.

The game has not been developed for other platforms.

4. The user cannot customize

The player cannot customize turrets for their own preference

STI College Marikina 7


LITERATURE REVIEW

Review of related literature, studies or systems

The purpose of this chapter placed the current study into the context of previous and
related research. As such, the review system emphasizes the relatedness between the
current system and the work of other.

Local Literature

According to the Ebrennan (2012), the objective of the game is simple, and the concept
is not particularly innovative. Basically, it is your job to defend some unmanned
kingdom from wolves, orcs, gargoyles, bandits, trolls, yetis, and many more enemies
by building four types of defense – barracks, archer towers, mages, and bombards. Each
structure has its own pros and cons, including price, damage, and range. Enemies arrive
in waves, and as you kill enemies, you gain more gold and can upgrade your towers.
The games narrative is a shallow, but the Lord of the Ring’s similarities are obvious
enough that the gamer can feel in the holes and naturally starts to invest more in the
story than the action that it gives you. There are a few sentences before every advance
on the map too. The story begins with you defending the port from highwaymen and
eventually progresses to full-out war, which puts you deeper in the map with more
defense options and way more enemies.

According to Mark (2010), Tower Defense, is a game system which, like all great game
systems, is simple to learn but hard to master. Almost without exception, it involves a
horde of lumbering creatures who enter from one location and are trying to make a trip
to the opposite side of your screen. If enough of them are successful, you lose the game.
To thwart their plans, you build “towers” to block their paths as best you can. The
towers do not just get in their way, however; they shoot, pummel or otherwise attack
the passing creeps. If you are quick on your feet and a bit of a strategist, you can prevent
the oncoming hordes from successfully making it from point A to point B. And that is
what it is all about.

Despite what everyone thought at the time, Tower Defense games did not start with
Warcraft III. In fact, Wikipedia says we were playing Tower Defense back in 1990 with
Atari’s arcade game “Rampart”. The genre really came into gamers’ awareness when

STI College Marikina 7


fans started making their own Tower Defense-style maps for Starcraft and Warcraft III
using free editors. What really catapulted the genre into ubiquity, however, was the
proliferation of Flash-based Web games to which the TD system lends itself very easily.
As web game developers are always looking for fun yet technologically simple ideas
for great games, the genre really leapt forward in its popularity.

According to Shokrizade (2015), it is his opinion that Supercell, creators of Clash of


Clans, has really earned their position in the industry by understanding the importance
of gender neutrality. Women make up 52% of gamers and generally have the “power
of the purse” in nuclear families. That said, the author think Hay Day is aimed more at
a less aggressive audience (with no direct combat), and Boom Beach is aimed at a more
aggressive audience (with a military theme and no shielding feature). Clash of Clans,
with its intense Comic Sans art style (I have pink and gold walls in my base) and
simplistic gameplay, is aimed at a younger demographic.

According to the article “the gamification of education why playing the future of
learning” by Michael Logarta (2014) students can benefit more in gamification if
education rather than using traditional way of educating students. Gamification means
using game mechanics to make teaching more interesting, motivation, casual and fun
for students. So instead of restricting them from playing games, why not use certain
games that can increase their knowledge, memorization and skills. Also, if lessons are
given in a game-like manner, students would tend to remember it more of them lectures
that are stated in a news-like manner.

According to the article of TJD of GMA News (2014), game development in the
Philippines that it has a lot of potential in generating jobs because right now, we have
few professionals related to gaming and information. This is in comparison to the other
competitors in other countries such in China, Singapore, Malaysia and Vietnam as
started also by an executive in Vietnam who said they had 10,000 game development
starts at school or earlier if possible so that companies that develop games could hire
highly skilled teams for the job.

STI College Marikina 9


Foreign Literature

According to Majgaard (2015), what makes the computer game Plants vs. Zombies
engaging and a successful learning machine? In the game, vegetables and flowers defeat
zombies by shooting peas, coconuts, and watermelons, and delaying the zombies by
feeding them walnuts. The game is a classic strategic tower defense game in a
vegetarian game universe. The game provides a unique example of seamlessly blending
the tutorial into the gameplay. This article analyses the game in order to identify
engaging elements that can be used in the design of serious games. Empowerment and
well-ordered problems were key elements found in the analysis of the gameplay in
Plants vs. Zombies. Empowerment can be split into active participation, meaningful
feedback, co-design, identity, and identification. The second key element, i.e., well-
ordered problems, can be divided into pleasantly frustrating, cycles of expertise,
strategies to achieve goals, and stripped-down version. Meaningful and engaging
gameplay makes the player invests a lot of time in playing and can trigger deep learning.
A first-hand experience of playing computer games gives valuable input for designing
serious games. The first-hand experiences are also valuable in the classroom when
relating game design theory to real-life experiences.

According to Andrei Dobra (2016), Plants vs. Zombies delighted millions of tower
defense many years ago when it appeared from PC and then be spread to many
platforms including consoles and mobile devices.
PopCap has released in 2013 the Plants vs. Zombies Adventures (abbreviated as PvZA).
The game had three modes: a town-building mode where players could build up their
town by buying buildings and decorations and planting plants, and a Road Trip mode
where players defended their vehicles from incoming zombies with plants harvested
from the town. The players could also play Brainball mode, they invaded other players'
town to get brains, and the five players with most brains in the leaderboard could get
gems. On July 14, 2014, a message appeared to all players that the game would close
on October 12, 2014. This is the first Plants vs. Zombies game to shut down.

According to Maiberg (2014), Anomaly: Warzone Earth launched in 2011 with a


simple, novel idea. We were being flooded with tower defense games at the time so 11
Bit Studios made a “tower offense” game, where, rather than set up defenses, you

STI College Marikina 10


played as the moving units to break through. It was successful enough to warrant a
sequel, Anomaly 2. Later, 11 Bit Studios created Anomaly: Defenders as the last sequel
of the game series.
In this series, the roles in the stories are opposite where the humans have been invaded
in the last 2 prequels are now the invaders and the aliens, opposed to their roles as the
invaders, are the defenders.

According to Lee (2013), Colosseum Defense is a defense game in which players press
to shoot the incoming waves of enemies that threaten the castle. Up to three unique
weapons can be equipped at one time and players can select which weapon abilities
best fit their play style. When the incoming waves become too difficult to manage,
powerful Magic can be used to stun and damage all enemies on the field. Featuring an
adaptive game interface, players can control how their game looks by advancing
through the levels, upgrading the Castle, unlocking powerful weapons, and changing
their avatar.

“We are excited to launch Colosseum Defense to Google Play,” stated Kyu Lee, VP
and Head of GAMEVIL USA, “The game offers a more casual game with clear game
progression that will have players engaged for hours."

According to Sholtz (2019), Defense Zone 3 HD is one of the more pragmatic tower
defense games on the Play Store, thanks to its realistic settings and weapons. There are
four separate difficulty levels on offer, which makes this a solid choice no matter your
skill level, and thanks to the inclusion of eight different kinds of turrets, you'll never
run out of options to take down your foes. This setup also allows for many different
tactical strategies when playing, making it interesting for players who are tired of
typical linear tower linear defense games.

STI College Marikina 11


Local Studies

According to Gabinete (2015), Clash of Clans is an addictive game where players build
a base, protect it, train troops and attack others. It is the hit army strategy game where
players raise their own army of barbarians, archers, hog riders, wizards, dragons and
other mighty fighters. it is a strategy game where players can construct and expand
one's village, unlock successively more powerful warriors and defenses, raid and
pillage resources from other villages, create and join clans and much, much more.
On the contrary, this game creates some hindrances and such distractions towards the
studies of many students. It decreases their time to study their lessons. In addition,
sometimesthey could no longer eat and sleep on time the way they used to before.
This research report provides an overview of how clash of clans affects the
performance of the CED students at Western Philippines University.

According to the study of Detablan (2016) entitled Mixed Up E-Games, the project has
different categories: different shape, math games, coloring games, typing games and
more. By creating various games that are fun yet educational, kids can learn skills like
problem-solving boosting creativity so they will have advance learning before they go
to school. Parents also benefit from it since they do not have to persuade their children
to learn new things. By letting the kids pay educational games, they will be able to
acquire new skills or improve what they already have.

According to Kong (2016) the game “The Leaning Tower of Pizza” is a tower defense
game where the players could enter each unit and attack all the enemies. Every wave
increases the level of difficulty and with each accomplished wave has an equivalent
reward such as golds that can be used to for upgrades, ability to add more tower or units
and more. The creator team shared the challenges they have encountered while doing
this project. According to them, working with a technology that they are not very much
familiar somehow gave them a slow start but by thorough research and advice from the
FEU Tech faculty, they were able to easily cope up with the problem. They did not have
issues with time as they had planned tasks. Their passion had kept them alive and
motivated to finishing the project.

STI College Marikina 12


According to Betsche (2017), the Nether Realms, which is still under development, will
be a mix between tower defense game and role-playing game and is inspired by cult
classics such as Plants vs. Zombies or Spore. Basically, players will send their monster
into battle to defeat other monsters. By collecting the souls of the fallen enemies, they
can rebuild their armies or train new monsters. The trick is to find the right balance
between expanding your own territory and building up protective defenses. All this will
happen in a 2D pixel environment set in a fantasy underworld.

According to De Vera (2016), this is not the same Plants vs. Zombies tower defense
game you used to play in between classes. This PVZ plays more like a kid-friendly
version of Call of Duty but with an anthpormorphic corn that shoots kernel and a
zombie piloting a mech. In multiplayer mode, the tables are turned, and you play team
zombie as they try to defend themselves from an attack by team plants.

Foreign Studies

According to Springer Link (2016), it is often necessary to create different versions of


a game prototype and gather information about players. LiverDefense, an educational
Tower Defense game about the basic functions of the human liver, which can be used
as a customizable research tool. LiverDefense can be customized via human-readable
XML files both in its degree of difficulty and the content of Likert scale questionnaires
to be presented to the player. As a proof of concept, LiverDefense has been successfully
employed in a psychological study focused on exploring the effect of perceived control
over gameplay on players’ emotions. The analysis of this study regarding enjoyment
and frustration and the resulting insights on using LiverDefense as a customizable
research tool.

According to the study of Romwell (2011), adaptive algorithms give away to solve a
problem through successive attempts, without needing much information about the
solution that the purpose of the tower defense games is to place towers that will kill
enemies before they can reach the end of the fixed path. Using adaptive algorithms for
a tower defense game allows the AI to not require any information about the types of
towers and the layout of the path. This paper discusses a simplified algorithm to this

STI College Marikina 13


problem (using only one type of tower), and possible extension to this algorithm that
would include multiple tower types and other modifications.

According to Liu (2019), Tower defense is a popular subgenre of real-time strategy


game requiring detailed level design and difficulty balancing to create an enjoyable
player experience. Because level production and testing are both time-consuming and
labor-intensive, they proposed and implemented a framework to automate the process.
They first analyzed the three main components, or "building blocks", of the popular
tower defense game Kingdom Rush: Frontiers (KRF), i.e. road maps, tower locations
and monster sequences. They automatically created new building blocks in the style of
the original game, utilizing techniques from Procedural Content Generation (PCG), and
assemble them to create new levels. They also added a fourth block: automated testing
via a Monte Carlo search algorithm, to ensure the generated content is playable.
Focusing on KRF because it is a popular video game in the tower defense genre, and
highlights some of the challenges of designing appropriate PCG and playtesting
algorithms for a commercial video game.

According to Sutoyo (2015), when we play tower defense game, generally we repeat
the same stages several times with the same enemies. Moreover, when the players play
a stage that is ridiculously hard or way too easy, they would probably quit the game
because it is moderately frustrating or boring. The purpose of this research is to create
a game that can adapt to the players’ ability, so the difficulty of the game becomes
dynamic. In other words, the game will have different difficulties of levels according
to the players’ ability. High difficulty levels will be set if the players use good strategy
and low difficulty levels will be set if the players use bad strategy. In this work, we
determine the difficulties based on players’ lives, enemies’ health, and passive skills
(skill points) that are chosen by the player. With three of these factors, players will have
varied experience of playing tower defense because different combination will give
different results to the system and difficulties of the games will be different for each
gameplay. The result of this research is a dynamic difficulty tower defense game,
dynamic difficulty adjustment (DDA) document, and gameplay outputs for best,
average, and worst strategy cases.

STI College Marikina 14


According to Gouveia (2015), in this article we state that serious gaming can be used
to help solve real world problems in education and health care. Serious gaming, which
aims to merge digital and real-world social environments, can be also instrumental to
enhance connectivity among communities. The main statements and ideas developed
in this paper are inspired in concrete projects and actions in the field of serious games,
game-based learning, transmedia experience and alternate reality games. The purpose
of this research is to review some literature and projects in serious gaming as future
inspirations for the creation and production of a serious game design applied to
education and/or health. The approached adapted in this paper relates to methodologies
used in communication science/design where it is presented a state of the art of the field
before creating and developing a game prototype. The main motivation of this paper is
to present a consistent body of projects to inspire future research in this area.

Synthesis

A.I(Alien Invasion) Guard was developed but do not intended to plagiarize any of the
related studies and literature. The game is based on the proponent’s own imagination,
the gameplay concept was inspired by Space Impact. A.I(Alien Invasion) Guard is a
tower defense game built for Android operating system. The players must survive the
waves of enemies to finish the game.

STI College Marikina 15


A.I(ALIEN INVASION) GUARD

Overview of the project

A.I(Alien Invasion) Guard: a Tower Defense Game is a system that the proponents
created to help the 10 years old target users to improve critical thinking, and relax while
taking a break from studying. The name “A.I(Alien Invasion) Guard” came from
Mobile Legends hero’s skin named Kimmy. “A.I(Alien Invasion) Guard” is a three-
dimensional tower defense game for Android where the player must survive the waves
and kill the enemies with defensive turrets to finish the game. The proponents created
A.I(Alien Invasion) Guard for the players that do like complicated strategy games. This
also improves critical thinking and situational awareness which are used in a variety of
daily skills. The proponents created A.I(Alien Invasion) Guard as an offline game and
three-dimensional game since it does not require large space on the memory.

System design specification

Minimum System Requirements Recommended System Requirements

Operating System: Android 4.4 Jellybean Operating System: Android 8.1.0 Oreo
API18 API27

CPU: 1.2 ghz Quad-Core processor CPU: 1.6GHz Octa-Core Processor

Storage: 50 MB Storage: 50 MB

RAM: 2 GB RAM: 2 GB

Screen Resolution: 720 x 1520 Screen Resolution: 720 x 1520

Display Type: Touchscreen Display Type: Touchscreen

Figure 1. System Requirements

STI College Marikina 12


System Design

Figure 2.1. Home

Figure 2.2. Options

STI College Marikina 17


Figure 2.3. Main Menu

Figure 2.4. Instructions

STI College Marikina 18


Figure 2.5. Records

Figure 2.6. Stage 1

STI College Marikina 19


Figure 2.7. Stage 2

Figure 2.8. Stage 3

STI College Marikina 20


Figure 2.9. Stage 4

Figure 2.10. Stage 5 / Credits

STI College Marikina 21


Figure 2.11. Paused Menu

Figure 2.12. Level Clear

STI College Marikina 22


Figure 2.13. Game Over

STI College Marikina 23


Figure 3.1. Storyboard

STI College Marikina 24


Figure 3.2. Storyboard

STI College Marikina 25


Figure 3.3s. Storyboard

Software development tools:

Unity engine

Unity is a cross-platform engine. The Unity editor is supported on Windows and


macOS, with a version of the editor available for the Linux platform, albeit in an
experimental stage, while the engine itself currently supports building games for more
than 25 different platforms, including mobile, desktop, consoles, and virtual reality.

Microsoft Visual Studio

Is an integrated development environment (IDE) from Microsoft. It is used to develop


computer programs, as well as websites, web apps, web services and mobile apps.
Visual Studio uses Microsoft software development platforms such as Windows API,
Windows Forms, Windows Presentation Foundation, Windows Store and Microsoft
Silverlight. It can produce both native code and managed code.

STI College Marikina 26


Methodology of the Study

Figure 3. Prototyping Model


Prototype methodology is defined as a Software Development model in which a
prototype is built, test, and then reworked when needed until an acceptable prototype is
achieved. It also creates a base to produce the final system.

Software prototyping model works best in scenarios where the project's requirement
are not known. It is an iterative, trial, and error method, which take place between the
developer and the client.

The proponents decided to use the Prototyping Model because the testing and
modifying of the project is necessary until the system achieved the objectives of the
study.
Step 1: Requirements gathering and analysis
A prototyping model starts with requirement analysis. In this phase, the requirements
of the system are defined in detail. During the process, the users of the system are
interviewed to know what the expectation from the system is.

The programmer gathered information how to use Unity game engine, Microsoft Visual
Studio to design and develop the system. Adobe Photoshop CS6 and Paint Tool SAI
for the character and the background of the game. Beep Box and Free sound for the
music.

Step 2: Quick design


The second phase is a preliminary design or a quick design. In this stage, a simple
design of the system is created. However, it is not a complete design. It gives a brief
idea of the system to the user. The quick design helps in developing the prototype.

STI College Marikina 27


The programmer created a storyboard for the concept of the game. The storyboard was
on a bond paper and presented to the thesis adviser.

Step 3: Build a Prototype


In this phase, an actual prototype is designed based on the information gathered from
quick design. It is a small working model of the required system.

During this phase, the proponents added and changed some objectives of the system
that the thesis adviser suggested.

Step 4: Initial user evaluation


In this stage, the proposed system is presented to the client for an initial evaluation. It
helps to find out the strength and weakness of the working model. Comment and
suggestion are collected from the customer and provided to the developer.

During this phase, the proponents asked some classmates to test the system and give
suggestions for the game.

Step 5: Refining prototype


If the user is not satisfied with the current prototype, the developers need to refine the
prototype according to the user's feedback and suggestions.

This phase will not over until all the requirements specified by the user are met. Once
the user is satisfied with the developed prototype, a final system is developed based on
the approved final prototype.

The proponents test and modify the system until the objectives of the study was
achieved. Since the system does not have specific audience, the proponents based on
classmates’ satisfaction.

Step 6: Implement Product and Maintain

STI College Marikina 28


Once the final system is developed based on the final prototype, it is thoroughly tested
and deployed to production. The system undergoes routine maintenance for minimizing
downtime and prevent large-scale failures.

During this phase, the proponents are able to publish the game. The proponents believe
that the system is fully functional.

Hierarchical Input Process Output

Figure 4.1. Main Menu Module

Figure 4.2. Play Module

STI College Marikina 29


Flowchart

Figure 5.1. Flowchart of the Home module.

STI College Marikina 30


Figure 5.2. Flowchart of the Level module.

STI College Marikina 31


Entity Relationship Diagram

Figure 6. Entity Relationship Diagram

STI College Marikina 32


RESULTS AND DISCUSSIONS

Pre-Survey

The proponents conducted an online Pre-survey to the target users. Each tables shows
the computation for the results of each questions.
1.) What is your gender?
a) Male
b) Female

Figure 7.1. Question #1

Male Female Total


26 14 40

Table 2.1. Question #1

The graph and table above show that the respondents answered Male are 26 and Female
are 14.

2. How old are you?


a) 10 – 12 yrs. Old
b) 13 – 15 yrs. Old
c) 16 – 18 yrs. Old
d) 19 yrs. Old and Above

STI College Marikina 33


Figure 7.2. Question #2

10 – 12 13 – 15 16 – 18 19 yrs. Old
Total
yrs. Old yrs. Old yrs. Old and Above

1 4 15 20 40

Table 2.2. Question #2

The graph and table above show that the respondents answered 1 for 10 – 12 yrs. Old,
4 for 13 – 15 yrs. Old, 15 for 16 – 18 yrs. Old, and 20 for 19 yrs. Old and Above
respectively.

3. Do you have your own mobile phone?


a) Yes
b) No

STI College Marikina 34


Figure 7.3. Question #3

Yes No Total
39 1 40
Table 2.3. Question #3

The graph and the table show that the respondents answered Yes are 29 and No are 1.

4. How much time do you usually spend playing mobile games a day?
a) 1-2 hours
b) 2-3 hours
c) 5 hours and Above

STI College Marikina 35


Figure 7.4. Question #4

1-2 2-3 5 hours and Total


hours hours above
9 9 22 40

Table 2.4. Question #4

The graph and table above show that the respondents answered 1-2 hours are 9, 2-3
hours are 9 and 5 hours and above are 22.

5. What type of mobile games do you play the most?


a) Puzzle
b) Action
c) Casual
d) Strategy

STI College Marikina 36


Figure 7.5. Question #5

Puzzle Action Casual Strategy Total


4 7 11 18 40

Table 2.5. Question #5

The graph and table above show that the respondents answered Puzzle are 4, Action are
7, Casual are 11, and Strategy are 18.

6. What kind of game do you prefer?


a) Online
b) Offline

STI College Marikina 37


Figure 7.6. Question #6

Online Offline Total


22 18 40
Table 2.6. Question #6

The graph and table show that the respondents answered Online are 22 and Offline are
18.

7. Which game do you prefer?


a) Single Player
b) Multiple Player

STI College Marikina 38


Figure 7.7. Question #7

Single Multiple
Total
Player Player
22 18 40

Table 2.7. Question #7

The graph and table above show that the respondents answered Single Player are 22
and Multiple Player 18.

8. What attracts you most in a mobile game?


a) Storyline
b) Game Style
c) Graphics

STI College Marikina 39


Figure 7.8. Question #8

Storyline Game Style Graphics Total


9 17 14 40

Table 2.8. Question #8

The graph and table above show that the respondents answered Storyline are 9, Game
Style are 17, and Graphics are 14.

9. Why do you play games?


a) It challenges my mind
b) I will play anything when I am bored
c) I follow mainstream games

STI College Marikina 40


Figure 7.9. Question #9

I follow
I will play
It challenges mainstream
anything when Total
my mind games
I am bored

11 23 6 40

Table 2.9. Question #9


The graph and table show that the respondents answered Single Player are 22 and
Multiple Player are 18.

10. What is your favorite game?

STI College Marikina 41


Figure 7.10. Question #10

Mobile Subway Clash Total


Wild Rift Others
Legends Surf Royal
5 7 12 6 10 40

Table 2.10. Question #10

The graph and table above show that the respondents answered Mobile Legends are 5,
Subway Surf are 7, Wild Rift are 12, Clash Royal are 6, and Others are 10.

STI College Marikina 42


User Acceptance Testing

The proponents conducted a User Acceptance Testing to 50 respondents. Each table


shows the computation for the results of each questions.

Design:
Readability (proper font size, font style, color scheme)
5 4 3 2 1 Total Weighted Interpretation
Outstanding Good Satisfactory Poor Unsatisfactory Mean
7 33 10 0 0 50 3.94 Good
Table 3.1. Readability

Figure 8.1. Readability

The table and pie chart above shows that the Readability of the design is 14%
Outstanding, 66% Good, 14% Satisfactory, 0% Poor, and 0% Unsatisfactory. The result
is 66%, interpreted as Good, and weighted mean is 4.36.

STI College Marikina 43


Formality Design (overall Quality Design)
5 4 3 2 1 Total Weighted Interpretation
Outstanding Good Satisfactory Poor Unsatisfactory Mean
11 25 14 0 0 50 3.94 Good
Table 3.2. Formality Design

Figure 8.2. Formality Design

The table and pie chart shows that the Formality of the design is 22% Outstanding, 50%
Good, 28% Satisfactory, 0% Poor, and 0% Unsatisfactory. The result is 50%,
interpreted as Good, and weighted mean 3.94.

Accuracy (modules/components)

5 4 3 2 1 Total Weighted Interpretation


Outstanding Good Satisfactory Poor Unsatisfactory Mean
7 23 20 0 0 50 3.74 Good
Table 3.3. Accuracy

STI College Marikina 44


Figure 8.3. Accuracy

The table and pie chart shows that the Accuracy of the design is 14% Outstanding, 46%
Good, 40% Satisfactory, 0% Poor, and 0% Unsatisfactory. The result is 46%,
interpreted as Good, and weighted mean is 3.74.

User Friendly
5 4 3 2 1 Total Weighted Interpretation
Outstanding Good Satisfactory Poor Unsatisfactory Mean
11 28 11 0 0 50 3.96 Good
Table 3.4. User Friendly

STI College Marikina 45


Figure 8.4. User Friendly

The table and pie chart above shows that the User Friendliness of the design is 22%
Outstanding, 56% Good, 22% Satisfactory, 0% Poor, and 0% Unsatisfactory. The result
is 56%, interpreted as Good, and weighted mean is 3.96.

STI College Marikina 46


System Performance:
Speed Response (upon click/touch)

5 4 3 2 1 Total Weighted Interpretation


Outstanding Good Satisfactory Poor Unsatisfactory Mean
8 22 20 0 0 50 3.96 Good
Table 3.5. Speed Response

Figure 8.5. Speed Response

The table and pie chart above shows that the Speed Response of the design is 16%
Outstanding, 44% Good, 40% Satisfactory, 0% Poor, and 0% Unsatisfactory. The result
is 44%, interpreted as Good, and weighted mean is 3.76.

Usefulness

STI College Marikina 45


5 4 3 2 1 Total Weighted Interpretation
Outstanding Good Satisfactory Poor Unsatisfactory Mean
5 23 22 0 0 50 3.66 Good
Table 3.6. Usefulness

Figure 8.6. Usefulness

The table and pie chart above shows that the Usefulness of the system is 10%
Outstanding, 46% Good, 44% Satisfactory, 0% Poor, and 0% Unsatisfactory. The result
is 46%, interpreted as Satisfactory, and weighted mean is 3.66.

Performance of the System

5 4 3 2 1 Total Weighted Interpretation


Outstanding Good Satisfactory Poor Unsatisfactory Mean
5 30 15 0 0 50 3.8 Good
Table 3.7. Performance of the System

STI College Marikina 48


Figure 8.7. Performance of the System

The table and pie chart above shows that the Performance of the System is 10%
Outstanding, 60% Good, 30% Satisfactory, 0% Poor, and 0% Unsatisfactory. The result
is 60%, interpreted as Good, and weighted mean is 3.8.

System Validation:
Error handling
5 4 3 2 1 Total Weighted Interpretation
Outstanding Good Satisfactory Poor Unsatisfactory Mean
7 22 21 0 0 50 3.72 Good
Table 3.8. Error handling

STI College Marikina 49


Figure 8.8. Error Handling

The table and pie chart above shows that the Error Handling of the system is 14%
Outstanding, 44% Good, 42% Satisfactory, 0% Poor, and 0% Unsatisfactory. The result
is 44%, interpreted as Good, and weighted mean is 3.72.

Correctness

5 4 3 2 1 Total Weighted Interpretation


Outstanding Good Satisfactory Poor Unsatisfactory Mean
3 29 18 0 0 50 3.7 Good
Table 3.9. Correctness

STI College Marikina 50


Figure 8.9. Correctness

The table and pie chart above shows that the Correctness of the system is 6%
Outstanding, 58% Good, 36% Satisfactory, 0% Poor, and 0% Unsatisfactory. The result
is 58%, interpreted as Satisfactory, and weighted mean is 3.7.

Reliability
5 4 3 2 1 Total Weighted Interpretation
Outstanding Good Satisfactory Poor Unsatisfactory Mean
6 27 17 0 0 50 3.78 Good
Table 3.10. Reliability

STI College Marikina 51


Figure 8.10. Reliability

The table and pie chart above shows that the Usefulness of the design is 12%
Outstanding, 54% Good, 34% Satisfactory, 0% Poor, and 0% Unsatisfactory. The result
is 54% interpreted as Good, and weighted mean is 3.78.

STI College Marikina 52


CONCLUSIONS AND RECOMMENDATIONS

Conclusion
The proponents conducted a Pre-survey and a User Acceptance Testing to know how
relevant their system is to the target users. The results shown in the tables and pie chart
shows that the system is feasible. A.I(Alien Invasion) Guard can help users 10 years
old and above to entertain as well as to improve critical thinking of the user. After
gathering results, the proponents concluded that the objectives is achieved and the game
is fully functional.

Recommendation
For the continuation of the project, the proponents recommended that the game can be
better if it has more features, a larger scope and available for iOS mobile phones.

STI College Marikina 53


REFERENCES

Gunver Majgaard (2015). PLANTS VS ZOMBIES AS AN EMPOWERING LEARNING


MACHINE. Retrieved from http://gunvermajgaard.dk/wp-
content/uploads/2012/03/Majgaard_GET_2015.pdf

Yasmin Ebrennan (2012). Developing Gaming Fluencies with Scratch: Realizing Game
Design as an Artistic Process
https://www.researchgate.net/publication/264995626_Developing_Gaming_Fluencies
_with_Scratch_Realizing_Game_Design_as_an_Artistic_Process

Tamas Mark (2010). Understanding Tower Defense games


https://www.loopinsight.com/2010/03/30/understanding-tower-defense-games/

Michael Logarta (2014). The gamification of education: Why playing is the future of
learning
https://www.gmanetwork.com/news/scitech/technology/365281/the-gamification-of-
education-why-playing-is-the-future-of-learning/story

Estacio, Z. (2018). Why Mobile is now the No.1 platform for games. Retrieved from
https://www.yugatech.com/feature/why-mobile-is-now-the-no-1-platform-for-
games/#sthash.iwfzxl7D.dpbs#F8fpeTcVSczWytb1.97 [Accessed 10 Oct. 2019].

En.wikipedia.org. (n.d.). Microsoft Visual Studio. Retrieved from


https://en.wikipedia.org/wiki/Microsoft_Visual_Studio [Accessed 14 Oct. 2019].

En.wikipedia.org. (n.d.). Unity (game engine). Retrieved from


https://en.wikipedia.org/wiki/Unity_(game_engine) [Accessed 6 Oct. 2019].

Guru99.com. (n.d.). Prototyping Model in Software Engineering: Methodology,


Process, Approach. Retrieved from https://www.guru99.com/software-engineering-
prototyping-model.html [Accessed 8 Oct. 2019].

STI College Marikina 54


Hughes, J. (2011). MOBILE MARKETING: A NEW DIRECT MARKETING
PROMOTIONAL CHANNEL. Retrieved from
https://www.researchgate.net/publication/318561405_Mobile_Marketing_A_New_Di
rect_Marketing_Promotional_Channel [Accessed 28 Sep. 2019].

Indigo Entertainment. (2016). Agent Aliens. Retrieved from http://indigo-


entertainment.com/games/agent-aliens [Accessed 2 Oct. 2019].

M.mobilelegends.com. (n.d.). Kimmy. Retrieved from https://m.mobilelegends.com/en/


[Accessed 28 Oct. 2019].

Morelikegames.com. (2016). The Bug Butcher. Retrieved from


https://www.moregameslike.com/the-bug-butcher/ [Accessed 6 Oct. 2019].

Promsutipong, P., & Kotrajaras, V. (2017, July). Enemy evaluation AI for 2D action-
platform game. In 2017 14th International Joint Conference on Computer Science and
Software Engineering (JCSSE) (pp. 1-6). IEEE. Retrieved from https://sci-
hub.tw/10.1109/JCSSE.2017.8025906 [Accessed 8 Oct. 2019].

Speckmann, B. (2008). MOBILE MARKETING: A NEW DIRECT MARKETING


PROMOTIONAL CHANNEL. Retrieved from
https://www.researchgate.net/publication/318561405_Mobile_Marketing_A_New_Di
rect_Marketing_Promotional_Channel [Accessed 28 Sep. 2019].

Systemax.jp (n.d.). Paint Tool SAI. Retrieved from https://www.systemax.jp/en/sai/


[Accessed 14 Oct. 2019].

Wang, P., Liu, H. H., Zhu, X. T., Meng, T., Li, H. J., & Zuo, X. N. (2016). Action video
game training for healthy adults: a meta-analytic study. Frontiers in psychology, 7,
907. Retrieved from
https://www.frontiersin.org/articles/10.3389/fpsyg.2016.00907/full [Accessed 8 Oct.
2019].

STI College Marikina 55


Acet Edeza (2014). Utilization of BSBA Student's Allowances in Playing Mobile
Games
https://www.coursehero.com/file/p5jd6qc8/According-to-an-article-TJD-GMA-News-
Game-Development-industry-in-the/
Music for Video Library. (2017). ROYALTY FREE Documentary Background Music
Serious Documentary Music Royalty Free Retrieved from
https://www.youtube.com/watch?v=4_HUlAFlxwU
Infraction. (2018). Epic Hybrid Sci-Fi Music by Raspberrymusic [No Copyright Music]
Aliens Retrieved from
https://www.youtube.com/watch?v=2H8kJBjdYvU&t=26s

STI College Marikina 56


APPENDICES

STI College Marikina 57


APPENDIX A. GANTT CHART

STI College Marikina 58


STI College Marikina 59
STI College Marikina 60
APPENDIX B. USER’S MANUAL

STI College Marikina 61


User’s Manual

Options
Quit Button Play button

Record Button

Back button to proceed back to home.


Instruction Button
Proceed to a certain stages.
STI College Marikina 62
Money Number of life

Mini Map

Pause button to pause the game.


Turret build spots Shop Button

STI College Marikina 63


Retry button to retry the game.
Menu button to proceed home.

STI College Marikina 64


Resume button to resume the game when its pause .
Menu button to proceed main menu.
Quit button to exit the game.

Next Level button to proceed to next stage


Menu button to proceed to main menu

STI College Marikina 65


Sound scroll

STI College Marikina 66


APPENDIX E. LETTERS AND CERTIFICATION

STI College Marikina 67


APPENDIX C. USER ACCEPTANCE TESTING AND PRE-SURVEY

STI College Marikina 68


Figure 9.1. Online Survey for 10 years old

STI College Marikina 69


Figure 9.2. Online Survey for 10 years old and above

STI College Marikina 70


Figure 9.3. Online Survey for 10 years old and above

STI College Marikina 71


Figure 9.4. Online Survey for 10 years old and above

STI College Marikina 72


Figure 9.5. Online Survey for 10 years old and above

STI College Marikina 73


Figure 10.1. Online UAT for 10 years old and above

STI College Marikina 74


Figure 10.2. Online UAT for 10 years old and above

STI College Marikina 75


Figure 10.3. Online UAT for 10 years old and above

STI College Marikina 76


APPENDIX D. CURRICULUM VITAE OF RESEARCHERS

STI College Marikina 77


Curriculum Vitae of
RAYSOLI M. MACAKILING
Block 1 Lot 3 Goldland Eastwood, Village East, Cainta, Rizal
mayorngeac@gmail.com
09611105075

EDUCATIONAL BACKGROUND
Level Inclusive Dates Name of school/ Institution
Tertiary June 2016 – STI College Marikina
current
TechVoc None none

High School June 2010 - La Petite Learning Center/Dee Hwa Liong Academy
March 2014
Elementary June 2004 - La Petite Learning Center
March 2010

PROFESSIONAL OR VOLUNTEER EXPERIENCE


Nature of Experience/ Name and Address of Company or
Inclusive Dates
Job Title Organization

AFFILIATIONS
Inclusive Dates Name of Organization Position

SKILLS
SKILLS Level of Competency Date Acquired

TRAININGS, SEMINARS OR WORKSHOP ATTENDED


Inclusive Dates Title of Training, Seminar or Workshop

STI College Marikina 78


APPENDIX E. SOURCE CODE

STI College Marikina 79


A.I(Alien Invasion) Guard
Source code
using UnityEngine; return;
using System.Collections; }

public class ActiveStateToggler: MonoBehaviour { selectedNode = node;


turretToBuild = null;
public void ToggleActive () {
gameObject.SetActive nodeUI.SetTarget(node);
(!gameObject.activeSelf); }
}
} public void DeselectNode()
{
selectedNode = null;
using UnityEngine; nodeUI.Hide();
using System.Collections; }

public class ApplicationManager : MonoBehaviour { public void SelectTurretToBuild (TurretBlueprint


turret)
{
public void Quit () turretToBuild = turret;
{ DeselectNode();
#if UNITY_EDITOR }
UnityEditor.EditorApplication.isPlaying
= false; public TurretBlueprint GetTurretToBuild ()
#else {
Application.Quit(); return turretToBuild;
#endif }
}
} }

using UnityEngine; using UnityEngine;

public class BuildManager : MonoBehaviour { public class Bullet : MonoBehaviour {

public static BuildManager instance; private Transform target;

void Awake () public float speed = 70f;


{
if (instance != null) public int damage = 50;
{
Debug.LogError("More than public float explosionRadius = 0f;
one BuildManager in scene!"); public GameObject impactEffect;
return;
} public void Seek (Transform _target)
instance = this; {
} target = _target;
}
public GameObject buildEffect;
public GameObject sellEffect; // Update is called once per frame
void Update () {
private TurretBlueprint turretToBuild;
private Node selectedNode; if (target == null)
{
public NodeUI nodeUI; Destroy(gameObject);
return;
public bool CanBuild { get { return turretToBuild != }
null; } }
public bool HasMoney { get { return Vector3 dir = target.position -
PlayerStats.Money >= turretToBuild.cost; } } transform.position;
float distanceThisFrame = speed *
public void SelectNode (Node node) Time.deltaTime;
{
if (selectedNode == node) if (dir.magnitude <= distanceThisFrame)
{ {
DeselectNode(); HitTarget();

STI College Marikina 80


return;
} private void Awake()
{
transform.Translate(dir.normalized * if (Camera == null)
distanceThisFrame, Space.World); Camera = Camera.main;
transform.LookAt(target); }

} private void Update()


{
void HitTarget ()
{ //Update Plane
GameObject effectIns = if (Input.touchCount >= 1)
(GameObject)Instantiate(impactEffect, transform.position, Plane.SetNormalAndPosition(transform.up,
transform.rotation); transform.position);
Destroy(effectIns, 5f);
var Delta1 = Vector3.zero;
if (explosionRadius > 0f) var Delta2 = Vector3.zero;
{
Explode(); //Scroll
} else if (Input.touchCount >= 1)
{ {
Damage(target); Delta1 = PlanePositionDelta(Input.GetTouch(0));
} if (Input.GetTouch(0).phase == TouchPhase.Moved)
Camera.transform.Translate(Delta1, Space.World);
Destroy(gameObject); }
}
//Pinch
void Explode () if (Input.touchCount >= 2)
{ {
Collider[] colliders = var pos1 = PlanePosition(Input.GetTouch(0).position);
Physics.OverlapSphere(transform.position, explosionRadius); var pos2 = PlanePosition(Input.GetTouch(1).position);
foreach (Collider collider in colliders) var pos1b = PlanePosition(Input.GetTouch(0).position -
{ Input.GetTouch(0).deltaPosition);
if (collider.tag == "Enemy") var pos2b = PlanePosition(Input.GetTouch(1).position -
{ Input.GetTouch(1).deltaPosition);

Damage(collider.transform); //calc zoom


} var zoom = Vector3.Distance(pos1, pos2) /
} Vector3.Distance(pos1b, pos2b);
}
//edge case
void Damage (Transform enemy) if (zoom == 0 || zoom > 10)
{ return;
Enemy e =
enemy.GetComponent<Enemy>(); //Move cam amount the mid ray
Camera.transform.position =
if (e != null) Vector3.LerpUnclamped(pos1, Camera.transform.position, 1 /
{ zoom);
e.TakeDamage(damage);
} if (Rotate && pos2b != pos2)
} Camera.transform.RotateAround(pos1,
Plane.normal, Vector3.SignedAngle(pos2 - pos1, pos2b - pos1b,
void OnDrawGizmosSelected () Plane.normal));
{ }
Gizmos.color = Color.red;
}
Gizmos.DrawWireSphere(transform.position,
explosionRadius); protected Vector3 PlanePositionDelta(Touch touch)
} {
} //not moved
if (touch.phase != TouchPhase.Moved)
return Vector3.zero;
using UnityEngine;
//delta
class CameraController : MonoBehaviour var rayBefore = Camera.ScreenPointToRay(touch.position
{ - touch.deltaPosition);
#if UNITY_IOS || UNITY_ANDROID var rayNow = Camera.ScreenPointToRay(touch.position);
public Camera Camera; if (Plane.Raycast(rayBefore, out var enterBefore) &&
public bool Rotate; Plane.Raycast(rayNow, out var enterNow))
protected Plane Plane;

STI College Marikina 81


return rayBefore.GetPoint(enterBefore) - GetComponent<Light>().color
rayNow.GetPoint(enterNow); = c;
}
//not on plane
return Vector3.zero; public void OnPointerClick(PointerEventData data)
} {
if (GetComponent<Renderer>() != null)
protected Vector3 PlanePosition(Vector2 screenPos)
{ GetComponent<Renderer>().material.color = new
//position Color(Random.value, Random.value, Random.value, 1.0f);
var rayNow = Camera.ScreenPointToRay(screenPos); else if (GetComponent<Light>() != null)
if (Plane.Raycast(rayNow, out var enterNow)) GetComponent<Light>().color
return rayNow.GetPoint(enterNow); = new Color(Random.value, Random.value, Random.value,
1.0f);
return Vector3.zero; }
} }

private void OnDrawGizmos() using System.Collections;


{ using System.Collections.Generic;
Gizmos.DrawLine(transform.position, transform.position using UnityEngine;
+ transform.up); using UnityEngine.UI;
}
#endif public class CompleteLevel : MonoBehaviour {
}
public string menuSceneName = "MainMenu";

using UnityEngine; public string nextLevel = "Level02";


using UnityEngine.EventSystems; public int levelToUnlock = 2;
using UnityEngine.UI; public static int Currencyworth = 2;
public Text worthText;
public class ChangeColor : MonoBehaviour, public SceneFader sceneFader;
IPointerClickHandler
{ public void AddCurrency()
void OnEnable () {
{ Stats.Currency += Currencyworth;
} worthText.text = ""+
Currencyworth.ToString();
public void SetRed(float value)
{ }
OnValueChanged(value, 0); public void Continue ()
} {
PlayerPrefs.SetInt("levelReached",
public void SetGreen(float value) levelToUnlock);
{ sceneFader.FadeTo(nextLevel);
OnValueChanged(value, 1); }
}
public void Menu ()
public void SetBlue(float value) {
{ sceneFader.FadeTo(menuSceneName);
OnValueChanged(value, 2); }
}
}
public void OnValueChanged(float value, int using System.Collections.Generic;
channel) using UnityEngine;
{ using UnityEngine.EventSystems;
Color c = Color.white; using UnityEngine.UI;

if (GetComponent<Renderer>() != null) [RequireComponent(typeof(Image))]


c = public class DragMe : MonoBehaviour, IBeginDragHandler,
GetComponent<Renderer>().material.color; IDragHandler, IEndDragHandler
else if (GetComponent<Light>() != null) {
c = public bool dragOnSurfaces = true;
GetComponent<Light>().color;
private Dictionary<int,GameObject>
c[channel] = value; m_DraggingIcons = new Dictionary<int, GameObject>();
private Dictionary<int, RectTransform>
if (GetComponent<Renderer>() != null) m_DraggingPlanes = new Dictionary<int, RectTransform>();

GetComponent<Renderer>().material.color = c; public void OnBeginDrag(PointerEventData


else if (GetComponent<Light>() != null) eventData)

STI College Marikina 82


{ if
var canvas = (RectTransformUtility.ScreenPointToWorldPointInRectangle(
FindInParents<Canvas>(gameObject); m_DraggingPlanes[eventData.pointerId], eventData.position,
if (canvas == null) eventData.pressEventCamera, out globalMousePos))
return; {
rt.position = globalMousePos;
// We have clicked something that can be rt.rotation =
dragged. m_DraggingPlanes[eventData.pointerId].rotation;
// What we want to do is create an icon for }
this. }
m_DraggingIcons[eventData.pointerId] =
new GameObject("icon"); public void OnEndDrag(PointerEventData
eventData)
{
m_DraggingIcons[eventData.pointerId].transform.S if
etParent (canvas.transform, false); (m_DraggingIcons[eventData.pointerId] != null)

m_DraggingIcons[eventData.pointerId].transform.S Destroy(m_DraggingIcons[eventData.pointerId]);
etAsLastSibling();
m_DraggingIcons[eventData.pointerId] =
var image = null;
m_DraggingIcons[eventData.pointerId].AddComponent<Imag }
e>();
// The icon will be under the cursor. static public T FindInParents<T>(GameObject go)
// We want it to be ignored by the event where T : Component
system. {
var group = if (go == null) return null;
m_DraggingIcons[eventData.pointerId].AddComponent<Canv var comp = go.GetComponent<T>();
asGroup>();
group.blocksRaycasts = false; if (comp != null)
return comp;
image.sprite =
GetComponent<Image>().sprite; var t = go.transform.parent;
image.SetNativeSize(); while (t != null && comp == null)
{
if (dragOnSurfaces) comp =
t.gameObject.GetComponent<T>();
m_DraggingPlanes[eventData.pointerId] = t = t.parent;
transform as RectTransform; }
else return comp;
}
m_DraggingPlanes[eventData.pointerId] = }
canvas.transform as RectTransform;

SetDraggedPosition(eventData); using UnityEngine;


} using UnityEngine.UI;
using UnityEngine.EventSystems;
public void OnDrag(PointerEventData eventData) using System.Collections;
{
if public class DragPanel : MonoBehaviour,
(m_DraggingIcons[eventData.pointerId] != null) IPointerDownHandler, IDragHandler {

SetDraggedPosition(eventData); private Vector2 originalLocalPointerPosition;


} private Vector3 originalPanelLocalPosition;
private RectTransform panelRectTransform;
private void SetDraggedPosition(PointerEventData private RectTransform parentRectTransform;
eventData)
{ void Awake () {
if (dragOnSurfaces && panelRectTransform = transform.parent
eventData.pointerEnter != null && as RectTransform;
eventData.pointerEnter.transform as RectTransform != null) parentRectTransform =
panelRectTransform.parent as RectTransform;
m_DraggingPlanes[eventData.pointerId] = }
eventData.pointerEnter.transform as RectTransform;
public void OnPointerDown (PointerEventData data)
var rt = {
m_DraggingIcons[eventData.pointerId].GetComponent<RectT originalPanelLocalPosition =
ransform>(); panelRectTransform.localPosition;
Vector3 globalMousePos;
RectTransformUtility.ScreenPointToLocalPointInR

STI College Marikina 83


ectangle (parentRectTransform, data.position, {
data.pressEventCamera, out originalLocalPointerPosition); containerImage.color = normalColor;
}
if (receivingImage == null)
public void OnDrag (PointerEventData data) { return;
if (panelRectTransform == null ||
parentRectTransform == null) Sprite dropSprite = GetDropSprite (data);
return; if (dropSprite != null)
receivingImage.overrideSprite
Vector2 localPointerPosition; = dropSprite;
if }
(RectTransformUtility.ScreenPointToLocalPointInRectangle
(parentRectTransform, data.position, data.pressEventCamera, public void OnPointerEnter(PointerEventData data)
out localPointerPosition)) { {
Vector3 offsetToOriginal = if (containerImage == null)
localPointerPosition - originalLocalPointerPosition; return;

panelRectTransform.localPosition = Sprite dropSprite = GetDropSprite (data);


originalPanelLocalPosition + offsetToOriginal; if (dropSprite != null)
} containerImage.color =
highlightColor;
ClampToWindow (); }
}
public void OnPointerExit(PointerEventData data)
// Clamp panel to area of parent {
void ClampToWindow () { if (containerImage == null)
Vector3 pos = return;
panelRectTransform.localPosition;
containerImage.color = normalColor;
Vector3 minPosition = }
parentRectTransform.rect.min -
panelRectTransform.rect.min; private Sprite GetDropSprite(PointerEventData
Vector3 maxPosition = data)
parentRectTransform.rect.max - {
panelRectTransform.rect.max; var originalObj = data.pointerDrag;
if (originalObj == null)
pos.x = Mathf.Clamp return null;
(panelRectTransform.localPosition.x, minPosition.x,
maxPosition.x); var dragMe =
pos.y = Mathf.Clamp originalObj.GetComponent<DragMe>();
(panelRectTransform.localPosition.y, minPosition.y, if (dragMe == null)
maxPosition.y); return null;

panelRectTransform.localPosition = pos; var srcImage =


} originalObj.GetComponent<Image>();
} if (srcImage == null)
return null;

return srcImage.sprite;
using System.Reflection; }
using UnityEngine; }
using UnityEngine.EventSystems;
using UnityEngine.UI;
using UnityEngine;
public class DropMe : MonoBehaviour, IDropHandler, using UnityEngine.UI;
IPointerEnterHandler, IPointerExitHandler
{ public class Enemy : MonoBehaviour {
public Image containerImage;
public Image receivingImage; public float startSpeed = 10f;
private Color normalColor;
public Color highlightColor = Color.yellow; [HideInInspector]
public float speed;
public void OnEnable ()
{ public float startHealth = 100;
if (containerImage != null) private float health;
normalColor =
containerImage.color; public int worth = 50;
}
public GameObject deathEffect;
public void OnDrop(PointerEventData data)

STI College Marikina 84


[Header("Unity Stuff")] transform.Translate(dir.normalized *
public Image healthBar; enemy.speed * Time.deltaTime, Space.World);

private bool isDead = false; if (Vector3.Distance(transform.position,


target.position) <= 0.4f)
void Start () {
{ GetNextWaypoint();
speed = startSpeed; }
health = startHealth;
} enemy.speed = enemy.startSpeed;
}
public void TakeDamage (float amount)
{ void GetNextWaypoint()
health -= amount; {
if (wavepointIndex >=
healthBar.fillAmount = health / Waypoints.points.Length - 1)
startHealth; {
EndPath();
if (health <= 0 && !isDead) return;
{ }
Die();
} wavepointIndex++;
} target =
Waypoints.points[wavepointIndex];
public void Slow (float pct) }
{
speed = startSpeed * (1f - pct); void EndPath()
} {
PlayerStats.Lives--;
void Die () WaveSpawner.EnemiesAlive--;
{ Destroy(gameObject);
isDead = true; }

PlayerStats.Money += worth; }

GameObject effect =
(GameObject)Instantiate(deathEffect, transform.position, using UnityEngine;
Quaternion.identity); using System.Collections;
Destroy(effect, 5f);
public class GameManager : MonoBehaviour {
WaveSpawner.EnemiesAlive--;
public static bool GameIsOver;
Destroy(gameObject);
} public GameObject gameOverUI;
public GameObject completeLevelUI;
}
void Start ()
{
using UnityEngine; GameIsOver = false;
using System.Collections; }

[RequireComponent(typeof(Enemy))] // Update is called once per frame


public class EnemyMovement : MonoBehaviour { void Update () {
if (GameIsOver)
private Transform target; return;
private int wavepointIndex = 0;
if (PlayerStats.Lives <= 0)
private Enemy enemy; {
EndGame();
void Start() }
{ }
enemy = GetComponent<Enemy>();
void EndGame ()
target = Waypoints.points[0]; {
} GameIsOver = true;
gameOverUI.SetActive(true);
void Update() }
{
Vector3 dir = target.position - public void WinLevel ()
transform.position; {

STI College Marikina 85


GameIsOver = true; void Update () {
completeLevelUI.SetActive(true); livesText.text =
} PlayerStats.Lives.ToString() + " LIVES";
}
} }
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine;
using UnityEngine.SceneManagement; public class MainMenu : MonoBehaviour {

public class GameOver : MonoBehaviour { public string levelToLoad = "MainLevel";


public string option = "Setting";
public string menuSceneName = "MainMenu"; public SceneFader sceneFader;

public SceneFader sceneFader; public void Play ()


{
public void Retry () sceneFader.FadeTo(levelToLoad);
{ }

sceneFader.FadeTo(SceneManager.GetActiveScene( public void Option ()


).name); {
} sceneFader.FadeTo(option);
}
public void Menu ()
{ public void Quit ()
sceneFader.FadeTo(menuSceneName); {
} Debug.Log("Exciting...");
Application.Quit();
} }

}
using UnityEngine;
using UnityEngine.UI;
using UnityEngine;
public class LevelSelector : MonoBehaviour { using UnityEngine.UI;
using System.Collections;
public SceneFader fader;
public class MoneyUI : MonoBehaviour {
public Button[] levelButtons;
public Text moneyText;
void Start ()
{ // Update is called once per frame
int levelReached = void Update () {
PlayerPrefs.GetInt("levelReached", 1); moneyText.text = "₯" +
PlayerStats.Money.ToString();
for (int i = 0; i < levelButtons.Length; i++) }
{ }
if (i + 1 > levelReached) using UnityEngine;
using UnityEngine.EventSystems;
levelButtons[i].interactable = false;
} public class Node : MonoBehaviour {
}
public Color hoverColor;
public void Select (string levelName) public Color notEnoughMoneyColor;
{ public Vector3 positionOffset;
fader.FadeTo(levelName);
} [HideInInspector]
public GameObject turret;
[HideInInspector]
} public TurretBlueprint turretBlueprint;
[HideInInspector]
public bool isUpgraded = false;
using UnityEngine;
using UnityEngine.UI; private Renderer rend;
private Color startColor;
public class LivesUI : MonoBehaviour {
BuildManager buildManager;
public Text livesText;
void Start ()
// Update is called once per frame {

STI College Marikina 86


rend = GetComponent<Renderer>();
startColor = rend.material.color; //Get rid of the old turret
Destroy(turret);
buildManager = BuildManager.instance;
} //Build a new one
GameObject _turret =
public Vector3 GetBuildPosition () (GameObject)Instantiate(turretBlueprint.upgradedPrefab,
{ GetBuildPosition(), Quaternion.identity);
return transform.position + turret = _turret;
positionOffset;
} GameObject effect =
(GameObject)Instantiate(buildManager.buildEffect,
void OnMouseDown () GetBuildPosition(), Quaternion.identity);
{ Destroy(effect, 5f);
if
(EventSystem.current.IsPointerOverGameObject()) isUpgraded = true;
return;
Debug.Log("Turret upgraded!");
if (turret != null) }
{
public void SellTurret ()
buildManager.SelectNode(this); {
return; PlayerStats.Money +=
} turretBlueprint.GetSellAmount();

if (!buildManager.CanBuild) GameObject effect =


return; (GameObject)Instantiate(buildManager.sellEffect,
GetBuildPosition(), Quaternion.identity);
Destroy(effect, 5f);
BuildTurret(buildManager.GetTurretToBuild());
} Destroy(turret);
turretBlueprint = null;
void BuildTurret (TurretBlueprint blueprint) }
{
if (PlayerStats.Money < blueprint.cost) void OnMouseEnter ()
{ {
Debug.Log("Not enough money if
to build that!"); (EventSystem.current.IsPointerOverGameObject())
return; return;
}
if (!buildManager.CanBuild)
PlayerStats.Money -= blueprint.cost; return;

GameObject _turret = if (buildManager.HasMoney)


(GameObject)Instantiate(blueprint.prefab, GetBuildPosition(), {
Quaternion.identity); rend.material.color =
turret = _turret; hoverColor;
} else
turretBlueprint = blueprint; {
rend.material.color =
GameObject effect = notEnoughMoneyColor;
(GameObject)Instantiate(buildManager.buildEffect, }
GetBuildPosition(), Quaternion.identity);
Destroy(effect, 5f); }

Debug.Log("Turret build!"); void OnMouseExit ()


} {
rend.material.color = startColor;
public void UpgradeTurret () }
{
if (PlayerStats.Money < }
turretBlueprint.upgradeCost)
{
Debug.Log("Not enough money using UnityEngine;
to upgrade that!"); using UnityEngine.UI;
return;
} public class NodeUI : MonoBehaviour {

PlayerStats.Money -= public GameObject ui;


turretBlueprint.upgradeCost;

STI College Marikina 87


public Text upgradeCost; public void OnEnable()
public Button upgradeButton; {
m_OpenParameterId =
public Text sellAmount; Animator.StringToHash (k_OpenTransitionName);

private Node target; if (initiallyOpen == null)


return;
public void SetTarget (Node _target)
{ OpenPanel(initiallyOpen);
target = _target; }

transform.position = public void OpenPanel (Animator anim)


target.GetBuildPosition(); {
if (m_Open == anim)
if (!target.isUpgraded) return;
{
upgradeCost.text = "$" + anim.gameObject.SetActive(true);
target.turretBlueprint.upgradeCost; var newPreviouslySelected =
upgradeButton.interactable = EventSystem.current.currentSelectedGameObject;
true;
} else anim.transform.SetAsLastSibling();
{
upgradeCost.text = "DONE"; CloseCurrent();
upgradeButton.interactable =
false; m_PreviouslySelected =
} newPreviouslySelected;

sellAmount.text = "$" + m_Open = anim;


target.turretBlueprint.GetSellAmount(); m_Open.SetBool(m_OpenParameterId,
true);
ui.SetActive(true);
} GameObject go =
FindFirstEnabledSelectable(anim.gameObject);
public void Hide ()
{ SetSelected(go);
ui.SetActive(false); }
}
static GameObject FindFirstEnabledSelectable
public void Upgrade () (GameObject gameObject)
{ {
target.UpgradeTurret(); GameObject go = null;
BuildManager.instance.DeselectNode(); var selectables =
} gameObject.GetComponentsInChildren<Selectable> (true);
foreach (var selectable in selectables) {
public void Sell () if (selectable.IsActive () &&
{ selectable.IsInteractable ()) {
target.SellTurret(); go =
BuildManager.instance.DeselectNode(); selectable.gameObject;
} break;
}
} }
return go;
}
using UnityEngine;
using UnityEngine.UI; public void CloseCurrent()
using UnityEngine.EventSystems; {
using System.Collections; if (m_Open == null)
using System.Collections.Generic; return;

public class PanelManager : MonoBehaviour { m_Open.SetBool(m_OpenParameterId,


false);
public Animator initiallyOpen; SetSelected(m_PreviouslySelected);

private int m_OpenParameterId; StartCoroutine(DisablePanelDeleyed(m_Open));


private Animator m_Open; m_Open = null;
private GameObject m_PreviouslySelected; }

const string k_OpenTransitionName = "Open"; IEnumerator DisablePanelDeleyed(Animator anim)


const string k_ClosedStateName = "Closed"; {
bool closedStateReached = false;

STI College Marikina 88


bool wantToClose = true; sceneFader.FadeTo(menuSceneName);
while (!closedStateReached && }
wantToClose)
{ }
if (!anim.IsInTransition(0))
closedStateReached
= using UnityEngine;
anim.GetCurrentAnimatorStateInfo(0).IsName(k_ClosedState using UnityEngine.SceneManagement;
Name);
public class PauseMenu : MonoBehaviour
wantToClose = {
!anim.GetBool(m_OpenParameterId);
public GameObject ui;
yield return new public SceneFader sceneFader;
WaitForEndOfFrame(); public string menuSceneName = "MainMenu";
} public void PauseGame()
{
if (wantToClose) ui.SetActive(true);

anim.gameObject.SetActive(false); Time.timeScale = 0f;


} }

private void SetSelected(GameObject go) public void ResumeGame()


{ {
ui.SetActive(false);
EventSystem.current.SetSelectedGameObject(go); Time.timeScale = 1f;
} }
} public void Retry()
{

using UnityEngine; sceneFader.FadeTo(SceneManager.GetActiveScene(


using UnityEngine.SceneManagement; ).name);
public class Pause : MonoBehaviour }
{
public string menuSceneName = "MainMenu"; public void Menu()
public string pausemenu = "PauseMenu"; {
public SceneFader sceneFader;
sceneFader.FadeTo(menuSceneName);
public GameObject ui; }
public void selectPauseMenu ()
{ }
Debug.Log("Game Paused");
sceneFader.selectPauseMenu(pausemenu);
using System.Collections;
Toggle(); using System.Collections.Generic;
} using UnityEngine;
public void Toggle() using UnityEngine.AI;
{
ui.SetActive(!ui.activeSelf); public class PlayerMov : MonoBehaviour
{
if (ui.activeSelf) NavMeshAgent agent;
{ void Start()
Time.timeScale = 0f; {
} agent = GetComponent<NavMeshAgent>();
else
{ }
Time.timeScale = 1f;
}
} void Update()
{
public void Retry() if (Input.GetMouseButtonDown(0))
{ {
Toggle(); RaycastHit hit;
Ray ray =
sceneFader.FadeTo(SceneManager.GetActiveScene().name); Camera.main.ScreenPointToRay(Input.mousePosition);
} if (Physics.Raycast(ray, out hit, Mathf.Infinity))
{
public void Menu() agent.SetDestination(hit.point);
{ }
Toggle(); }

STI College Marikina 89


} Vector2 sizeDelta = originalSizeDelta +
} new Vector2 (offsetToOriginal.x, -offsetToOriginal.y);
sizeDelta = new Vector2 (
Mathf.Clamp (sizeDelta.x,
using UnityEngine; minSize.x, maxSize.x),
using System.Collections; Mathf.Clamp (sizeDelta.y,
minSize.y, maxSize.y)
public class PlayerStats : MonoBehaviour { );

public static int Money; panelRectTransform.sizeDelta =


public int startMoney = 400; sizeDelta;
}
public static int Lives; }
public int startLives = 20;

public static int Rounds; using System.Collections;


using System.Collections.Generic;
void Start () using UnityEngine;
{ using UnityEngine.UI;
Money = startMoney;
Lives = startLives; public class RoundsSurvived : MonoBehaviour {

Rounds = 0; public Text roundsText;


}
void OnEnable()
} {
StartCoroutine(AnimateText());
}
using UnityEngine;
using UnityEngine.UI; IEnumerator AnimateText ()
using UnityEngine.EventSystems; {
roundsText.text = "0";
public class ResizePanel : MonoBehaviour, int round = 0;
IPointerDownHandler, IDragHandler {
yield return new WaitForSeconds(.7f);
public Vector2 minSize = new Vector2 (100, 100);
public Vector2 maxSize = new Vector2 (400, 400); while (round < PlayerStats.Rounds)
{
private RectTransform panelRectTransform; round++;
private Vector2 originalLocalPointerPosition; roundsText.text =
private Vector2 originalSizeDelta; round.ToString();

void Awake () { yield return new


panelRectTransform = WaitForSeconds(.05f);
transform.parent.GetComponent<RectTransform> (); }
}
}
public void OnPointerDown (PointerEventData data)
{ }
originalSizeDelta =
panelRectTransform.sizeDelta;
using UnityEngine;
RectTransformUtility.ScreenPointToLocalPointInR using UnityEngine.UI;
ectangle (panelRectTransform, data.position, using UnityEngine.SceneManagement;
data.pressEventCamera, out originalLocalPointerPosition); using System.Collections;
} using System;

public void OnDrag (PointerEventData data) { public class SceneFader : MonoBehaviour {


if (panelRectTransform == null)
return; public Image img;
public AnimationCurve curve;
Vector2 localPointerPosition;
void Start ()
RectTransformUtility.ScreenPointToLocalPointInR {
ectangle (panelRectTransform, data.position, StartCoroutine(FadeIn());
data.pressEventCamera, out localPointerPosition); }
Vector3 offsetToOriginal =
localPointerPosition - originalLocalPointerPosition; public void FadeTo (string scene)
{
StartCoroutine(FadeOut(scene));

STI College Marikina 90


} mSprite.material = mCopy;
}
IEnumerator FadeIn () }
{
float t = 1f; void OnDisable ()
{
while (t > 0f) if (mCopy != null)
{ {
t -= Time.deltaTime; mSprite.material = mOriginal;
float a = curve.Evaluate(t); if (Application.isEditor)
img.color = new Color (0f, 0f, 0f,
a); UnityEngine.Object.DestroyImmediate(mCopy);
yield return 0; else
}
} UnityEngine.Object.Destroy(mCopy);
mCopy = null;
internal void selectPauseMenu(string pausemenu) }
{ mOriginal = null;
throw new NotImplementedException(); }
}
void Update ()
IEnumerator FadeOut(string scene) {
{ Material mat = (mCopy != null) ? mCopy :
float t = 0f; mOriginal;

while (t < 1f) if (mat != null)


{ {
t += Time.deltaTime; Texture tex =
float a = curve.Evaluate(t); mat.GetTexture("_DetailTex");
img.color = new Color(0f, 0f, 0f,
a); if (tex != null)
yield return 0; {
}
mat.SetTextureOffset("_DetailTex",
SceneManager.LoadScene(scene); scrollPerSecond * Time.time);
}
// TODO: It would be
} better to add support for MaterialBlocks on UIRenderer,
// because currently
only one Update() function's matrix can be active at a time.
using UnityEngine; // With material
using UnityEngine.UI; block properties, the batching would be correctly broken up
instead,
// and would work
[RequireComponent(typeof(Image))] with multiple widgets using this detail shader.
public class ScrollDetailTexture : MonoBehaviour }
{ }
public bool uniqueMaterial = false; }
public Vector2 scrollPerSecond = Vector2.zero; }

Matrix4x4 m_Matrix;
Material mCopy; using UnityEngine;
Material mOriginal;
Image mSprite; public class Shop : MonoBehaviour {
Material m_Mat;
public TurretBlueprint standardTurret;
void OnEnable () public TurretBlueprint missileLauncher;
{ public TurretBlueprint laserBeamer;
mSprite = GetComponent<Image>();
mOriginal = mSprite.material; BuildManager buildManager;

if (uniqueMaterial && mSprite.material void Start ()


!= null) {
{ buildManager = BuildManager.instance;
mCopy = new }
Material(mOriginal);
mCopy.name = "Copy of " + public void SelectStandardTurret ()
mOriginal.name; {
mCopy.hideFlags = Debug.Log("Standard Turret Selected");
HideFlags.DontSave;

STI College Marikina 91


buildManager.SelectTurretToBuild(standardTurret void Start ()
); {
} mTrans = transform;
mStart = mTrans.localRotation;
public void SelectMissileLauncher() }
{
Debug.Log("Missile Launcher Selected"); void Update ()
{
buildManager.SelectTurretToBuild(missileLaunche Vector3 pos = Input.mousePosition;
r);
} float halfWidth = Screen.width * 0.5f;
float halfHeight = Screen.height * 0.5f;
public void SelectLaserBeamer() float x = Mathf.Clamp((pos.x - halfWidth)
{ / halfWidth, -1f, 1f);
Debug.Log("Laser Beamer Selected"); float y = Mathf.Clamp((pos.y - halfHeight)
/ halfHeight, -1f, 1f);
buildManager.SelectTurretToBuild(laserBeamer); mRot = Vector2.Lerp(mRot, new
} Vector2(x, y), Time.deltaTime * 5f);

} mTrans.localRotation = mStart *
Quaternion.Euler(-mRot.y * range.y, mRot.x * range.x, 0f);
}
using System.Reflection.Emit; }
using UnityEngine;
using UnityEngine.UI;
using UnityEngine;
[RequireComponent(typeof(Text))] using System.Collections;
public class ShowSliderValue : MonoBehaviour
{ public class Turret : MonoBehaviour {
public void UpdateLabel (float value)
{ private Transform target;
Text lbl = GetComponent<Text>(); private Enemy targetEnemy;
if (lbl != null) private CompleteLevel currencyworth;
lbl.text = Mathf.RoundToInt
(value * 100) + "%";
}
}

using UnityEngine;
using UnityEngine.UI;
using System.Collections; [Header("General")]

public class Stats : MonoBehaviour public static float baserange = 15f;


{
public int startCurrecy = 0; public static float finalrange = baserange +
public static int Currency; CompleteLevel.Currencyworth;
public Text CurrencyText; [Header("Use Bullets (default)")]
public GameObject bulletPrefab;
void Start() public static float basefireRate = 1f;
{ public static float finalfireRate = basefireRate +
Currency = startCurrecy; CompleteLevel.Currencyworth;
} private float fireCountdown = 0f;
void Update()
{ [Header("Use Laser")]
CurrencyText.text = "" + Stats.Currency.ToString(); public bool useLaser = false;
}
} public static int basedamageOverTime = 30;
public static int finaldamageOverTime =
basedamageOverTime + CompleteLevel.Currencyworth;
using UnityEngine; public float slowAmount = .5f;

public class TiltWindow : MonoBehaviour public LineRenderer lineRenderer;


{ public ParticleSystem impactEffect;
public Vector2 range = new Vector2(5f, 3f); public Light impactLight;

Transform mTrans; [Header("Unity Setup Fields")]


Quaternion mStart;
Vector2 mRot = Vector2.zero; public string enemyTag = "Enemy";

STI College Marikina 92


public Transform partToRotate; LockOnTarget();
public float turnSpeed = 10f;
if (useLaser)
public Transform firePoint; {
Laser();
public CompleteLevel Currencyworth { get => } else
currencyworth; set => currencyworth = value; } {
if (fireCountdown <= 0f)
// Use this for initialization {
void Start () { Shoot();
InvokeRepeating("UpdateTarget", 0f, fireCountdown = 1f /
0.5f); basefireRate;
} }

void UpdateTarget () fireCountdown -=


{ Time.deltaTime;
GameObject[] enemies = }
GameObject.FindGameObjectsWithTag(enemyTag);
float shortestDistance = Mathf.Infinity; }
GameObject nearestEnemy = null;
foreach (GameObject enemy in enemies) void LockOnTarget ()
{ {
float distanceToEnemy = Vector3 dir = target.position -
Vector3.Distance(transform.position, transform.position;
enemy.transform.position); Quaternion lookRotation =
if (distanceToEnemy < Quaternion.LookRotation(dir);
shortestDistance) Vector3 rotation =
{ Quaternion.Lerp(partToRotate.rotation, lookRotation,
shortestDistance = Time.deltaTime * turnSpeed).eulerAngles;
distanceToEnemy; partToRotate.rotation =
nearestEnemy = Quaternion.Euler(0f, rotation.y, 0f);
enemy; }
}
} void Laser ()
{
if (nearestEnemy != null &&
shortestDistance <= baserange) targetEnemy.TakeDamage(basedamageOverTime *
{ Time.deltaTime);
target = targetEnemy.Slow(slowAmount);
nearestEnemy.transform;
targetEnemy = if (!lineRenderer.enabled)
nearestEnemy.GetComponent<Enemy>(); {
} else lineRenderer.enabled = true;
{ impactEffect.Play();
target = null; impactLight.enabled = true;
} }

} lineRenderer.SetPosition(0,
firePoint.position);
// Update is called once per frame lineRenderer.SetPosition(1,
void Update () { target.position);
if (target == null)
{ Vector3 dir = firePoint.position -
if (useLaser) target.position;
{
if impactEffect.transform.position =
(lineRenderer.enabled) target.position + dir.normalized;
{
impactEffect.transform.rotation =
lineRenderer.enabled = false; Quaternion.LookRotation(dir);
}
impactEffect.Stop();
void Shoot ()
impactLight.enabled = false; {
} GameObject bulletGO =
} (GameObject)Instantiate(bulletPrefab, firePoint.position,
firePoint.rotation);
return; Bullet bullet =
} bulletGO.GetComponent<Bullet>();

STI College Marikina 93


public class WaveSpawner : MonoBehaviour {
if (bullet != null)
bullet.Seek(target); public static int EnemiesAlive = 0;
}
public Wave[] waves;
void OnDrawGizmosSelected ()
{ public Transform spawnPoint01;
Gizmos.color = Color.red;
public float timeBetweenWaves = 5f;
Gizmos.DrawWireSphere(transform.position, private float countdown = 2f;
baserange);
} public Text waveCountdownText;
}
public GameManager gameManager;

using UnityEngine; private int waveIndex = 0;


using System.Collections;
void Update ()
[System.Serializable] {
public class TurretBlueprint { if (EnemiesAlive > 0)
{
public GameObject prefab; return;
public int cost; }

public GameObject upgradedPrefab; if (waveIndex == waves.Length)


public int upgradeCost; {
gameManager.WinLevel();
public int GetSellAmount () this.enabled = false;
{ }
return cost / 2;
} if (countdown <= 0f)
{
} StartCoroutine(SpawnWave());
using UnityEngine; countdown =
using UnityEngine.UI; timeBetweenWaves;
using System.Collections; return;
}
public class TurretStats : MonoBehaviour
{ countdown -= Time.deltaTime;
public Text rangeText;
public Text fireRateText; countdown = Mathf.Clamp(countdown,
public Text damageOverTimeText; 0f, Mathf.Infinity);

waveCountdownText.text =
void Update() string.Format("{0:00.00}", countdown);
{ }
rangeText.text = "" + Turret.finalrange.ToString();
fireRateText.text = "" + Turret.finalfireRate.ToString(); IEnumerator SpawnWave ()
damageOverTimeText.text = "" + {
Turret.finaldamageOverTime.ToString(); PlayerStats.Rounds++;
}
} Wave wave = waves[waveIndex];

EnemiesAlive = wave.count;
using UnityEngine;
for (int i = 0; i < wave.count; i++)
[System.Serializable] {
public class Wave { SpawnEnemy(wave.enemy);
yield return new
public GameObject enemy; WaitForSeconds(1f / wave.rate);
public int count; }
public float rate;
waveIndex++;
} }

void SpawnEnemy (GameObject enemy)


using UnityEngine; {
using System.Collections; Instantiate(enemy,
using UnityEngine.UI; spawnPoint01.position, spawnPoint01.rotation);
}

STI College Marikina 94


}

using UnityEngine;

public class Waypoints : MonoBehaviour {

public static Transform[] points;

void Awake ()
{
points = new
Transform[transform.childCount];
for (int i = 0; i <
points.Length; i++)
{
points[i] =
transform.GetChild(i);
}
}

STI College Marikina 95

You might also like