<repo_name>TeamNavdeep/LetsBrawl<file_sep>/2dFinal GIT/Assets/Scripts/Main/TestHealth.cs
﻿using UnityEngine;
using System.Collections;

public class TestHealth : MonoBehaviour {

	private float health;
	public GameObject healthbar;
	private GameObject healthbar2;
	private bool isAlive;

	// Use this for initialization
	void Start () {
		print(gamestart.healthPower);
		health = gamestart.healthPower;
		isAlive = true;
		healthbar2 = (GameObject)Instantiate (healthbar, transform.position, Quaternion.identity);
	}
	
	// Update is called once per frame
	void Update () {
		if (health <= 0) {
			isAlive =false;
			Destroy(healthbar);
		}
		healthbar2.transform.localScale = new Vector3 (health/100, 0.05f, 1);
		healthbar2.transform.position = new Vector3(this.transform.position.x, this.transform.position.y+ 2.0f, this.transform.position.z);

        //For Testing
        if (Input.GetKeyDown(KeyCode.F5))
        {
            health -= 20;
        }

		if (!Network.isServer && !Network.isClient){
			Destroy(healthbar);
		}
	}
	public bool getAliveStatus(){
		return isAlive;
	}

    public void setAliveStatus(bool status)
    {
        isAlive = status;
    }

	void OnCollisionEnter(Collision col){
		if (col.gameObject.tag == "Projectile") {
			health -= 10.0f;
		}
	}
}
<file_sep>/2dFinal GIT/Assets/Scripts/Main/PlayerController.cs
﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;


public class PlayerController : MonoBehaviour {

	public GameObject player;

	//buttons
	public GameObject leftBtn,rightBtn,jumpBtn, shootBtn, gunBtn;

	//projectiles
	public GameObject pistolprojectile;

	private int slotNum;

	//movespeed
	private Vector3 movement = Vector3.forward * 0.1f;
	private WeaponManager wepManage;

	//shooting variables
	private float timer = 0f;
	private float limit;
	private bool canshoot = false;
	private float speed = 10f;

	//jump and ground check
	public static bool isGrounded;
	public static bool doubleJump;
	public bool checkWalking;
	public bool checkJump;
	public bool checkDoubleJump;

	private bool isleft = false;
	private float xoffset = 0.7f;

	//multi touch support
	public static Touch[] touches;
	private int fingertouch= 0;
	//animation
	private Animator anim;
	private NetworkView netView;

    //Sound variables
    public AudioClip hgSound;
    public AudioClip arSound;
    public AudioClip sgSound;

	void shoot(){
		if (isleft) {
			xoffset = -0.7f;
		} else {
			xoffset = 0.7f;
		}
		Vector3 bulletspawnpos = new Vector3 (
			player.transform.position.x + xoffset,
			player.transform.position.y + 0.7f,
			player.transform.position.z
			);
		GameObject bullet = 
			(GameObject) Network.Instantiate(pistolprojectile, bulletspawnpos, player.transform.rotation, 0);
	}

	void Start () 
	{
		anim = this.GetComponent<Animator> ();
		netView = this.GetComponent<NetworkView> ();
		leftBtn = GameObject.Find ("Left_Btn");
		rightBtn = GameObject.Find ("Right_Btn");
		jumpBtn = GameObject.Find ("Jump_Btn");
		shootBtn = GameObject.Find ("Shoot_Btn");
		gunBtn = GameObject.Find ("Gun_Btn");
		wepManage = GetComponent<WeaponManager> ();
	}
	
	void Update () 
	{
		timer += Time.deltaTime;
		switch (wepManage.GetSlotNum()) {
		case 0:
			limit = 1.0f - gamestart.fireRate;
			break;
		case 1:
			limit = 1.5f - gamestart.fireRate;
			break;
		case 2:
			limit = 0.3f - gamestart.fireRate;
			break;
		case 5:
			limit = 1.0f - gamestart.fireRate;
			break;
		}
		if (timer >= limit) {
			canshoot = true;
		}
		// for single touch use this code 
		//Input.GetTouch (0).phase == TouchPhase.Began
		//for touch and hold 
		//Input.GetTouch (0).phase != TouchPhase.Ended && Input.GetTouch (0).phase != TouchPhase.Canceled
		// to check if ray cast is hitting an object via touch
		// if ( Physics.Raycast(ray, out hit) && hit.transform.gameObject == GAMEOBJECT)
		if (netView.isMine){

			if (Input.touchCount > 0 ) 
			{
				foreach(Touch t in Input.touches)
				{
					Ray ray = Camera.main.ScreenPointToRay( t.position );
					RaycastHit hit;
					if(t.phase != TouchPhase.Ended && t.phase != TouchPhase.Canceled)
					{
						if ( Physics.Raycast(ray, out hit) && hit.transform.gameObject == leftBtn)
						{
							isleft = true;
							//Debug.Log("CLICK LEFT");
							anim.SetBool("Moving", true);
							checkWalking = true;
							player.transform.rotation = Quaternion.Euler(0.0f, 270.0f, 0.0f);
							player.transform.Translate(movement);
							
						}
						else if ( Physics.Raycast(ray, out hit) && hit.transform.gameObject == rightBtn)
						{
							isleft = false;
							//Debug.Log("CLICK RIGHT");
							anim.SetBool("Moving", true);
							checkWalking = true;
							player.transform.rotation = Quaternion.Euler(0.0f, -270.0f, 0.0f);
							player.transform.Translate(movement);
						}

                        //For Testing - START -
                        if (Input.GetKeyDown(KeyCode.F8))
                        {
                            {
                                anim.SetTrigger("Fire");
                                Debug.Log("SHOOTING");
                                if (wepManage.GetSlotNum() != 5)
                                {
                                    shoot();
                                    switch (wepManage.GetSlotNum())
                                    {
                                        case 0:
                                            audio.PlayOneShot(hgSound);
                                            break;
                                        case 1:
                                            audio.PlayOneShot(arSound);
                                            break;
                                        case 2:
                                            audio.PlayOneShot(sgSound);
                                            break;
                                    }
                                }
                                canshoot = false;
                                timer = 0.0f;
                            }
                        }

                        //For Testing - END -

						if (Physics.Raycast(ray, out hit) && hit.transform.gameObject == shootBtn)
						{

							if(canshoot == true){
								anim.SetTrigger("Fire");
								Debug.Log("SHOOTING");
								if(wepManage.GetSlotNum() != 5){
									shoot ();
                                    switch (wepManage.GetSlotNum())
                                    {
                                        case 0:
                                            audio.PlayOneShot(hgSound);
                                            break;
                                        case 1:
                                            audio.PlayOneShot(arSound);
                                            break;
                                        case 2:
                                            audio.PlayOneShot(sgSound);
                                            break;
                                    }
								}
								canshoot = false;
								timer = 0.0f;
							}
						}
					}
					else
					{
						anim.SetBool("Moving", false);
						checkWalking = false;
					}
					if(t.phase == TouchPhase.Began)
					{
						if (Physics.Raycast(ray, out hit) && hit.transform.gameObject == gunBtn)
						{
							slotNum++;
							if(slotNum > 2)
							{
								slotNum = 0;
							}
							wepManage.SwitchWeapon(slotNum);
							
							switch(wepManage.GetSlotNum())
								{
								case  0:
									wepManage.SwitchWeapon(0);
									break;
								case  1:
									wepManage.SwitchWeapon(1);
									break;
								case  2:
									wepManage.SwitchWeapon(2);
									break;
								}


							
						}

						if (Physics.Raycast(ray, out hit) && hit.transform.gameObject == jumpBtn && isGrounded)
						{
							anim.SetTrigger("Jump");
							checkJump = true;
							isGrounded = false;
							//Debug.Log("CLICK JUMP");
							player.rigidbody.AddForce(new Vector2(0,1000f));
							
						}
						else if(Physics.Raycast(ray, out hit) && hit.transform.gameObject == jumpBtn && !isGrounded && doubleJump)
						{
							anim.SetTrigger("Double Jump");
							checkDoubleJump = true;
							player.rigidbody.AddForce(new Vector2(0,750f));
							doubleJump=false;
						}
					}
				}
			}
		}
		syncAnimation ();
	}

	[RPC]
	void syncAnimation(){
		if (checkJump){
			anim.SetTrigger("Jump");
			checkJump = false;
		}
		if (checkDoubleJump){
			anim.SetTrigger("Double Jump");
			checkDoubleJump = false;
		}
		if (checkWalking){
			anim.SetBool("Moving", true);
		}
		else{
			anim.SetBool("Moving", false);
		}
	}
}

<file_sep>/2dFinal GIT/Assets/Scripts/Testing/LivesTest.cs
﻿using UnityEngine;
using System.Collections;

public class LivesTest : MonoBehaviour {

    private BattleResultsManager brmScript;

	// Use this for initialization
	void Start () {
        brmScript = GetComponent<BattleResultsManager>();
	}
	
	// Update is called once per frame
	void Update () {

        if (Input.GetKeyDown(KeyCode.F6))
        {
            brmScript.setPlayerLives(brmScript.getPlayerLives() - 1);
        }
	}
}
<file_sep>/2dFinal GIT/Assets/Scripts/Main/gamestate.cs
﻿using UnityEngine;
using System.Collections;

public class gamestate : MonoBehaviour {


	// Declare properties
	private static gamestate instance;
	private string activeLevel;			
	private float healthPower,defence,moveSpeed,jumpStats,demageState,attackingSpeed;
	private string playerName;
	private bool winLoss;
	UserStats userProp = new UserStats();
	
	// ---------------------------------------------------------------------------------------------------
	// gamestate()
	// --------------------------------------------------------------------------------------------------- 
	// Creates an instance of gamestate as a gameobject if an instance does not exist
	// ---------------------------------------------------------------------------------------------------
	public static gamestate Instance
	{
		get
		{
			if(instance == null)
			{
				instance =  new GameObject("gamestate").AddComponent<gamestate>();
			}
			
			return instance;
		}
	}	
	
	// Sets the instance to null when the application quits
	public void OnApplicationQuit()
	{
		instance = null;
	}
	// startState()
	// --------------------------------------------------------------------------------------------------- 
	// Creates a new game state
	// ---------------------------------------------------------------------------------------------------
	public void startState()
	{
		print ("Creating a new game state");

		// Set default properties:
		activeLevel = "Level 1";
		playerName = userProp.PlayerName;
		healthPower = userProp.HealthPower;
		defence = userProp.Defence;
		moveSpeed = userProp.MoveSpeed;
		jumpStats = userProp.JumpStats;
		demageState = userProp.DemageStats;
		attackingSpeed = userProp.AttackingSpeed;
			
		Application.LoadLevel("network_test");
	}
}
<file_sep>/2dFinal GIT/Assets/Scripts/Main/PlatformGenerator.cs
﻿using UnityEngine;
using System.Collections;

public class PlatformGenerator : MonoBehaviour {

	GameObject[] platformsobj;

	public Transform platform;

	private bool isServer = false, isClient = false;


	//private Vector3 lfstplatform, mfstplatform, rfstplatform;
	private Vector3 lsndplatform, msndplatform, rsndplatform;
	private Vector3 ltrdplatform, mtrdplatform, rtrdplatform;
	private Vector3 lfthplatform, mfthplatform, rfthplatform;

	void GeneratePlatform(){
		platformsobj = GameObject.FindGameObjectsWithTag ("Platform");

		// Upper most platforms
		//lfstplatform = new Vector3 (-4.35f, 8f, -13.5f);
		//mfstplatform = new Vector3 (0, 8f, -12.5f);
		//rfstplatform = new Vector3 (4.35f, 8f, -13.5f);

		// 2nd Upper platforms
		lsndplatform = new Vector3 (-7.35f, 8f, -12f);
		msndplatform = new Vector3 (0, 8f, -12f);
		rsndplatform = new Vector3 (7.35f, 8f, -12f);

		// 3rd lower most platforms
		ltrdplatform = new Vector3 (-7.35f, 5f, -12f);
		mtrdplatform = new Vector3 (0, 5f, -12f);
		rtrdplatform = new Vector3 (7.35f, 5f, -12f);

		// 4th lowest most platforms
		lfthplatform = new Vector3 (-7.35f, 0f, -12f);
		mfthplatform = new Vector3 (0, 0f, -12f);
		rfthplatform = new Vector3 (7.35f, 0f, -12f);

		//int fstplatformrng = Random.Range (0,50);
		int sndplatformrng = Random.Range (0,50);
		int trdplatformrng = Random.Range (0,50);
		int fthplatformrng = Random.Range (0,50);
		int slantedplatformrng = Random.Range(0, 10);
		//int platformpicker = 0;
		int platformpicker2 = 0;
		int platformpicker3 = 0;
		int platformpicker4 = 0;

		/*
		// First Row	
		if (fstplatformrng > 20) {
			Debug.Log ("Spawning 1st row platform");
			platformpicker = Random.Range (1,4);
			switch(platformpicker)
			{
				case 1:
					if(CheckPlatforms(lfstplatform) == true){
						slantedplatformrng = Random.Range (0, 10);
						if(slantedplatformrng >= 5){
							Network.Instantiate(platform, lfstplatform, Quaternion.identity);
						}else{
							Network.Instantiate(platform, lfstplatform, Quaternion.Euler(0,0,-10));
						}
					}
					break;
				case 2:
					if(CheckPlatforms(mfstplatform) == true){
						Network.Instantiate(platform, mfstplatform, Quaternion.identity);
					}
					break;
				case 3:
					if(CheckPlatforms(rfstplatform) == true){
						slantedplatformrng = Random.Range (0, 10);
						if(slantedplatformrng >= 5){
							Network.Instantiate(platform, rfstplatform, Quaternion.identity);
						}else{
							Network.Instantiate(platform, rfstplatform, Quaternion.Euler(0,0,10));
						}
					}
					break;
			}
			Debug.Log ("1st Row = " + platformpicker);
		}
		*/

		// Second Row
		if (sndplatformrng > 10) {
			Debug.Log ("Spawning 2nd row platform");
			platformpicker2 = Random.Range (1,4);
			switch(platformpicker2)
			{
			case 1:
				if(CheckPlatforms(lsndplatform)==true)
				{
					slantedplatformrng = Random.Range (0, 10);
					if(slantedplatformrng >= 5){
						Network.Instantiate(platform, lsndplatform, Quaternion.identity, 0);
					}else{
						Network.Instantiate(platform, lsndplatform, Quaternion.Euler(0,0,-10), 0);
					}
				}else{
					if(CheckPlatforms(msndplatform)==true){
						platformpicker2 = 2;
						Network.Instantiate(platform, msndplatform, Quaternion.identity, 0);
					}
				}
				break;
			case 2:
				if(CheckPlatforms(msndplatform)==true)
				{
					Network.Instantiate(platform, msndplatform, Quaternion.identity, 0);
				}else if(CheckPlatforms(rsndplatform)==true){
					platformpicker2 = 3;
					Network.Instantiate(platform, rsndplatform, Quaternion.identity, 0);
				}else if(CheckPlatforms(lsndplatform)==true){
					platformpicker2 = 1;
					Network.Instantiate(platform, lsndplatform, Quaternion.identity, 0);
				}
				break;
			case 3:
				if(CheckPlatforms(msndplatform)==true)
				{
					//platformpicker = 3;
					Network.Instantiate(platform, msndplatform, Quaternion.identity, 0);
				}else if(CheckPlatforms(rsndplatform)==true){
					slantedplatformrng = Random.Range (0, 10);
					if(slantedplatformrng >= 5){
						Network.Instantiate(platform, rsndplatform, Quaternion.identity, 0);
					}else{
						Network.Instantiate(platform, rsndplatform, Quaternion.Euler(0,0,10), 0);
					}
				}
				break;
			}
			Debug.Log ("2nd Row = " + platformpicker2);
		}

		// Third Row
		if (trdplatformrng > 10) {
			Debug.Log ("Spawning 3rd row platform");
			platformpicker3 = Random.Range (1,4);
			switch(platformpicker3)
			{
			case 1:
				if(platformpicker2 != 1 && CheckPlatforms(ltrdplatform)==true)
				{
					slantedplatformrng = Random.Range (0, 10);
					if(slantedplatformrng >= 5){
						Network.Instantiate(platform, ltrdplatform, Quaternion.identity, 0);
					}else{
						Network.Instantiate(platform, ltrdplatform, Quaternion.Euler(0,0,-10), 0);
					}
				}else{
					if(CheckPlatforms(mtrdplatform)==true){
						platformpicker3 = 2;
						Network.Instantiate(platform, mtrdplatform, Quaternion.identity, 0);
					}
				}
				break;
			case 2:
				if(platformpicker2 != 2 && CheckPlatforms(mtrdplatform)==true)
				{
					Network.Instantiate(platform, mtrdplatform, Quaternion.identity, 0);
				}else if(platformpicker2 == 1){
					if(CheckPlatforms(rtrdplatform)==true){
						platformpicker3 = 3;
						Network.Instantiate(platform, rtrdplatform, Quaternion.identity, 0);
					}
				}else{
					if(CheckPlatforms(ltrdplatform)==true){
						platformpicker3 = 1;
						Network.Instantiate(platform, ltrdplatform, Quaternion.identity, 0);
					}
				}
				break;
			case 3:
				if(platformpicker2 == 3 && CheckPlatforms(mtrdplatform)==true)
				{
					platformpicker3 = 3;
					Network.Instantiate(platform, mtrdplatform, Quaternion.identity, 0);
				}else{
					if(CheckPlatforms(rtrdplatform)==true){
						slantedplatformrng = Random.Range (0, 10);
						if(slantedplatformrng >= 5){
							Network.Instantiate(platform, rtrdplatform, Quaternion.identity, 0);
						}else{
							Network.Instantiate(platform, rtrdplatform, Quaternion.Euler(0,0,10), 0);
						}
					}
				}
				break;
			}
			Debug.Log ("3rd Row = " + platformpicker3);
		}

		// Fourth Row
		if (fthplatformrng > 10) {
			Debug.Log ("Spawning 4th row platform");
			platformpicker4 = Random.Range (1,4);
			switch(platformpicker4)
			{
			case 1:
				if(platformpicker3 != 1 && CheckPlatforms(lfthplatform)==true)
				{
					Network.Instantiate(platform, lfthplatform, Quaternion.identity, 0);
				}else{
					if(CheckPlatforms(mfthplatform)==true){
						platformpicker4 = 2;
						Network.Instantiate(platform, mfthplatform, Quaternion.identity, 0);
					}
				}
				break;
			case 2:
				if(platformpicker3 != 2 && CheckPlatforms(mfthplatform)==true)
				{
					Network.Instantiate(platform, mfthplatform, Quaternion.identity, 0);
				}else if(platformpicker3 == 1 || platformpicker2 == 1){
					if(CheckPlatforms(rfthplatform)==true){
						platformpicker4 = 3;
						Network.Instantiate(platform, rfthplatform, Quaternion.identity, 0);
					}
				}else{
					if(CheckPlatforms(lfthplatform)==true){
						platformpicker4 = 1;
						Network.Instantiate(platform, lfthplatform, Quaternion.identity, 0);
					}
				}
				break;
			case 3:
				if(platformpicker3 == 3 && CheckPlatforms(mfthplatform)==true)
				{
					platformpicker4 = 3;
					Network.Instantiate(platform, mfthplatform, Quaternion.identity, 0);
				}else{
					if(CheckPlatforms(rfthplatform)==true){
						Network.Instantiate(platform, rfthplatform, Quaternion.identity, 0);
					}
				}
				break;
			}
			Debug.Log ("4th Row = " + platformpicker4);
		}
	}

	void DestroyPlatforms(){
		platformsobj = GameObject.FindGameObjectsWithTag ("Platform");
		Debug.Log ("Removing Platforms");
		foreach (GameObject item in platformsobj) {
			Destroy (item);
		}
	}

	bool CheckPlatforms(Vector3 chosenplatform){
		bool isfree = true;
		platformsobj = GameObject.FindGameObjectsWithTag ("Platform");
		if(platformsobj.Length > 0){
			for (int i=0; i < platformsobj.Length; i++){
				if(platformsobj[i].transform.position.x == chosenplatform.x &&
				   platformsobj[i].transform.position.y == chosenplatform.y &&
				   platformsobj[i].transform.position.z == chosenplatform.z){
					isfree = false;
					Debug.Log ("Detected overlapping on " + chosenplatform.x + " " + chosenplatform.y + " " + chosenplatform.z);
					Debug.Log ("There are " + platformsobj.Length + " left");
				}
			}
		}
		return isfree;
	}

	// Use this for initialization
	void Start () {
		// REMOVE ORIENTATION LINE UNDER THIS COMMENT UPON MERGING
		Screen.orientation = ScreenOrientation.Landscape;

		platformsobj = GameObject.FindGameObjectsWithTag ("Platform");
		// Generate the platforms
		//TotalPlatforms ();

	}

	void TotalPlatforms(){
		platformsobj = GameObject.FindGameObjectsWithTag ("Platform");

		while(GameObject.FindGameObjectsWithTag("Platform").Length <= 3){
			Debug.Log ("Less than 4 platforms!");
			GeneratePlatform();
			platformsobj = GameObject.FindGameObjectsWithTag ("Platform");
		}

		platformsobj = GameObject.FindGameObjectsWithTag ("Platform");

		Debug.Log ("Platforms total is " + platformsobj.Length);
		foreach (GameObject item in platformsobj) {
			Debug.Log ("Platform: X=" + item.transform.position.x + " Y=" + item.transform.position.y + " Z=" + item.transform.position.z);
		}
	}
	
	// Update is called once per frame
	void Update () {
		if (Network.isServer){
			if (Input.GetKeyDown (KeyCode.T) || !isServer) {
				Debug.Log ("Creating Level!!");
				TotalPlatforms();
				isServer = true;
			}
			// Reset the levels debug key
			if (Input.GetKeyDown (KeyCode.R)) {
				Debug.Log ("Destroying level!!");
				DestroyPlatforms();
			}
		}
		else{
			if (isServer){
				Debug.Log ("Destroying level!!");
				DestroyPlatforms();
				isServer = false;
			}
		}
		if (Network.isClient){
			isClient = true;
		}
		else{
			if (isClient){
				Debug.Log ("Destroying level!!");
				DestroyPlatforms();
				isClient = false;
			}
		}
	}
}
<file_sep>/2dFinal GIT/Assets/Scripts/Testing/DC_Test.cs
﻿using UnityEngine;
using System.Collections;

public class DC_Test : MonoBehaviour {

	private WeaponManager wepManage;
	private Animator anim;
	public GameObject guiText;

	// Use this for initialization
	void Start () {
		anim = this.GetComponent<Animator> ();
		wepManage = GetComponent<WeaponManager> ();
	}
	
	// Update is called once per frame
	void Update () {
	
		if(Input.GetKeyDown(KeyCode.Space))
		{
			wepManage.SwitchWeapon(0);
			guiText.SetActive(true);
			this.transform.rotation = Quaternion.Euler(0.0f, 180.0f, 0.0f);
			anim.SetTrigger("Disconnected");
		}
	}
}
<file_sep>/2dFinal GIT/Assets/Scripts/Main/UserStats.cs
﻿using System;
using UnityEngine;
using System.Collections;

public class UserStats
{

    private float healthPower,defence,moveSpeed,jumpStats,demageState,attackingSpeed;
    private int playerLives = 3;
    private string playerName;
    private bool winLoss;


    public UserStats(){}

    public UserStats(float hp,float def,float mSpeed,float jStat,float dStat,string pName,bool wLoss,float aSpeed, int lives)
    {
        healthPower = hp;
        defence = def;
        moveSpeed = mSpeed;
        jumpStats = jStat;
        demageState = dStat;
        playerName = pName;
        winLoss = wLoss;
        attackingSpeed = aSpeed;
        playerLives = lives;
    }

    public float HealthPower 
    {
        get { return healthPower; } 
        set { healthPower = value; } 
    }

	public float Defence {
	    get { return defence; }
	    set { defence = value; }
	}

	public float MoveSpeed{
	    get { return moveSpeed; }
	    set { moveSpeed = value; }
	}

    public float JumpStats {
        get { return jumpStats; }
        set { jumpStats = value; }
    }

	public float DemageStats {
	    get { return demageState; }
	    set { demageState = value; }
	}

    public string PlayerName
    {
        get { return playerName; }
        set { playerName = value; } 
    }

    public bool WinLoss {
        get { return winLoss; }
        set { winLoss = value; }
    }

	public float AttackingSpeed {
	    get { return attackingSpeed; }
	    set { attackingSpeed = value; }
	}

    public int PlayerLives
    {
        get { return playerLives; }
        set { playerLives = value; }
    }

    
}
<file_sep>/2dFinal GIT/Assets/Scripts/Main/GameOverScript.cs
﻿using UnityEngine;
using System.Collections;

public class GameOverScript : MonoBehaviour {

	//Global Objects/Variables
	public GameObject gameover;
	//multi touch support
	public static Touch[] touches;

	// Use this for initialization
	void Start () {

	}
	
	// Update is called once per frame
	void Update () {

	}

	void OnGUI(){
		Rect hg1 = new Rect (0, 0, Screen.width / 2, Screen.height);
		Rect hg2 = new Rect (Screen.width / 2, 0, Screen.width / 2, Screen.height);
		Rect info = new Rect (hg1.width / 2 - ((hg1.width - 50) / 2), 100, hg1.width - 100, hg1.height - 400);

		if (GUI.Button(new Rect(hg2.width / 2 - 100, hg2.height - 150, 200, 100), "Menu")){
			Application.LoadLevel("MainMenu");
		}
	}
}<file_sep>/2dFinal GIT/Assets/Scripts/Main/Projectile.cs
﻿using UnityEngine;
using System.Collections;

public class Projectile : MonoBehaviour {

	private float speed = 15f;
	private float timer = 0.0f;
	private float timerlimit = 5.0f;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		rigidbody.velocity = transform.forward * speed;
		if (!renderer.isVisible) {
			Debug.Log ("Destroying bullet");
			Destroy (this.gameObject);
		}
	}

	void OnCollisionEnter(Collision col){
		Destroy (this.gameObject);
	}
}
<file_sep>/2dFinal GIT/Assets/Scripts/Main/WeaponManager.cs
﻿using UnityEngine;
using System.Collections;

public class WeaponManager : MonoBehaviour {

	private Animator anim;
	private int slotNum;
	public GameObject slot_HG;
	public GameObject slot_SG;
	public GameObject slot_AR;
	public GameObject slot_ME01;

	// Use this for initialization
	void Start () {
		anim = this.GetComponent<Animator> ();
		slotNum = 0;
	}
	
	// Update is called once per frame
	void Update () 
	{
	}

	public void SwitchWeapon(int newSlot)
	{
		slotNum = newSlot;

		slot_HG.SetActive (false);
		slot_SG.SetActive (false);
		slot_AR.SetActive (false);
		slot_ME01.SetActive (false);

		switch(slotNum)
		{
		case 0:
			slot_HG.SetActive (true);
			anim.SetFloat("CurStyle", slotNum);
			Debug.Log("HG equipped!");
			break;
		case 1:
			slot_SG.SetActive (true);
			anim.SetFloat("CurStyle", slotNum);
			Debug.Log("SG equipped!");
			break;
		case 2:
			slot_AR.SetActive (true);
			anim.SetFloat("CurStyle", slotNum);
			Debug.Log("AR equipped!");
			break;
		case 5:
			slot_ME01.SetActive (true);
			anim.SetFloat("CurStyle", slotNum);
			Debug.Log("ME equipped!");
			break;
		}
	}

	public int GetSlotNum()
	{
		return slotNum;
	}
}
<file_sep>/2dFinal GIT/Assets/Scripts/Main/ShootBtnManager.cs
﻿using UnityEngine;
using System.Collections;

public class ShootBtnManager : MonoBehaviour {

	private int curWep; 
	private WeaponManager wepManage;
	public Texture HG_TEX;
	public Texture SG_TEX;
	public Texture AR_TEX;
	public Texture ME_TEX;

	// Use this for initialization
	void Start () {

//		wepManage = GameObject.FindWithTag ("Player").GetComponent<WeaponManager> ();
	}
	
	// Update is called once per frame
	void Update () {
	
//		curWep = wepManage.GetSlotNum ();

		switch(curWep)
		{
		case 0:
			this.renderer.material.mainTexture = HG_TEX;
			break;
		case 1:
			this.renderer.material.mainTexture = SG_TEX;
			break;
		case 2:
			this.renderer.material.mainTexture = AR_TEX;
			break;
		case 5:
			this.renderer.material.mainTexture = ME_TEX;
			break;
		}
	}
}
<file_sep>/2dFinal GIT/Assets/Scripts/Main/BattleResultsManager.cs
﻿using UnityEngine;
using System.Collections;

public class BattleResultsManager : MonoBehaviour {

    public GameObject life01;
    public GameObject life02;
    public GameObject life03;

    private int playerLives = 3;
    private TestHealth thScript;
    private bool livesLeft;

	// Use this for initialization
	void Start () {
        livesLeft = true;
        thScript = GetComponent<TestHealth>();
	}
	
	// Update is called once per frame
	void Update () {
		thScript.getAliveStatus();
        switch (playerLives)
        {
            case 0:
                life01.SetActive(false);
                life02.SetActive(false);
                life03.SetActive(false);
                break;
            case 1:
                life01.SetActive(true);
                life02.SetActive(false);
                life03.SetActive(false);
                break;
            case 2:
                life01.SetActive(true);
                life02.SetActive(true);
                life03.SetActive(false);
                break;
            case 3:
                life01.SetActive(true);
                life02.SetActive(true);
                life03.SetActive(true);
                break;
        }

        if (thScript.getAliveStatus() == false)
        {
            thScript.setAliveStatus(true);
            playerLives--;
        }

        if (playerLives <= 0)
        {
            livesLeft = false;
            Application.LoadLevel("Lose_Screen");
        }
	}

    public bool getLivesLeft()
    {
        return livesLeft;
    }

    public void setLivesLeft(bool newStatus)
    {
        livesLeft = newStatus;
    }

    //For testing only
    public void setPlayerLives(int newValue)
    {
        playerLives = newValue;
    }

    public int getPlayerLives()
    {
        return playerLives;
    }
}
<file_sep>/2dFinal GIT/Assets/Scripts/Testing/WeaponChange_Test.cs
﻿using UnityEngine;
using System.Collections;

public class WeaponChange_Test : MonoBehaviour {

	private WeaponManager wepManage;

	// Use this for initialization
	void Start () {
		wepManage = GetComponent<WeaponManager> ();
	}
	
	// Update is called once per frame
	void Update () {
	
		if(Input.GetKeyDown(KeyCode.F1))
		{
			wepManage.SwitchWeapon(0);
		}

		if(Input.GetKeyDown(KeyCode.F2))
		{
			wepManage.SwitchWeapon(1);
		}

		if(Input.GetKeyDown(KeyCode.F3))
		{
			wepManage.SwitchWeapon(2);
		}

		if(Input.GetKeyDown(KeyCode.F4))
		{
			wepManage.SwitchWeapon(5);
		}
	}
}
<file_sep>/2dFinal GIT/Assets/Scripts/Main/PlayerCustomization.cs
﻿using System.Collections.Generic;
using UnityEngine;
using System.Collections;

public class PlayerCustomization 
{
    public static int totalAttack, totalDefence, totalSpeed;

    public enum Attack
    {
        PowerGloves,BrawnBadge,XAttack
    }
    public enum Defence
    {
        ProtectionBadge,Jacket,Suit,Helmet
    }
    public enum Speed
    {
        AgilityBadge,Boots,Booster,Shoes
    }

    public int[] EquipAttack(Attack att)
    {
        switch (att)
        {
            case Attack.PowerGloves:
                totalAttack += 85;
                totalDefence -= 35;
                break;
            case Attack.BrawnBadge:
                totalAttack += 45;
                totalDefence -= 25;
                break;
            case Attack.XAttack:
                totalAttack += 65;
                totalDefence -= 45;
                break;
        }
        return new int[] { totalAttack, totalDefence}; // returning 2 values final attack , final defence 
    }

    public int[] EquipDefence(Defence def)
    {
        switch (def)
        {
            case Defence.Helmet:
                totalDefence += 55;
                totalSpeed -=  25;
                break;
            case Defence.Jacket:
                totalDefence += 85;
                totalSpeed -= 35;
                break;
            case Defence.ProtectionBadge:
                totalDefence += 45;
                totalSpeed -= 22;
                break;
            case Defence.Suit:
                totalDefence += 65;
                totalSpeed -= 30;
                break;
        }
        return new int[] {totalDefence, totalSpeed}; // returning two values |  final defence and final speed;
    }
    public int[] EquipSpeed(Speed spd)
    {
        switch (spd)
        {
            case Speed.AgilityBadge:
                totalSpeed += 55;
                totalAttack -= 20;
                break;
            case Speed.Booster:
                totalSpeed += 70;
                totalAttack -= 45;
                break;
            case Speed.Boots:
                totalSpeed += 40;
                totalAttack-= 35;
                break;
            case Speed.Shoes:
                totalSpeed += 35;
                totalAttack -= 35;
                break;
        }
        return new int[] { totalSpeed, totalAttack };  // returning two values |  final speed and final attack
    }

//    void Start ()
//    {
//
//        //Debug.Log("First I choose helmet from  defence equipment - Final Defence: " + EquipDefence(Defence.Helmet)[0]);
//
//        //Debug.Log("second I choose boots from Speed equipment - Final Speed: " + EquipSpeed(Speed.Boots)[0]);
//
//        EquipAttack(Attack.XAttack);
//        EquipDefence(Defence.Helmet);
//        EquipSpeed(Speed.Booster);
//
//        Debug.Log("Total Attack : " + totalAttack);
//        Debug.Log("Total speed : " + totalSpeed);
//        Debug.Log("Total defence: " + totalDefence);
//
//    }
//	
//	void Update () {
//	
//	}

}
<file_sep>/2dFinal GIT/Assets/Scripts/Main/GroundCheck.cs
﻿using UnityEngine;
using System.Collections;

public class GroundCheck : MonoBehaviour {

	public static Animator anim;
	// Use this for initialization
	void Start () {
		anim = this.GetComponent<Animator> ();
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	void OnCollisionEnter(Collision col)
	{
		if (col.gameObject.tag == "Platform" || col.gameObject.tag == "Ground")
		{
			anim.SetBool("Grounded", true);
			PlayerController.isGrounded = true;
			PlayerController.doubleJump = true;
			Debug.Log("GROUNDED");
		}
	}

	void OnCollisionStay(Collision col)
	{
		if (col.gameObject.tag == "Platform" || col.gameObject.tag == "Ground")
		{
			anim.SetBool("Grounded", true);
			PlayerController.isGrounded = true;
			PlayerController.doubleJump = true;
			Debug.Log("GROUNDED");
		}
	}

	void OnCollisionExit(Collision col)
	{
		if (col.gameObject.tag == "Platform" || col.gameObject.tag == "Ground")
		{
			anim.SetBool("Grounded", false);
			PlayerController.isGrounded = false;
			PlayerController.doubleJump = true;
			Debug.Log("NOT GROUNDED");
		}
	}
}
<file_sep>/2dFinal GIT/Assets/Scripts/Main/NetworkScript.cs
﻿using UnityEngine;
using System.Collections;

public class NetworkScript : MonoBehaviour {

	//Global Objects/Variables
	public GUISkin skinGUI;
	public string gameName = "Let's Brawl ver 0.5";//Name of the Game
	public string serverName = "Game Match";//Custom name of the server
	public string hostName = "John";//Host Name
	private string password = "";//The password that the player enters
	private bool wantPass = false;//If the player hosting a game wants to add a password
	private string errorMessage = "";

	private bool refreshing = true, searching = false;
	private HostData[] hData = new HostData[6];
	private int minPortNum = 25001, maxPortNum = 25555;
	public int portNum = 25001;
	private bool taken = false;
	private string waitMsg = "";
	private int[] playerNum = new int[6];
	public int game;

	public GameObject player;
	public GameObject startPos;
	
	void startServer(){
		if (serverName == null || serverName == "")
			errorMessage = "Enter a name in the Server Name field.";
		else if (wantPass && password == "")
			errorMessage = "Enter a Password";
		else{
			if (wantPass)
				Network.incomingPassword = <PASSWORD>;
			portNum = Random.Range(minPortNum, maxPortNum);
			Network.InitializeServer (3, portNum, !Network.HavePublicAddress());//Number of players, port number, makes sure the port isn't taken
			MasterServer.RegisterHost (gameName, serverName, hostName);
			Debug.Log("Starting Server");
		}
	}
	void startServer(int port){
		if (serverName == null || serverName == "")
			errorMessage = "Enter a name in the Server Name field.";
		else if (wantPass && password == "")
			errorMessage = "Enter a Password";
		else{
			if (wantPass)
				Network.incomingPassword = <PASSWORD>;
			Network.InitializeServer (3, port, !Network.HavePublicAddress());//Number of players, port number, makes sure the port isn't taken
			MasterServer.RegisterHost (gameName, serverName, hostName);
			Debug.Log("Starting Server");
		}
	}
	
	void refreshHostList(){
		MasterServer.RequestHostList (gameName);
		refreshing = true;
		for (int i = 0; i < hData.Length; i++){
			hData[i] = null;
		}
	}

	void createPlayer(int playerNum){
		if (Network.isServer){
			Network.Instantiate (player, startPos.transform.position, player.transform.rotation, 0);
		}
		else if (Network.isClient)
			Network.Instantiate (player, startPos.transform.position, player.transform.rotation, playerNum);
	}
	
	void Update () {
		if (refreshing){
			if (MasterServer.PollHostList().Length > 0){
				refreshing = false;
				Debug.Log(MasterServer.PollHostList ().Length);
				hData = MasterServer.PollHostList ();
				waitMsg = "";
			}
			else{
				waitMsg = "<size=20>Finding Games...</size>";
				//refreshing = false;
			}
		}
		else{
			if (hData.Length <= 0){
				waitMsg = "<size=20>Can't Find Games</size>";
			}
			else{
				hData = MasterServer.PollHostList ();
			}
		}
	}

	void OnServerInitialized(){
		Debug.Log ("Server Initialized");
		createPlayer (game);
	}

	void OnConnectedToServer(){
		createPlayer (game);
	}

	void OnPlayerConnected(NetworkPlayer player){
		Debug.Log ("Player:" + player.port);
	}

	void OnPlayerDisconnected(NetworkPlayer player) {
		Debug.Log("Clean up after player " + player);
		Network.RemoveRPCs(player);
		Network.DestroyPlayerObjects(player);
	}

	void OnDisconnectedFromServer(){
		GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
		GameObject[] hpBars = GameObject.FindGameObjectsWithTag("HP");
		for (int i = 0; i < players.Length; i++){
			Destroy(players[i]);
			Destroy(hpBars[i]);
		}
	}
	
	void OnMasterServerEvent(MasterServerEvent mse){
		if (searching){
			if(mse == MasterServerEvent.RegistrationSucceeded){
				taken = false;
				Debug.Log("Registered Server!");
				searching = false;
			}
			else{
				errorMessage = "Server already taken.";
				taken = true;
				Debug.Log("Registration Failed");
				startServer();
			}
		}
	}
	
	void OnGUI(){
		//Determined menu sizes
		Rect hg1 = new Rect (0, 0, Screen.width / 2, Screen.height+150);
		Rect hg2 = new Rect (Screen.width / 2, 0, Screen.width / 2, Screen.height+150);
		Rect info = new Rect (hg1.width / 2 - ((hg1.width - 50) / 2), 100, hg1.width - 100, hg1.height - 100);
		
		GUI.skin = skinGUI;
		//If you're not in a game
		if (!Network.isServer && !Network.isClient){
			GUI.BeginGroup (hg1);//Gives the GUI a default size
			GUI.Box (new Rect(0, 0, hg1.width, hg1.height), "<size=20>Host Game</size>");
			//Hosting game menu========================================================================================================
			GUI.BeginGroup (info);
			GUI.Label (new Rect (20, 1, 200, 80), "<size=20>Server Name:</size>");
			serverName = GUI.TextField (new Rect(150, 10, 200, 30), serverName, 15);

			//Toggle whether you want a password or not
			wantPass = GUI.Toggle (new Rect (20, 30, 150, 100), wantPass, "<size=20>Password</size>");
			//If you want a password with your game
			if (wantPass){
				GUI.Label(new Rect(20, 60, 200, 40), "<size=20>Enter Password:</size>");
				password = GUI.PasswordField(new Rect(180, 60, 140, 30), password, '#', 15);
			}

			GUI.Label (new Rect (20, info.height - 80, info.width - 40, 20), errorMessage);
			
			//Rect btnSize1 = new Rect (info.width / 2 - 50, info.height - 50, 100, 50);
			GUI.EndGroup ();
			
			if (GUI.Button(new Rect(hg1.width / 2-90, hg1.height/ 2-10, 200, 100), "<size=20>Start Server</size>")){
				searching = true;
				startServer();
			}
			GUI.EndGroup ();
			//Finding game menu========================================================================================================
			GUI.BeginGroup (hg2);
			GUI.Box (new Rect (0, 0, hg2.width, hg2.height), "<size=20>Join Game</size>");
			
			if (GUI.Button(new Rect(20, 20, 120, 80), "<size=20>Refresh</size>")){
				refreshHostList();
				Debug.Log("Refresh");
			}
			GUI.Label (new Rect (hg2.width / 2 - 70, hg2.height / 2 - 120, 200, 80), waitMsg);
			Rect gameBox;
			if (!refreshing){
				for (int i = 0; i < hData.Length; i++){
					if (hData[i] != null){
						gameBox = new Rect (hg2.width / 2 - ((hg2.width - 200) / 2), 60 + (60 * i), hg2.width - 50, 60);
						GUI.BeginGroup(gameBox);
						GUI.Box(gameBox, "" + (1 + 1));
						GUI.Label(new Rect(gameBox.width / 2 - 100, gameBox.height / 2 - 10, 200, 20), hData[i].gameName);
						GUI.Label(new Rect(20, 10, 200, 20), "Host: " + hData[i].comment);
						GUI.Label(new Rect(20, gameBox.height - 30, 50, 20), hData[i].connectedPlayers + "/" + hData[i].playerLimit);
						playerNum[i] = hData[i].connectedPlayers;
						if (GUI.Button(new Rect(gameBox.width - 100, 0, 40, 40), "Join")){
							if (hData[i].passwordProtected){
								//This is not important right now
							}
							else{
								game = playerNum[i];
								Network.Connect(hData[i]);
							}
						}
						GUI.EndGroup();
					}
				}
			}
			if (GUI.Button(new Rect(hg2.width / 2-90, hg2.height/ 2-10, 200, 100), "<size=20>Menu</size>")){
				Application.LoadLevel("MainMenu");
			}
			GUI.EndGroup ();
			//End of game menu========================================================================================================
		}
		else{
			
		}
		if (Network.isServer){
			if (GUI.Button(new Rect(20, 20, 200, 100), "Close Server")){
				Network.Disconnect();
			}
		}
		if (Network.isClient){
			if (GUI.Button(new Rect(20, 20, 200, 100), "Disconnect")){
				Network.Disconnect();
			}
		}
	}
}
<file_sep>/2dFinal GIT/Assets/Scripts/Testing/Gui_Test.cs
﻿using UnityEngine;
using System.Collections;

public class Gui_Test : MonoBehaviour
{
    // we dont need to attach this script to camera. As Navdeep said just show something on the screen. SO I just 
    // added this Gui_Test to camera for testing purpose and created 2 UserStats object and passed some data.


    private UserStats player1,player2;

	void Start ()
	{
        // since we will allow 4 player to connect therefore we can just create 4 user stats on any script 
        // and modify values using proerties. 

        //nPlayer = new Userstats(float hp,float def,float mSpeed,float jStat,float dStat,string pName,bool wLoss,float aSpeed)

		player1 = new UserStats(45,20,23,12,32,"Red Guy",true,32, 3);
        player2 = new UserStats(20, 10, 40, 00, 12, "Bowser", true, 22, 3);
	}
	
	void Update () {

	}

    void OnGUI()
    {

        /////////////////// 1st player ////////////
       
       
        GUILayout.BeginArea(new Rect(10, 10, 180, Screen.width / 2));
        GUILayout.BeginVertical("box");

        GUILayout.Label("Player Name: "+player1.PlayerName);
        GUILayout.Label("Health Power: " + player1.HealthPower);
        GUILayout.Label("Defence: "+player1.Defence);
        GUILayout.Label("Move Speed: "+player1.MoveSpeed);
        GUILayout.Label("Jump: "+player1.JumpStats);
        GUILayout.Label("Demage: "+player1.DemageStats);
        GUILayout.Label("win/lose: "+player1.WinLoss);
        GUILayout.Label("Atacking Speed: "+player1.AttackingSpeed);

        GUILayout.EndVertical();
        GUILayout.EndArea();

        /////////////////// 2nd player ////////////
        
        GUILayout.BeginArea(new Rect(200, 10, 180, Screen.width / 2));
        GUILayout.BeginVertical("box");

        GUILayout.Label("Player Name: " + player2.PlayerName);
        GUILayout.Label("Health Power: " + player2.HealthPower);
        GUILayout.Label("Defence: " + player2.Defence);
        GUILayout.Label("Move Speed: " + player2.MoveSpeed);
        GUILayout.Label("Jump: " + player2.JumpStats);
        GUILayout.Label("Demage: " + player2.DemageStats);
        GUILayout.Label("win/lose: " + player2.WinLoss);
        GUILayout.Label("Atacking Speed: " + player2.AttackingSpeed);

        GUILayout.EndVertical();
        GUILayout.EndArea();
    }

}
<file_sep>/2dFinal GIT/Assets/Scripts/Main/gamestart.cs
﻿using UnityEngine.UI;
using UnityEngine;
using System.Collections;

public class gamestart : MonoBehaviour 
{		
	// Our Startscreen GUI
	//healthPower being distributed to TestHealthPower, firerate changes firerate of each gun check player Controller switch
	//statement
	public static float healthPower = 100.00f;
	public static float fireRate;

	GameObject customizeMenu,GUIButton;
	Slider headGearSlider,chestGearSlider,glovesSlider,fireRateSlider;
	UserStats userStats = new UserStats();

	void Start(){
		customizeMenu = GameObject.Find("CustomizeMenu");
		GUIButton = GameObject.Find("GUI");
		customizeMenu.SetActive(false);
		//GUI.skin.label.fontSize = Screen.height / 1080 * 64;
	}

	public void BackButton(){
		customizeMenu.SetActive(false);
		GUIButton.SetActive(true);
	}

	void OnGUI () 
	{
		if(GUI.Button(new Rect (Screen.width/2 - 150, Screen.height/2 - 40, 290, 90), "<size=28>Play Game</size>"))
		{
			startGame();
		}	
		if (GUI.Button (new Rect (Screen.width/2 - 150, Screen.height/2 + 60, 290, 90), "<size=28>Customize Character</size>"))
		{
			customizeMenu.SetActive(true);

			headGearSlider = GameObject.Find("headGearSlider").GetComponent<Slider>();
			headGearSlider.onValueChanged.AddListener(HeadGearListener);

			chestGearSlider = GameObject.Find("chestGearSlider").GetComponent<Slider>();
			chestGearSlider.onValueChanged.AddListener(ChestGearListener);

			glovesSlider = GameObject.Find("glovesSlider").GetComponent<Slider>();
			glovesSlider.onValueChanged.AddListener(GlovesGearListener);

			fireRateSlider = GameObject.Find("fireRateSlider").GetComponent<Slider>();
			fireRateSlider.onValueChanged.AddListener(FireRateListener);
			
			GUIButton.SetActive(false);
		}
	}

	public void HeadGearListener(float value)
	{
		if(headGearSlider.value >= 0.7){
			chestGearSlider.value = 0.5f;
			glovesSlider.value = 0.2f;
			healthPower = 90;
		}
		if(headGearSlider.value <= 0.5){
			chestGearSlider.value = 0.6f;
			glovesSlider.value = 0.3f;
			healthPower = 80;
		}
	}
	public void ChestGearListener(float value)
	{
		if(chestGearSlider.value >= 0.7){
			headGearSlider.value = 0.5f;
			glovesSlider.value = 0.4f;
			healthPower = 90;
		}

	}
	public void GlovesGearListener(float value)
	{
		if(glovesSlider.value >= 0.7){
			chestGearSlider.value = 0.4f;
			headGearSlider.value = 0.3f;
			healthPower = 85;
		}
		if(glovesSlider.value <= 0.3){
			chestGearSlider.value = 0.6f;
			headGearSlider.value = 0.8f;
			healthPower = 80;
		}
	}
	public void FireRateListener(float value)
	{
		fireRate = fireRateSlider.value;
	}

	private void startGame()
	{
		//Launch Louis Script
		print("Starting game scene");
		DontDestroyOnLoad(gamestate.Instance);
		gamestate.Instance.startState();
	}

	private void Achievements()
	{
		print("Achievements scene");
		
		DontDestroyOnLoad(gamestate.Instance);
		gamestate.Instance.startState();
	}
}
