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.Networking;
- using UnityEngine.UI;
- [RequireComponent(typeof(AudioSource))]
- public class Strzelanie : NetworkBehaviour {
- public ParticleSystem muzzle;
- public RaycastHit hit;
- public Transform Kamera;
- public AudioClip shoot;
- public AudioSource src;
- public int ammoAll =500;
- public int ammoMag = 100;
- int ammoLoaded =100;
- int ammoNeeded;
- public Text amunicja;
- int hp =100;
- Strzelanie sc;
- // Use this for initialization
- void Start ()
- {
- ammoMag = 100;
- ammoLoaded = 100;
- ammoAll = 500;
- amunicja.text = +ammoLoaded + "/" + ammoAll;
- }
- // Update is called once per frame
- void Update () {
- if (!isLocalPlayer)
- {
- return;
- }
- ammoNeeded = ammoMag - ammoLoaded;
- amunicja.text= +ammoLoaded +"/" + ammoAll;
- if (Input.GetMouseButton(0) && isLocalPlayer && ammoLoaded>0)
- {
- muzzle.Play(true);
- src.PlayScheduled(10);
- ammoLoaded = ammoLoaded-1;
- if (Physics.Raycast(Kamera.position, Kamera.forward, out hit , 3000))
- {
- if(hit.collider.gameObject.tag=="Player")
- {
- sc = hit.collider.GetComponent<Strzelanie>();
- sc.hp = sc.hp - 10;
- }
- }
- }
- if(Input.GetKeyDown(KeyCode.R) && isLocalPlayer && ammoAll>0)
- {
- gameObject.GetComponent<Animation>().Play("reload");
- ammoLoaded = ammoLoaded + ammoNeeded;
- ammoAll = ammoAll - ammoNeeded;
- }
- if(hp==0 && isLocalPlayer)
- {
- Debug.Log("Die");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement