Guest User

Untitled

a guest
Jan 7th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class BirdController : MonoBehaviour {
  6.  
  7. public int score = 0;
  8.  
  9. private Rigidbody2D bird;
  10. private AudioSource[] sounds;
  11. private AudioSource hit;
  12. private AudioSource wings;
  13. private GameOver game;
  14.  
  15.  
  16. void Start ()
  17. {
  18. bird = GetComponent<Rigidbody2D>();
  19. sounds = GameObject.FindGameObjectWithTag("Music").GetComponents<AudioSource>();
  20. game = GetComponent<GameOver>();
  21. wings = sounds[1];
  22. hit = sounds[3];
  23. }
  24.  
  25. void Update ()
  26. {
  27. if(Input.GetMouseButtonDown(0))
  28. {
  29. bird.velocity = new Vector2(0, 5);
  30. wings.Play();
  31. }
  32. }
  33.  
  34. private void OnTriggerEnter2D(Collider2D collision)
  35. {
  36. if (collision.gameObject.tag == "Pipe" || collision.gameObject.tag == "Ground")
  37. {
  38. hit.Play();
  39. game.IsOver();
  40. Destroy(gameObject);
  41. }
  42. }
  43.  
  44. public void AddScore()
  45. {
  46. score += 1;
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment