<file_sep>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class UpdateScore : MonoBehaviour {
	public int score;
	public Text text;
	
	// Use this for initialization
	void Start () {
		score= 0;
		score = ZombieController.zombieKillCount;
		
	}
	
	// Update is called once per frame
	void Update () {
		
		
		text.text = "Score: "+ score;
		
	}
}
<file_sep>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class PauseScript : MonoBehaviour {

	public Button exitButton;
	public Text text;

	
    public void PauseGame()
    {
        if(Time.timeScale == 1){
			Time.timeScale = 0;
			text.color = new Color (255,0,0,255);
			GetComponent<PlayerController>().enabled = false;
			GetComponent<ZombieController>().enabled = false;
			GetComponent<BulletControl>().enabled = false;
			
		}
		else if(Time.timeScale == 0){
			Time.timeScale = 1;
			text.color = new Color(0,0,0,0);
			GetComponent<PlayerController>().enabled = true;
			GetComponent<ZombieController>().enabled = true;
			GetComponent<BulletControl>().enabled = true;
			
		}
    } 
	
	public void leaveButtonPause(){
		Time.timeScale = 1;
		SceneManager.LoadScene("planetSelect");
		
	}
}<file_sep>﻿
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ZombieController : MonoBehaviour {
	
	public Rigidbody2D sprite; 
	public Sprite zombieSprite;
	public GameObject zombieTemplate;
	
	//Variables to check if the zombie is on the bullet
	public bool onBullet;
	public LayerMask whatIsBullet;
	public float bulletCheckRadius;
	
	public List<GameObject> zombieList  = new List<GameObject>();
	public List<int>zombieEraseList = new List<int>();
	
	public int zombieCount=0;
	public static int zombieKillCount = 0;
	public int zombieSpawnCount = 2;
	public float zombieSpeed = 0.2f;
	
	//Text that updates the Player's score
	public Text text;
	

	public int getScore(){
		return zombieKillCount;
	}
	
	//FUnction to lay the framework of the zombie
	public void spawnZombie(){
		GameObject zombie = Instantiate(zombieTemplate);
		zombie.transform.parent = GameObject.Find("Main Camera").transform;
		zombie.transform.position = new Vector3(Random.Range(-207,212), Random.Range(-164,168), 1);
		zombie.AddComponent<SpriteRenderer>();
		zombie.AddComponent<Rigidbody2D>();
		zombie.GetComponent<Rigidbody2D>().isKinematic = true;
		zombie.AddComponent<BoxCollider2D>();
		zombie.GetComponent<BoxCollider2D>().size = new Vector2(5,5);
		zombie.layer = 8;
		zombie.transform.localScale = new Vector3(sprite.transform.localScale.x,sprite.transform.localScale.y,1);
		zombie.GetComponent<SpriteRenderer>().sprite = zombieSprite;
		zombieList.Add(zombie);//Adds zombie to an array list instead of a public varibale so multiple zombies can be manipulated
		zombieCount++;
		

	}
	//THis function checks all the active zombies
	public void checkDeadZombies(){
		//This variableness goes through all the zombies in the array list and makes them chase the player
		for(int i = 0; i < zombieList.Count; i++){
			onBullet = Physics2D.OverlapCircle(zombieList[i].transform.position, bulletCheckRadius, whatIsBullet); //checks collision between zombies and pullets
			zombieList[i].transform.position = Vector3.MoveTowards(zombieList[i].transform.position, sprite.position, zombieSpeed);//chases player
			//If there is a collision between bullets and zombies it deletes it from the array list
			if(onBullet){
				//zombieEraseList.Add(i);
				Destroy(zombieList[i]);//Come from the foreach loop
				zombieList.Remove(zombieList[i]);//Come from foreach loop
				zombieCount--;
				zombieKillCount++;
				
			}
			
		
		}
		/*
		foreach(int i in zombieEraseList){
			
			Destroy(zombieList[i]);
			zombieList.Remove(zombieList[i]);
			
			
		}
		zombieEraseList = new List<int>();
	
		*/
	}
	
	public void updateSpawnSpeed(){
		if((zombieKillCount % 8 == 0)){
			
				zombieSpawnCount += 2;
				zombieSpeed += 0.1f;
			
			}
	}
	
	// Use this for initialization
	void Start () {
		zombieTemplate = new GameObject();
		spawnZombie();
		spawnZombie();
		zombieKillCount = 0;
		
		
	}
	
	
	// Update is called once per frame
	void Update () {
		text.text = "Score: " + zombieKillCount;
		checkDeadZombies();
		if(zombieCount == 0){
			//Adds difficulty curve
			updateSpawnSpeed();
			for(int i = 0; i < zombieSpawnCount; i++){
				spawnZombie();
			}
		}
		
	}
}
<file_sep>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class PlayerController : MonoBehaviour {
	public Rigidbody2D sprite;
	public Button up;
	public Button down;
	public Button left;
	public Button right;
	
	public bool onZombie;
	public LayerMask whatIsZombie;
	public float zombieCheckRadius;
	
	//Boolean values to check what direction the main character is facing
	public static bool isRight;
	public static bool isLeft;
	
	public static bool isFacingRight;
	public static bool isFacingLeft;
	
	public static bool isDown;
	public static bool isUp;
	
	public static bool upRight;
	public static bool upLeft;
	public static bool downRight;
	public static bool downLeft;
	
	public Sprite bulletSprite;
	
	public void goLeft(){
		//coditional to make sure the character is facing the opposite direction, if passed, it goes in the opposite direction and flips the sprite to match direction
		if(isFacingRight == true && isFacingLeft == false){
			sprite.GetComponent<Transform>().localScale = new Vector3( sprite.GetComponent<Transform>().localScale.x * -1, sprite.GetComponent<Transform>().localScale.y, sprite.GetComponent<Transform>().localScale.z );
			isFacingLeft = true;
			isFacingRight = false;
		}
		isRight = false;
		isLeft = true;
		isUp = false;
		isDown = false;
		
		upRight = false;
		upLeft = false;
		downRight = false;
		downLeft = false;
		sprite.velocity = new Vector2(-30, 0);
	}
	public void goRight(){
		//coditional to make sure the character is facing the opposite direction, if passed, it goes in the opposite direction and flips the sprite to match direction
		if(isFacingLeft == true && isFacingRight == false){
			sprite.GetComponent<Transform>().localScale = new Vector3( sprite.GetComponent<Transform>().localScale.x * -1, sprite.GetComponent<Transform>().localScale.y, sprite.GetComponent<Transform>().localScale.z );	
			isFacingRight = true;
			isFacingLeft = false;
		}
		isRight = true;
		isLeft = false;
		isUp = false;
		isDown = false;
		
		upRight = false;
		upLeft = false;
		downRight = false;
		downLeft = false;
		sprite.velocity = new Vector2(30, 0);
	}
	public void goUp(){
		isUp = true;
		isDown = false;
		isLeft = false;
		isRight = false;
		
		upRight = false;
		upLeft = false;
		downRight = false;
		downLeft = false;
		sprite.velocity = new Vector2(0, 30);
	}
	public void goDown(){
		isUp = false;
		isDown = true;
		isLeft = false;
		isRight = false;
		
		upRight = false;
		upLeft = false;
		downRight = false;
		downLeft = false;
		sprite.velocity = new Vector2(0, -30);
	}
	
	public void goUpRight(){
		
		if(isFacingLeft == true && isFacingRight == false){
			sprite.GetComponent<Transform>().localScale = new Vector3( sprite.GetComponent<Transform>().localScale.x * -1, sprite.GetComponent<Transform>().localScale.y, sprite.GetComponent<Transform>().localScale.z );	
			isFacingRight = true;
			isFacingLeft = false;
		}
		isRight = false;
		isLeft = false;
		isUp = false;
		isDown = false;
		
		upRight = true;
		upLeft = false;
		downRight = false;
		downLeft = false;
		sprite.velocity = new Vector2(21.2f, 21.2f);
		
	}
	
	public void goUpLeft(){
		
		if(isFacingLeft == false && isFacingRight == true){
			sprite.GetComponent<Transform>().localScale = new Vector3( sprite.GetComponent<Transform>().localScale.x * -1, sprite.GetComponent<Transform>().localScale.y, sprite.GetComponent<Transform>().localScale.z );	
			isFacingRight = false;
			isFacingLeft = true;
		}
		isRight = false;
		isLeft = false;
		isUp = false;
		isDown = false;
		
		upRight = false;
		upLeft = true;
		downRight = false;
		downLeft = false;
		sprite.velocity = new Vector2(-21.2f, 21.2f);
		
	}
	
	public void goDownLeft(){
		
		if(isFacingLeft == false && isFacingRight == true){
			sprite.GetComponent<Transform>().localScale = new Vector3( sprite.GetComponent<Transform>().localScale.x * -1, sprite.GetComponent<Transform>().localScale.y, sprite.GetComponent<Transform>().localScale.z );	
			isFacingRight = false;
			isFacingLeft = true;
		}
		isRight = false;
		isLeft = false;
		isUp = false;
		isDown = false;
		
		upRight = false;
		upLeft = false;
		downRight = false;
		downLeft = true;
		sprite.velocity = new Vector2(-21.2f, -21.2f);
		
	}
	
	public void goDownRight(){
		
		if(isFacingLeft == true && isFacingRight == false){
			sprite.GetComponent<Transform>().localScale = new Vector3( sprite.GetComponent<Transform>().localScale.x * -1, sprite.GetComponent<Transform>().localScale.y, sprite.GetComponent<Transform>().localScale.z );	
			isFacingRight = true;
			isFacingLeft = false;
		}
		isRight = false;
		isLeft = false;
		isUp = false;
		isDown = false;
		
		upRight = false;
		upLeft = false;
		downRight = true;
		downLeft = false;
		sprite.velocity = new Vector2(21.2f, -21.2f);
		
	}
	
	
	// Use this for initialization
	void Start () {
		isRight = false;
		isLeft = true;
		isDown = false;
		isUp = false;
		
		isFacingLeft = true;
		isFacingRight = false;
		
		upRight = false;
		upLeft = false;
		downRight = false;
		downLeft = false;
	}
	
	// Update is called once per frame
	void Update () {
		
		//Check if player is on the zombie by a certain radius (zombieCheckRadius), from a rigidbody (sprite) for certain layers (whatIsZombie)
		onZombie = Physics2D.OverlapCircle(sprite.transform.position, zombieCheckRadius, whatIsZombie);
		if(onZombie){
			SceneManager.LoadScene ("Lose");
		}
		
	}
}
<file_sep>using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class BulletControl : MonoBehaviour {
	
	public  Rigidbody2D sprite;
	public Sprite bulletSprite;
	
	public bool pistolShotBullet;
	public bool pistolBulletPending;
	
	public GameObject bullet;
	
	//This is the function that repsonds to the shoot button, it makes the boolean true to help succed to if statement in update
	public void pistolShoot(){
		pistolShotBullet = true;
	}
	
	/*public void shootBullet(){
		
		
			GameObject bullet;
			bullet = new GameObject();
			bullet.AddComponent<SpriteRenderer>();
			bullet.AddComponent<Rigidbody2D>();
			bullet.AddComponent<BoxCollider2D>();
			bullet.GetComponent<Rigidbody2D>().bodyType = RigidbodyType2D.Kinematic;
			bullet.transform.localScale = new Vector3(6,6,1);
			Vector2 tempColl = new Vector2(1,1);
			bullet.GetComponent<BoxCollider2D>().size = tempColl;
			Vector3 temp = new Vector3(sprite.position.x,sprite.position.y,0);
			bullet.transform.position = temp;
			bullet.GetComponent<SpriteRenderer>().sprite = bulletSprite;
			if(PlayerController.isRight == true && PlayerController.isLeft == false){
				bullet.GetComponent<Rigidbody2D>().velocity = new Vector2(230, bullet.GetComponent<Rigidbody2D>().velocity.y);
				
			}
			else if(PlayerController.isRight == false && PlayerController.isLeft == true){
				bullet.GetComponent<Rigidbody2D>().velocity = new Vector2(-230, bullet.GetComponent<Rigidbody2D>().velocity.y);
				
			}
			
		
		
		
	}*/
	
	void Start(){
		pistolShotBullet = false;
		pistolBulletPending = false;
		bullet = new GameObject();
	}
	
	void Update(){
		//This part of the if statement checks if a the pistolShot() method is active and if there is any pistol bullets in the game. REMEBER: Pistols can only be shot after all other pistol bullets are gone
		if(pistolShotBullet == true && pistolBulletPending == false){
			
			
			
			//This part of the code creates the bullet object
			bullet = new GameObject();
			pistolBulletPending = true;
			bullet.AddComponent<SpriteRenderer>();
			bullet.AddComponent<Rigidbody2D>();
			bullet.AddComponent<BoxCollider2D>();
			bullet.transform.parent = GameObject.Find("Main Camera").transform;
			bullet.GetComponent<Rigidbody2D>().bodyType = RigidbodyType2D.Kinematic;
			bullet.layer = 9;
			bullet.transform.localScale = new Vector3(6,6,1);
			Vector2 tempColl = new Vector2(6,5);
			bullet.GetComponent<BoxCollider2D>().size = tempColl;
			Vector3 temp = new Vector3(sprite.position.x,sprite.position.y,0);
			bullet.transform.position = temp;
			bullet.GetComponent<SpriteRenderer>().sprite = bulletSprite;
			
			//This part determines which direction to shoot the bullet based on the sprite from PLayerController and what direction he is facing
			if(PlayerController.isRight == true){
				bullet.GetComponent<Rigidbody2D>().velocity = new Vector2(500,0);
				
			}
			else if(PlayerController.isLeft == true){
				bullet.GetComponent<Rigidbody2D>().velocity = new Vector2(-500,0);
				
			}
			else if(PlayerController.isDown == true){
				bullet.GetComponent<Rigidbody2D>().velocity = new Vector2(0,-500);
			}
			else if(PlayerController.isUp == true){
				bullet.GetComponent<Rigidbody2D>().velocity = new Vector2(0,500);
			}
			else if(PlayerController.upRight == true){
				bullet.GetComponent<Rigidbody2D>().velocity = new Vector2(354,354);
			}
			else if(PlayerController.upLeft == true){
				bullet.GetComponent<Rigidbody2D>().velocity = new Vector2(-354,354);
			}
			else if(PlayerController.downLeft == true){
				bullet.GetComponent<Rigidbody2D>().velocity = new Vector2(-354,-354);
			}
			else if(PlayerController.downRight == true){
				bullet.GetComponent<Rigidbody2D>().velocity = new Vector2(354,-354);
			}
		
			
		}
		//
		if(pistolBulletPending == true &&(bullet.GetComponent<Rigidbody2D>().position.x < 20 || bullet.GetComponent<Rigidbody2D>().position.x > 465)){
				Destroy(bullet.GetComponent<Rigidbody2D>());
				Destroy(bullet.GetComponent<SpriteRenderer>());
				Destroy(bullet.GetComponent<BoxCollider2D>());
				pistolBulletPending = false;
				pistolShotBullet = false;
		}
		else if(pistolBulletPending == true &&(bullet.GetComponent<Rigidbody2D>().position.y < -4 || bullet.GetComponent<Rigidbody2D>().position.y > 356)){
				Destroy(bullet.GetComponent<Rigidbody2D>());
				Destroy(bullet.GetComponent<SpriteRenderer>());
				Destroy(bullet.GetComponent<BoxCollider2D>());
				pistolBulletPending = false;
				pistolShotBullet = false;
		}
		
 
		
	}

}