Advertisement
Guest User

Untitled

a guest
May 16th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class HPandPoints : MonoBehaviour
  6. {
  7. public float HP;
  8. public float Points;
  9. private float _Damage=0f;
  10. private GameObject Camera;
  11. public delegate void DelegateScoreManager(float points);
  12. public event DelegateScoreManager SumScore;
  13. public delegate void DelegateBonusManager();
  14.  
  15. void Start()
  16. {
  17. if(CompareTag("50points"))
  18. {
  19. HP = 3f;
  20. Points = 50f;
  21. }
  22. if (CompareTag("20points"))
  23. {
  24. HP = 2f;
  25. Points = 20f;
  26. }
  27. if (CompareTag("10points"))
  28. {
  29. HP = 1f;
  30. Points = 10f;
  31. }
  32. Camera = GameObject.FindGameObjectWithTag("MainCamera");
  33. SumScore += Camera.GetComponent<ScoreManager>().SumScores;
  34.  
  35. }
  36. private void OnCollisionEnter2D(Collision2D collision)
  37. {
  38. if (collision.gameObject.tag=="Ball")
  39. {
  40. _Damage ++;
  41. if (_Damage == HP)
  42. {
  43. SumScore(Points);
  44. Destroy(gameObject);
  45. }
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement