using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class playerscript : MonoBehaviour {
public static bool ct;
public bool im;
public Vector3 movedir,mp;
public Vector3 rot;
public Rigidbody rb;
public GameObject bullet,sp;
public Camera c;
public float dps,timer=0.5f;
public float h1,v1;
public int lives = 3;
public GameObject
[] parts
= new GameObject
[2];
// Use this for initialization
void Start () {
rb = GetComponent<Rigidbody> ();
}
// Update is called once per frame
void Update () {
if (rb.velocity == Vector3.zero)
timer = 0.5f;
if (rb.velocity != Vector3.zero && timer <= 1)
timer += Time.deltaTime;
if(Input.GetButtonDown("ct"))ct = !ct;
v1 = Input.GetAxis ("V2");
h1 = Input.GetAxis ("H2");
dps += Time.deltaTime;
Transform t = transform;
Quaternion q
= new Quaternion
();
q
.eulerAngles = new Vector3
(transform
.rotation.eulerAngles.x+90,transform
.rotation.eulerAngles.y-90,transform
.rotation.eulerAngles.z);
if (Input.GetButton("Jump")&& dps > 0.15f) {
GameObject clone = Instantiate(bullet,sp.transform.position,q);
clone.GetComponent<Rigidbody>().AddForce(transform.forward * 400);
dps = 0;
}
rb.velocity = movedir;
movedir
= (new Vector3
(Input
.GetAxis("Horizontal"),
0,Input
.GetAxis("Vertical"))).normalized*1
.5f
*timer
;
//t.LookAt (transform.position+ movedir);
RaycastHit hit;
Ray ray = c.ScreenPointToRay(Input.mousePosition);
Debug.DrawRay (ray.origin, ray.direction*10);
if (Physics.Raycast (ray, out hit)&& ct&&Vector3.Distance(hit.point,transform.position)>0.1f) {
t = transform;
t.LookAt (hit.point);
q
.eulerAngles = new Vector3
(0,t
.rotation.eulerAngles.y,
0);
transform.rotation = q;
}
if (!ct) {
t = transform;
Vector3 lookdir
= (new Vector3
(Input
.GetAxis ("H2"),
0, Input
.GetAxis ("V2"))).normalized * 10;
if(lookdir!= Vector3.zero)t.LookAt (lookdir);
}
//transform.rotation = q;
}
void Getdmg(){
if (!im) {
lives--;
if (lives > 0)
breakone ();
if (lives == 0) {
lives = 3;
Application.LoadLevel( SceneManager.GetActiveScene().buildIndex);
}
StartCoroutine ("immortal");
}
}
void breakone(){
if (parts [0].active == true) {
parts [0].SetActive(false);
}
else parts [1].SetActive(false);
}
public IEnumerator immortal(){
im = true;
gameObject.layer = 9;
Renderer[] g = GetComponentsInChildren<Renderer> ();
foreach (Renderer a in g) {
a
.material.color = new Color
(a
.material.color.r,a
.material.color.g,a
.material.color.b,
0);
}
yield return new WaitForSeconds
(1);
im = false;
gameObject.layer = 12;
foreach (Renderer a in g) {
a
.material.color = new Color
(a
.material.color.r,a
.material.color.g,a
.material.color.b,
1);
}
}
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}