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 Metal : MonoBehaviour
- {
- public GameObject sound;
- public GameObject black;
- public GameObject antiSound;
- public GameObject na;
- public GameObject parts;
- public GameObject bags;
- public GameObject seat;
- public GameObject Wheel;
- public GameObject shoes;
- public bool onBike;
- public bool canDiveBike;
- public float bikeStartTime = 10f;
- public float bikeTimer = 0;
- public int item;
- void Update()
- {
- if (onBike)
- {
- if (Input.GetKeyDown(KeyCode.E))
- {
- digBike();
- }
- }
- if (onBike && !canDiveBike)
- {
- antiSound.SetActive(true);
- }
- if (canDiveBike == false)
- {
- bikeTimer -= Time.deltaTime;
- Debug.Log(bikeTimer);
- if (bikeTimer <= 0)
- {
- canDiveBike = true;
- return;
- }
- sound.SetActive(false);
- }
- }
- void Start()
- {
- bikeTimer = bikeStartTime;
- canDiveBike = true;
- onBike = false;
- }
- void OnTriggerEnter(Collider other)
- {
- if (other.gameObject.tag == "stuffBike")
- {
- onBike = true;
- if (canDiveBike == true)
- {
- sound.SetActive(true);
- antiSound.SetActive(false);
- }
- else
- {
- sound.SetActive(false);
- }
- }
- }
- void OnTriggerStay(Collider other)
- {
- if (other.gameObject.tag == "stuffBike") {
- if (canDiveBike == true)
- {
- sound.SetActive(true);
- antiSound.SetActive(false);
- }
- }
- }
- void OnTriggerExit(Collider other)
- {
- if (other.gameObject.tag == "stuffBike")
- {
- StopAllCoroutines();
- antiSound.SetActive(false);
- sound.SetActive(false);
- black.SetActive(false);
- na.SetActive(false);
- parts.SetActive(false);
- bags.SetActive(false);
- seat.SetActive(false);
- Wheel.SetActive(false);
- shoes.SetActive(false);
- onBike = false;
- }
- }
- void digBike()
- {
- StartCoroutine(DigItBike());
- }
- IEnumerator DigItBike()
- {
- if (canDiveBike == true) {
- float time = 0;
- float randy = Random.Range(2.5f, 17.5f);
- while (time < randy)
- {
- black.SetActive(true);
- time += Time.deltaTime;
- yield return null;
- }
- if (randy < 5) {
- Debug.Log("Nothing");
- item = 0;
- PlayerPrefs.SetInt("points", PlayerPrefs.GetInt("points") + 0);
- }
- else if (randy < 7.5)
- {
- Debug.Log("Just some parts");
- PlayerPrefs.SetInt("parts", PlayerPrefs.GetInt("parts") + 1);
- item = 1;
- PlayerPrefs.SetInt("points", PlayerPrefs.GetInt("points") + 2);
- }
- else if (randy < 10)
- {
- Debug.Log("saddle bags");
- PlayerPrefs.SetInt("bags", PlayerPrefs.GetInt("bags") + 1);
- item = 2;
- PlayerPrefs.SetInt("points", PlayerPrefs.GetInt("points") + 5);
- }
- else if (randy < 12.5)
- {
- Debug.Log("Bike seat");
- PlayerPrefs.SetInt("seat", PlayerPrefs.GetInt("seat") + 1);
- item = 3;
- PlayerPrefs.SetInt("points", PlayerPrefs.GetInt("points") + 5);
- }
- else if (randy < 15)
- {
- Debug.Log("A Wheel");
- PlayerPrefs.SetInt("Wheel", PlayerPrefs.GetInt("Wheel") + 1);
- item = 4;
- PlayerPrefs.SetInt("points", PlayerPrefs.GetInt("points") + 5);
- }
- else if (randy < 17.5)
- {
- Debug.Log("Biking Shoes!");
- PlayerPrefs.SetInt("Shoes", PlayerPrefs.GetInt("Shoes") + 1);
- item = 5;
- PlayerPrefs.SetInt("points", PlayerPrefs.GetInt("points") + 5);
- }
- bikeTimer = bikeStartTime;
- canDiveBike = false;
- black.SetActive(false);
- StopAllCoroutines();
- StartCoroutine(bikeShowDig());
- }else{
- StopAllCoroutines();
- }
- }
- IEnumerator bikeShowDig()
- {
- float time1 = 0;
- float randy1 = 2.0f;
- while (time1 < randy1)
- {
- if (item == 0)
- {
- na.SetActive(true);
- parts.SetActive(false);
- bags.SetActive(false);
- seat.SetActive(false);
- Wheel.SetActive(false);
- shoes.SetActive(false);
- antiSound.SetActive(false);
- }
- else if (item == 1)
- {
- na.SetActive(false);
- parts.SetActive(true);
- bags.SetActive(false);
- seat.SetActive(false);
- Wheel.SetActive(false);
- shoes.SetActive(false);
- antiSound.SetActive(false);
- }
- else if (item == 2)
- {
- na.SetActive(false);
- parts.SetActive(false);
- bags.SetActive(true);
- seat.SetActive(false);
- Wheel.SetActive(false);
- shoes.SetActive(false);
- antiSound.SetActive(false);
- }
- else if (item == 3)
- {
- na.SetActive(false);
- parts.SetActive(false);
- bags.SetActive(false);
- seat.SetActive(true);
- Wheel.SetActive(false);
- shoes.SetActive(false);
- antiSound.SetActive(false);
- }
- else if (item == 4)
- {
- na.SetActive(false);
- parts.SetActive(false);
- bags.SetActive(false);
- seat.SetActive(false);
- Wheel.SetActive(true);
- shoes.SetActive(false);
- antiSound.SetActive(false);
- }
- else if (item == 5)
- {
- na.SetActive(false);
- parts.SetActive(false);
- bags.SetActive(false);
- seat.SetActive(false);
- Wheel.SetActive(false);
- shoes.SetActive(true);
- antiSound.SetActive(false);
- }
- time1 += Time.deltaTime;
- yield return null;
- }
- na.SetActive(false);
- parts.SetActive(false);
- bags.SetActive(false);
- seat.SetActive(false);
- Wheel.SetActive(false);
- shoes.SetActive(false);
- antiSound.SetActive(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement