<repo_name>Asplomer/FPSMobile<file_sep>/FPSmobileS/Assets/Scripts/Extras/Follower2.cs
﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Follower2 : MonoBehaviour {

	public float speed = 1.8f;
	public Transform Target;
	public float timerBomber =3.0f;
	public float timer;
	public GameObject bomb;
	// Use this for initialization
	void Start () {
		timer = 0.0f;
	}

	// Update is called once per frame
	void Update () {
		if (timer != 0.0f) {
			timer = timer + Time.deltaTime;
		}
	//	Debug.Log (timer);
		Vector3 pos1 = this.transform.position;
		Vector3 pos2 = Target.position;

		Vector3 dir = pos2 - pos1;
		dir.y = 0.0f;
		dir.Normalize ();

		transform.rotation = Quaternion.LookRotation (dir);
		pos1 += speed * Time.deltaTime * transform.forward;
		transform.position = pos1;
		if (pos1.x + 3.0f > pos2.x && timer >= 0.0f) {
			Instantiate (bomb, transform.position, transform.rotation);
			timer -= timerBomber;

		}		
	}
}
<file_sep>/FPSmobileS/Assets/Scripts/Extras/CameraFollower.cs
﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraFollower : MonoBehaviour 
{

	public Transform Target;

	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		Vector3 posPlayer= Target.position;
		transform.position = posPlayer;

		posPlayer.Normalize ();

		transform.rotation = Quaternion.LookRotation (Target.forward);


	}
}
<file_sep>/FPSmobileS/Assets/Scripts/FoeScriptA.cs
﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FoeScriptA : MonoBehaviour {
	public int EnemyHealth;

	//i need a way to check for an impact with a spell or player


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


		if (EnemyHealth <= 0) {
			gameObject.GetComponent<Spawner> ().foeCount--;
			Destroy (gameObject); 
		}	
		//Debug.Log(EnemyHealth);
	}
}
<file_sep>/FPSmobileS/Assets/Scripts/PlayerShoot.cs
﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;

public class PlayerShoot : MonoBehaviour {


	public GameObject bulletPrefab;
	public Transform bulletSpawn;

	// Use this for initialization
	void Update () {
		/*
		if (!isLocalPlayer) {
			return;
		}*/
		var x = Input.GetAxis ("Horizontal") * Time.deltaTime * 150.0f;
		var z = Input.GetAxis ("Vertical") * Time.deltaTime * 3.0f;
		transform.Rotate (0, x, 0);
		transform.Rotate (0, 0, z);
		if (Input.GetKey ("Fire1")) {
			Fire ();
		}
	
	}

	
	// Update is called once per frame
	void Fire () {
		var bullet = (GameObject)Instantiate(
			bulletPrefab,
			bulletSpawn.position,
			bulletSpawn.rotation);

		bullet.GetComponent<Rigidbody> ().velocity = bullet.transform.forward * 6;
			Destroy (bullet, 2.0f);
		
		}











}<file_sep>/FPSmobileS/Assets/Scripts/Extras/MyShip.cs
﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MyShip : MonoBehaviour 
{
	public float Accel = 1.0f;
	public float RotSpeed = 5.0f;
	Vector3 speed = Vector3.zero;

	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		Vector3 pos = this.transform.position;

		if (Input.GetKey (KeyCode.RightArrow)) {
			this.transform.rotation *= Quaternion.AngleAxis (-RotSpeed * Time.deltaTime, Vector3.forward);
		}

		if (Input.GetKey (KeyCode.LeftArrow)) {
			this.transform.rotation *= Quaternion.AngleAxis (RotSpeed * Time.deltaTime, Vector3.forward);
		}

		if (Input.GetKey (KeyCode.UpArrow)) {
			speed += this.transform.up * Accel * Time.deltaTime;
		}

		pos += speed * Time.deltaTime;

		this.transform.position = pos;
	}
}
<file_sep>/FPSmobileS/Assets/Scripts/OnHitBehaviour.cs
﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class OnHitBehaviour : MonoBehaviour {
	private float duration;
	public float lifetime;
	// Use this for initialization
	void Start () {
		duration = 0.0f;
	}
	
	// Update is called once per frame
	void Update () {
		duration = duration + Time.deltaTime;
		if (duration >= lifetime) {
			Destroy (gameObject);
		}
	}
}
<file_sep>/FPSmobileS/Assets/Scripts/BombExplosion.cs
﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public class BombExplosion : MonoBehaviour {
	private float duration;
	public float lifetime;
	public GameObject player;
	private bool notHit;
	Vector3 vec ;
	Vector3 bomb ;
	// Use this for initialization
	void Start () {
		duration = 0.0f;
		notHit = true;

		vec= player.transform.position;
		 bomb = this.transform.position;
	}
	void OnTriggerEnter(Collider collider){
		if (collider.tag == "Player" || notHit) {
			
				//collider.gameObject.GetComponent<PlayerHealth> ().Health -= 1;
				notHit = false;
		

		}
	}
	// Update is called once per frame
	void Update () {
		duration = duration + Time.deltaTime;


		if (duration >= lifetime) {
			Destroy (gameObject);
		}
	}
}
<file_sep>/FPSmobileS/Assets/Scripts/Spawner.cs
﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Spawner : MonoBehaviour {

	public int foeCount;
	public int MaxFoe;
	public float timer;
	private Vector3 SpawnArea;
	void Start () {
		foeCount = 2;
		MaxFoe = 2;
//		Random.InitState();
	}
	public void Spawn(GameObject Creature, Vector3 Area){
		Instantiate (Creature, this.transform.position, this.transform.rotation);
		foeCount++;
	}

	// Update is called once per frame
	void Update () {/*
		if(foeCount !=MaxFoe){
			SpawnArea = Random.insideUnitSphere;
			transform.position.Set (SpawnArea.x, 0.0f, SpawnArea.z);


		}*/
	}
}
<file_sep>/FPSmobileS/Assets/Scripts/ShootCasting.cs
﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ShootCasting : MonoBehaviour {

	public GameObject bulletPrefab;
	public GameObject bulletPrefab2;
	public Transform tipWandF;
	public Transform tipWandR;
	public Transform tipWandL;

	// Update is called once per frame
	void Update () {
		if (Input.GetButtonDown("Fire1")) {
			SimpleSpell();
		}
		if (Input.GetButtonDown("Fire2")){
			SpreadSpell();
		}
	}

	void SimpleSpell(){
		Instantiate(bulletPrefab, tipWandF.position, tipWandF.rotation);
	}

	void SpreadSpell(){
		Instantiate(bulletPrefab2, tipWandF.position, tipWandF.rotation);
		Instantiate(bulletPrefab2, tipWandL.position, tipWandL.rotation);
		Instantiate(bulletPrefab2, tipWandR.position, tipWandR.rotation);

	}
	/*
	void SimpleSpell(){
		Instantiate(bulletPrefab, tipWandF.position, tipWandF.rotation);
	}


*/
}<file_sep>/FPSmobileS/Assets/Scripts/PlayerHealth.cs
﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerHealth : MonoBehaviour
{
	public int Health;
	private float iframes;
	private bool hit;
	//i need a way to check for an impact with a spell or player


	void Start () {
		iframes = 0f;
		hit = false;
	}
	void OnTriggerEnter(Collider collider){


		if ((collider.tag == "Enemy")&& !hit) {
			Health--;
			hit = true;
		}
		if ((collider.tag == "EBullet")&& !hit) {
			Health-=3;
			hit = true;
		}

	}
	// Update is called once per frame
	void Update () {
		if (iframes >= 1.0f && hit) {
			hit = false;
			iframes = 0.0f;
		}
		if (iframes != 1.0f && hit) {
			iframes = iframes + Time.deltaTime;

		} 
		Debug.Log(iframes);
		if (Health <= 0) {
			Destroy (gameObject); 
			UnityEngine.SceneManagement.SceneManager.LoadScene ("TitleScreen");
			}	
	//	Debug.Log(Health);
	}
}
<file_sep>/FPSmobileS/Assets/Scripts/bomb.cs
﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class bomb : MonoBehaviour {
	public float boltSpeed;
	private float duration;
	public float lifetimeBullet;
	public GameObject onHit;
	void Start(){
		duration = 0.0f;

	}
	void OnTriggerEnter(Collider collider){


		if ((collider.tag == "Floor" || collider.tag == "Player")) {
			Instantiate (onHit, transform.position, transform.rotation);
			Destroy (gameObject);
		}
	}
	void Update () {
		if(this.tag =="EBullet"){
			transform.Translate(Vector3.down* boltSpeed);
								
		}

		duration = duration + Time.deltaTime;
		if (duration >= lifetimeBullet) {

			Destroy (gameObject);
		}





	}



}
<file_sep>/FPSmobileS/Assets/Scripts/HealthBar.cs
﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class HealthBar : MonoBehaviour {

	public  GameObject Bar1;
	public  GameObject Bar2;
	public  GameObject Bar3;
	public  GameObject Bar4;
	public  GameObject Bar5;

	public GameObject player;

	void Update () {
		if((player.gameObject.GetComponent<PlayerHealth>().Health) <= 8)
			Destroy (Bar1);
		if((player.gameObject.GetComponent<PlayerHealth>().Health) <= 6)
			Destroy (Bar2);
		if((player.gameObject.GetComponent<PlayerHealth>().Health) <= 4)
			Destroy (Bar3);
		if((player.gameObject.GetComponent<PlayerHealth>().Health) <= 2)
			Destroy (Bar4);
		if((player.gameObject.GetComponent<PlayerHealth>().Health) <= 0)
			Destroy (Bar5);
		

	}
}
