Advertisement
Guest User

Untitled

a guest
Jun 30th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class EnemyHealthP : MonoBehaviour {
  5.  
  6. public float enemyHP;
  7. public bool dead = false;
  8. private Transform myTransform;
  9. public Transform exploded;
  10. public int pointsGain;
  11. public int upgradePointsGain;
  12. public bool infectOnp = false;
  13. public bool reverseInfection = false;
  14. public bool painingInfected = false;
  15. public Transform self;
  16. public int cubixexpgain = 10;
  17.  
  18. void Awake(){
  19. myTransform = transform;
  20. }
  21.  
  22. void Update(){
  23. if(enemyHP <= 0 && !dead){
  24. Destroy(self.gameObject);
  25. Transform explosion = Instantiate (exploded, myTransform.position, myTransform.rotation) as Transform;
  26. ScreenHUD.score += pointsGain;
  27. ScreenHUD.overallScore += pointsGain;
  28. UpgradeWindow.upgradePoints += upgradePointsGain;
  29. Cubix cubix = new Cubix();
  30. cubix.Cubixexp += cubixexpgain;
  31. dead = true;
  32.  
  33.  
  34. }
  35. }
  36.  
  37. void OnDestroy(){
  38. if(infectOnp){
  39. PlayerMoveM2.mdown = 6700;
  40. PlayerMoveM2.mup = 6700;
  41. PlayerMoveM2.mright = 11700;
  42. PlayerMoveM2.mleft = 10700;
  43. }
  44. if(reverseInfection){
  45. PlayerMoveM2.mdown = 6700;
  46. PlayerMoveM2.mup = 6700;
  47. PlayerMoveM2.mright = 11700;
  48. PlayerMoveM2.mleft = 10700;
  49. }
  50. if(painingInfected){
  51. PlayerMoveM2.pain = false;
  52. }
  53. }
  54.  
  55. void OnCollisionEnter(Collision other){
  56. Vector3 screenPos = Camera.main.WorldToScreenPoint (myTransform.position);
  57.  
  58. if (screenPos.x < Screen.width) {
  59. if(Application.loadedLevel == 0 || Application.loadedLevel == 1){
  60. if(other.gameObject.tag == "Bullet"){
  61. enemyHP -= 5;
  62. }
  63. }
  64. if(Application.loadedLevel == 2 || Application.loadedLevel == 3 || Application.loadedLevel == 4 || Application.loadedLevel == 5 || Application.loadedLevel == 6){
  65. if(other.gameObject.tag == "Bullet"){
  66. enemyHP -= 3.8f;
  67. }
  68. }
  69. if(Application.loadedLevel == 7 || Application.loadedLevel == 8 || Application.loadedLevel == 9){
  70. if(other.gameObject.tag == "Bullet"){
  71. enemyHP -= 3f;
  72. }
  73. }
  74. }
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement