Advertisement
Guest User

Untitled

a guest
Jul 30th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Collections;
  4.  
  5. public class StrzelanieGracza : MonoBehaviour {
  6. public GameObject Pocisk;
  7. public Transform Lufa;
  8. public float CoIleMoznaStrzelac;
  9. public float Wyrzut;
  10. public int AktAmmo;
  11. public int MaxAmmo;
  12. public int KosztAmmo;
  13. public Text LicznikAmmo;
  14.  
  15. // Use this for initialization
  16. void Start () {
  17.  
  18. }
  19.  
  20. // Update is called once per frame
  21. void Update () {
  22.  
  23. LicznikAmmo.text = AktAmmo.ToString() +"/"+ MaxAmmo.ToString();
  24.  
  25. if (AktAmmo > 0) {
  26. if (Input.GetMouseButtonDown (0)) {
  27. GameObject nowyPocisk1 = Instantiate (Pocisk, Lufa.position, Lufa.rotation) as GameObject;
  28. nowyPocisk1.GetComponent<Rigidbody> ().velocity = Lufa.forward * Wyrzut * Time.deltaTime;
  29. ZmianaAmmo( - KosztAmmo);
  30. }
  31.  
  32. }
  33. }
  34. void ZmianaAmmo(int Ammo){
  35. AktAmmo += Ammo;
  36.  
  37. if(AktAmmo > MaxAmmo)
  38. AktAmmo = MaxAmmo;
  39.  
  40. if(AktAmmo < 0)
  41. AktAmmo = 0;
  42. }
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement