Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class SpaceshipBehaviour : MonoBehaviour {
- public float Speed=10;
- public float RotationSpeed=100;
- public GameObject Explosion;
- public GameObject PlasmaTrail;
- public bool GodMode = false;
- private float _rotation=0;
- private int GodModeCounter=0;
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update () {
- if (Input.GetButton("Vertical"))
- {
- //Instantiate(PlasmaTrail, transform.position, transform.rotation);
- transform.position += transform.forward*(Speed*Time.deltaTime)*Input.GetAxis("Vertical");
- }
- if (Input.GetButton("Horizontal"))
- {
- _rotation += RotationSpeed*Time.deltaTime*Input.GetAxis("Horizontal");
- transform.rotation = Quaternion.AngleAxis(_rotation, transform.up);
- }
- if(GodMode == true)
- {
- Instantiate(Explosion, transform.position, transform.rotation);
- ++GodModeCounter;
- if(GodModeCounter>5000)
- {
- GodMode = false;
- GodModeCounter = 0;
- }
- }
- }
- void OnTriggerEnter(Collider colliderobject)
- {
- if(GodMode == false)
- {
- if(colliderobject.transform.tag.Equals("Asteroid"))
- {
- Destroy(gameObject);
- Instantiate(Explosion, transform.position, transform.rotation);
- GodMode = true;
- var spawner=GameObject.Find("SpaceshipSpawner");
- if(spawner != null)
- {
- spawner.GetComponent<SpaceshipSpawnBehaviour>().ShipSpawned=false;
- spawner.GetComponent<SpaceshipSpawnBehaviour>().Lives -= 1;
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment