Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class PlayerController: MonoBehaviour {
- public int Medicine;
- public int HP;
- [SerializeField] Text HPText;
- [SerializeField] GameObject bullet;
- [SerializeField] GameObject rifleStart;
- [SerializeField] Text MedicineText;
- [SerializeField] GameObject GameOver;
- private LineRenderer Laser;
- // Start is called before the first frame update
- void Start() {
- HP = 100;
- if (HP <= 0) {
- GameOver.SetActive(true);
- GetComponent < PlayerLook > ().enabled = false;
- Cursor.lockState = CursorLockMode.None;
- }
- Medicine = 1;
- }
- public void ChangeMedicine(int count) {
- Medicine += count;
- if (Medicine <= 0) {
- Medicine = 0;
- }
- }
- public void ChangeHealth(int count) {
- HP += count;
- if (HP <= 0) {
- GameOver.SetActive(true);
- GetComponent < PlayerLook > ().enabled = false;
- Cursor.lockState = CursorLockMode.None;
- HP = 0;
- }
- if (HP > 100)
- HP = 100;
- }
- public void OnTriggerEnter(Collider collider) {
- if (collider.tag == "Killer")
- ChangeHealth(-20);
- Destroy(collider.gameObject);
- if (collider.tag == "tomato")
- ChangeHealth(+20);
- Destroy(collider.gameObject);
- }
- void Update() {
- HPText.text = HP.ToString();
- MedicineText.text = Medicine.ToString();
- if (Input.GetMouseButtonDown(0)) {
- // GameObject buf = Instantiate(bullet);
- GameObject buf = Instantiate(bullet, rifleStart.transform.position, rifleStart.transform.rotation);
- // buf.transform.position = rifleStart.transform.position;
- buf.GetComponent < Bullet > ().setDirection(transform.forward);
- Debug.Log("Fire!");
- // buf.transform.rotation = transform.rotation;
- }
- }
- }
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class PlayerController: MonoBehaviour {
- public int Medicine;
- public int HP;
- [SerializeField] Text HPText;
- [SerializeField] GameObject bullet;
- [SerializeField] GameObject rifleStart;
- [SerializeField] Text MedicineText;
- [SerializeField] GameObject GameOver;
- private LineRenderer Laser;
- // Start is called before the first frame update
- void Start() {
- HP = 100;
- if (HP <= 0) {
- GameOver.SetActive(true);
- GetComponent < PlayerLook > ().enabled = false;
- Cursor.lockState = CursorLockMode.None;
- }
- Medicine = 1;
- }
- public void ChangeMedicine(int count) {
- Medicine += count;
- if (Medicine <= 0) {
- Medicine = 0;
- }
- }
- public void ChangeHealth(int count) {
- HP += count;
- if (HP <= 0) {
- GameOver.SetActive(true);
- GetComponent < PlayerLook > ().enabled = false;
- Cursor.lockState = CursorLockMode.None;
- HP = 0;
- }
- if (HP > 100)
- HP = 100;
- }
- public void OnTriggerEnter(Collider collider) {
- if (collider.tag == "Killer")
- ChangeHealth(-20);
- Destroy(collider.gameObject);
- if (collider.tag == "tomato")
- ChangeHealth(+20);
- Destroy(collider.gameObject);
- }
- void Update() {
- HPText.text = HP.ToString();
- MedicineText.text = Medicine.ToString();
- if (Input.GetMouseButtonDown(0)) {
- // GameObject buf = Instantiate(bullet);
- GameObject buf = Instantiate(bullet, rifleStart.transform.position, rifleStart.transform.rotation);
- // buf.transform.position = rifleStart.transform.position;
- buf.GetComponent < Bullet > ().setDirection(transform.forward);
- Debug.Log("Fire!");
- // buf.transform.rotation = transform.rotation;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement