Guest User

Untitled

a guest
Dec 18th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class SpaceshipBehaviour : MonoBehaviour {
  5.  
  6. public float Speed=10;
  7. public float RotationSpeed=100;
  8. public GameObject Explosion;
  9. public GameObject PlasmaTrail;
  10. public bool GodMode = false;
  11.  
  12. private float _rotation=0;
  13. private int GodModeCounter=0;
  14.  
  15. // Use this for initialization
  16. void Start () {
  17.  
  18. }
  19.  
  20. // Update is called once per frame
  21. void Update () {
  22.  
  23. if (Input.GetButton("Vertical"))
  24. {
  25. //Instantiate(PlasmaTrail, transform.position, transform.rotation);
  26. transform.position += transform.forward*(Speed*Time.deltaTime)*Input.GetAxis("Vertical");
  27. }
  28.  
  29. if (Input.GetButton("Horizontal"))
  30. {
  31. _rotation += RotationSpeed*Time.deltaTime*Input.GetAxis("Horizontal");
  32. transform.rotation = Quaternion.AngleAxis(_rotation, transform.up);
  33. }
  34. if(GodMode == true)
  35. {
  36. Instantiate(Explosion, transform.position, transform.rotation);
  37. ++GodModeCounter;
  38. if(GodModeCounter>5000)
  39. {
  40. GodMode = false;
  41. GodModeCounter = 0;
  42. }
  43. }
  44. }
  45.  
  46. void OnTriggerEnter(Collider colliderobject)
  47. {
  48. if(GodMode == false)
  49. {
  50. if(colliderobject.transform.tag.Equals("Asteroid"))
  51. {
  52. Destroy(gameObject);
  53. Instantiate(Explosion, transform.position, transform.rotation);
  54. GodMode = true;
  55. var spawner=GameObject.Find("SpaceshipSpawner");
  56. if(spawner != null)
  57. {
  58. spawner.GetComponent<SpaceshipSpawnBehaviour>().ShipSpawned=false;
  59. spawner.GetComponent<SpaceshipSpawnBehaviour>().Lives -= 1;
  60. }
  61. }
  62. }
  63. }
  64.  
  65. }
Add Comment
Please, Sign In to add comment