Level The Town

 Production Time: 09/2017 - 12/2017

Game No Longer Available on Google Play Store


I was both programmer and game lead for this game. Level The Town was developed over three months (September 2017 - December 2017) in Unity. At the time I had never developed for mobile, and so this was a massive learning experience. The game was developed in Unity, and made to be available for Android.




Level The Town was meant to be a throwback to 80's arcade shooters/ action games, the two largest inspirations being Space Invaders and Rampage.

My tasks as programmer were:
-Player UI
-Basic Health/ Game Over System
-Enemy AI
-Player Controls
-Score System
-Game Looping
-Currency and a store (unfinished in final build)



Camera Code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraMovement : MonoBehaviour
{
public float cameraStop = 1.0f;
public Transform playerToFollow;
public Transform Firstwall;
public Transform Lastwall;
void Update()
{
var min = Firstwall.position.x + cameraStop;
var max = Lastwall.position.x - cameraStop;
// if players position > min and player position < max
if (playerToFollow.position.x > min && playerToFollow.position.x < max)
{
// change camera's position = players position.x height.y zoom.z
transform.position = new Vector3(playerToFollow.position.x, playerToFollow.position.y - 4, -33);
}
}
}
view raw LTTCamera hosted with ❤ by GitHub

Tank Boss Code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TankBoss : MonoBehaviour {
public Slider enemyHealthBar;
public float maxDistance = 4.0f;
public float speed = 10.0f;
Transform player;
Vector2 currentPosition = new Vector2();
public float enemyMaxHealth;
float currentHealth;
public GameObject alien;
public GameObject enemyLaser1;
public GameObject enemyLaser2;
public GameObject enemyLaser3;
public GameObject frontGun;
public GameObject backGun;
public Transform tank1fire;
public Transform tank2fire;
public Transform tank3fire;
public Transform tank4fire;
float time = 1.25f;
bool chooseGun1 = true;
void Start()
{
currentHealth = enemyMaxHealth;
enemyHealthBar.value = CalculatedHealth();
}
void Update()
{
player = GameObject.FindGameObjectWithTag("Player").transform;
currentPosition.x = transform.position.x;
if (player.position.x <= currentPosition.x + maxDistance && player.position.x >= currentPosition.x - (maxDistance))
{
transform.position += transform.right * speed * Time.deltaTime;
if (time >= 0)
{
time -= Time.deltaTime;
return;
}
else
{
Instantiate(enemyLaser3, tank4fire.position, tank4fire.rotation);
time = 0.75f;
}
}
else if (player.position.x >= currentPosition.x + maxDistance)
{
Vector2 newScale = transform.localScale;
newScale.x = -1;
transform.localScale = newScale;
transform.position += transform.right * speed * Time.deltaTime;
if (time >= 0)
{
time -= Time.deltaTime;
return;
}
else
{
transform.position = transform.position;
Instantiate(enemyLaser2, tank1fire.position, tank1fire.rotation);
shootSmallGun();
time = 0.75f;
}
}
else if (player.position.x <= currentPosition.x - maxDistance)
{
Vector2 newScale = transform.localScale;
newScale.x = 1;
transform.localScale = newScale;
transform.position += transform.right * -speed * Time.deltaTime;
if (time >= 0)
{
time -= Time.deltaTime;
return;
}
else
{
transform.position = transform.position;
Instantiate(enemyLaser1, tank1fire.position, tank1fire.rotation);
shootSmallGun();
time = 0.75f;
}
}
}
public void damageEnemy(float damage)
{
enemyHealthBar.value = CalculatedHealth();
currentHealth -= damage;
if (currentHealth <= 0) killEnemy();
}
void killEnemy()
{
enemyHealthBar.gameObject.SetActive(false);
alien.SetActive(true);
Destroy(gameObject);
}
float CalculatedHealth()
{
return currentHealth / enemyMaxHealth;
}
void shootSmallGun()
{
if (time >= 0)
{
time -= Time.deltaTime;
return;
}
else
{
if (chooseGun1 == true)
{
Instantiate(enemyLaser1, tank2fire.position, tank2fire.rotation);
chooseGun1 = false;
}
else if (chooseGun1 == false)
{
Instantiate(enemyLaser1, tank3fire.position, tank2fire.rotation);
chooseGun1 = true;
}
}
}
}
view raw LTTBoss hosted with ❤ by GitHub


I was satisfied with the gameplay loop. Having the player move within the confines of the level against basic UI keeps the game moving fast. The boss could be more challenging, but overall I am okay with how it came to be.
I would have liked the store to be finished, and one more world that was similar to the first world. For a game made by 3 people in 3 and a half months, I am satisfied with what we created.



Button Code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class leftButton : MonoBehaviour {
private bool moveLeft;
private bool moveRight;
private float forwardSpeed = 100;
private Rigidbody2D playerRigid;
void Update()
{
playerRigid = GetComponent<Rigidbody2D>();
if (moveLeft && !moveRight)
playerRigid.AddForce(Vector2.right * -forwardSpeed);
if (moveRight && !moveLeft)
playerRigid.AddForce(Vector2.right * forwardSpeed);
}
public void MoveMeLeft()
{
moveLeft = true;
}
public void StopMeLeft()
{
moveLeft = false;
}
public void MoveMeRight()
{
moveRight = true;
}
public void StopMeRight()
{
moveRight = false;
}
}
view raw LTTTouchButton hosted with ❤ by GitHub

Building Code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class buildingBreak : MonoBehaviour {
public GameObject buildingA;
public GameObject buildingB;
public GameObject buildingC;
public GameObject buildingD;
public float buildingMaxHealth;
float currentHealth;
float hits = 0;
// Use this for initialization
void Start () {
buildingA.SetActive(true);
buildingB.SetActive(false);
buildingC.SetActive(false);
buildingD.SetActive(false);
currentHealth = buildingMaxHealth; currentHealth = buildingMaxHealth;
}
public void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "playershot")
{
hits++;
Destroy(other.gameObject);
}
}
public void Update()
{
if (hits ==2 || hits == 3)
{
buildingA.SetActive(false);
buildingB.SetActive(true);
}
if (hits == 4 || hits == 5)
{
buildingB.SetActive(false);
buildingC.SetActive(true);
}
if (hits >= 6)
{
GetComponent<BoxCollider2D>().enabled = false;
buildingC.SetActive(false);
buildingD.SetActive(true);
}
}
public void damagebuilding(float damage)
{
currentHealth -= damage;
if (currentHealth <= 0) destroyBuilding();
}
void destroyBuilding()
{
Destroy(gameObject);
}
}
view raw LTTBuilding hosted with ❤ by GitHub