Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class OutsideRing : MonoBehaviour
- {
- // Start is called before the first frame update
- void Start()
- {
- }
- // Update is called once per frame
- void Update()
- {
- }
- void OnTriggerExit2D(Collider2D col)
- {
- if (col.tag == "Player")
- {
- col.GetComponent<SumoMovement>().LoseLife();
- }
- }
- }
- --------------------------------------------------------------------------------------------------------------------------------
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class SumoGameMaster : MonoBehaviour
- {
- public Transform[] positions = new Transform[8];
- public GameObject spawnPositionParent;
- // Start is called before the first frame update
- void Start()
- {
- FindPlayerSpawnPositions();
- SpawnPlayers();
- }
- // Update is called once per frame
- void Update()
- {
- }
- void FindPlayerSpawnPositions()
- {
- positions = spawnPositionParent.GetComponentsInChildren<Transform>();
- }
- void SpawnPlayers()
- {
- }
- }
- ----------------------------------------------------------------------------------------------------------------------------------
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class SumoMovement : MonoBehaviour
- {
- public int speedMultiplier = 2;
- public int lives = 2;
- public float stoppingLimit = 0.1f;
- Vector2 OGmousePos;
- Vector2 FmousePos;
- Vector2 movenow;
- Rigidbody2D rb;
- // Start is called before the first frame update
- void Start()
- {
- rb = gameObject.GetComponent<Rigidbody2D>();
- }
- // Update is called once per frame
- void FixedUpdate()
- {
- if ((rb.velocity.x < stoppingLimit) && (rb.velocity.y < stoppingLimit))
- {
- if (Input.GetMouseButtonDown(0))
- {
- OGmousePos = (Input.mousePosition);
- FmousePos = new Vector2(0, 0); //if bros moving to center, its because the final mouse position is set to 0,0.
- }
- else if (Input.GetMouseButtonUp(0))
- {
- FmousePos = (Input.mousePosition);
- movenow = (FmousePos - OGmousePos);
- rb.AddForce(movenow * speedMultiplier);
- }
- }
- }
- public void LoseLife()
- {
- lives = (lives - 1);
- rb.velocity = Vector2.zero;
- gameObject.transform.position = new Vector3(0, 0, 0);
- if (lives == 0)
- {
- print("Game Over");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement