Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class OutsideRing : MonoBehaviour
  6. {
  7. // Start is called before the first frame update
  8. void Start()
  9. {
  10.  
  11. }
  12.  
  13. // Update is called once per frame
  14. void Update()
  15. {
  16.  
  17. }
  18.  
  19. void OnTriggerExit2D(Collider2D col)
  20. {
  21. if (col.tag == "Player")
  22. {
  23. col.GetComponent<SumoMovement>().LoseLife();
  24. }
  25. }
  26. }
  27. --------------------------------------------------------------------------------------------------------------------------------
  28. using System.Collections;
  29. using System.Collections.Generic;
  30. using UnityEngine;
  31.  
  32. public class SumoGameMaster : MonoBehaviour
  33. {
  34. public Transform[] positions = new Transform[8];
  35. public GameObject spawnPositionParent;
  36.  
  37. // Start is called before the first frame update
  38. void Start()
  39. {
  40. FindPlayerSpawnPositions();
  41. SpawnPlayers();
  42. }
  43.  
  44. // Update is called once per frame
  45. void Update()
  46. {
  47.  
  48. }
  49.  
  50. void FindPlayerSpawnPositions()
  51. {
  52. positions = spawnPositionParent.GetComponentsInChildren<Transform>();
  53. }
  54.  
  55. void SpawnPlayers()
  56. {
  57.  
  58. }
  59. }
  60. ----------------------------------------------------------------------------------------------------------------------------------
  61. using System.Collections;
  62. using System.Collections.Generic;
  63. using UnityEngine;
  64.  
  65. public class SumoMovement : MonoBehaviour
  66. {
  67. public int speedMultiplier = 2;
  68. public int lives = 2;
  69. public float stoppingLimit = 0.1f;
  70. Vector2 OGmousePos;
  71. Vector2 FmousePos;
  72. Vector2 movenow;
  73. Rigidbody2D rb;
  74.  
  75. // Start is called before the first frame update
  76. void Start()
  77. {
  78. rb = gameObject.GetComponent<Rigidbody2D>();
  79. }
  80.  
  81. // Update is called once per frame
  82. void FixedUpdate()
  83. {
  84. if ((rb.velocity.x < stoppingLimit) && (rb.velocity.y < stoppingLimit))
  85. {
  86. if (Input.GetMouseButtonDown(0))
  87. {
  88. OGmousePos = (Input.mousePosition);
  89. FmousePos = new Vector2(0, 0); //if bros moving to center, its because the final mouse position is set to 0,0.
  90. }
  91. else if (Input.GetMouseButtonUp(0))
  92. {
  93. FmousePos = (Input.mousePosition);
  94. movenow = (FmousePos - OGmousePos);
  95. rb.AddForce(movenow * speedMultiplier);
  96. }
  97. }
  98.  
  99. }
  100.  
  101. public void LoseLife()
  102. {
  103. lives = (lives - 1);
  104. rb.velocity = Vector2.zero;
  105. gameObject.transform.position = new Vector3(0, 0, 0);
  106. if (lives == 0)
  107. {
  108. print("Game Over");
  109. }
  110. }
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement