Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEngine.UI;
- using System.Collections;
- public class StrzelanieGracza : MonoBehaviour {
- public GameObject Pocisk;
- public Transform Lufa;
- public float CoIleMoznaStrzelac;
- public float Wyrzut;
- public int AktAmmo;
- public int MaxAmmo;
- public int KosztAmmo;
- public Text LicznikAmmo;
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update () {
- LicznikAmmo.text = AktAmmo.ToString() +"/"+ MaxAmmo.ToString();
- if (AktAmmo > 0) {
- if (Input.GetMouseButtonDown (0)) {
- GameObject nowyPocisk1 = Instantiate (Pocisk, Lufa.position, Lufa.rotation) as GameObject;
- nowyPocisk1.GetComponent<Rigidbody> ().velocity = Lufa.forward * Wyrzut * Time.deltaTime;
- ZmianaAmmo( - KosztAmmo);
- }
- }
- }
- void ZmianaAmmo(int Ammo){
- AktAmmo += Ammo;
- if(AktAmmo > MaxAmmo)
- AktAmmo = MaxAmmo;
- if(AktAmmo < 0)
- AktAmmo = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement