Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class BreakableBlock : MonoBehaviour
  6. {
  7. int blockLives = 3;
  8. //public Sprite blockStateB;
  9. //public Sprite blockStateC;
  10.  
  11. // Start is called before the first frame update
  12. void Start()
  13. {
  14.  
  15. }
  16.  
  17. // Update is called once per frame
  18. void Update()
  19. {
  20. if(blockLives == 2)
  21. {
  22. //GetComponent(SpriteRenderer).sprite
  23. }
  24.  
  25. if (blockLives == 1)
  26. {
  27. //GetComponent(SpriteRenderer).sprite
  28. }
  29.  
  30. if (blockLives == 0)
  31. {
  32. Destroy(gameObject);
  33. }
  34. }
  35.  
  36. private void OnCollisionEnter2D(Collision2D collision)
  37. {
  38. blockLives = blockLives - 1;
  39. }
  40. }
  41.  
  42.  
  43. using System.Collections;
  44. using System.Collections.Generic;
  45. using UnityEngine;
  46.  
  47. public class MovementStart : MonoBehaviour
  48. {
  49. public Vector3 startBoost = new Vector3(0.0f, 0.0f, 0.0f);
  50. bool notMoving = true;
  51. int ballLives = 3;
  52.  
  53. // Start is called before the first frame update
  54. void Start()
  55. {
  56.  
  57. }
  58.  
  59. // Update is called once per frame
  60. void Update()
  61. {
  62. if (notMoving == true)
  63. {
  64. GetComponent<Rigidbody2D>().AddForce(startBoost, ForceMode2D.Impulse);
  65. notMoving = false;
  66. }
  67.  
  68. if (transform.position.y <= 0)
  69. {
  70. ballLives = ballLives - 1;
  71. transform.position = new Vector3 (9.16f, 7.57f, 0);
  72. GetComponent<Rigidbody2D>().velocity = Vector3.zero;
  73. notMoving = true;
  74. }
  75.  
  76. if (ballLives == 0)
  77. {
  78. //find a way to load the game over scene;
  79. //SceneLoader.LoadGameOverScene();
  80. }
  81. }
  82. }
  83.  
  84. using System.Collections;
  85. using System.Collections.Generic;
  86. using UnityEngine;
  87.  
  88. public class PaddleMovement : MonoBehaviour
  89. {
  90.  
  91. float paddleSpeed = 7.0f;
  92.  
  93. // Start is called before the first frame update
  94. void Start()
  95. {
  96.  
  97. }
  98.  
  99. // Update is called once per frame
  100. void Update()
  101. {
  102. if (Input.GetKey(KeyCode.RightArrow))
  103. {
  104. transform.Translate(Vector3.right * Time.deltaTime * paddleSpeed);
  105. }
  106.  
  107. if (Input.GetKey(KeyCode.LeftArrow))
  108. {
  109. transform.Translate(Vector3.left * Time.deltaTime * paddleSpeed);
  110. }
  111. }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement