Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class AK : MonoBehaviour {
- public Bala bala;
- public Transform cano;
- public int quantidadebala = 15 ;
- public int municao = 64 ;
- private int iniciodebalas;
- public ParticleSystem fireparticle;
- public GameObject audiotiro;
- public GameObject reloadaudio;
- public Font font;
- public GUISkin skin;
- public Transform troca;
- public float fireBate = 0.01f;
- private float currentTimeToFire =0;
- private float delay;
- private float acumuladorTempo;
- public AnimationClip akatirando;
- public AnimationClip Take ;
- public Animation animationak;
- private bool flagAnimacao;
- void Start (){
- iniciodebalas = quantidadebala;
- Time.timeScale = 1.0F;
- Time.fixedDeltaTime = 2*Time.timeScale/100;
- delay = 1.10f;
- //delay = 100* Time.fixedDeltaTime;
- acumuladorTempo=0;
- flagAnimacao=false;
- }
- void Update () {
- if ((Input.GetButton ("Fire1") && quantidadebala > 0)&&(flagAnimacao==false)) {
- audiotiro.audio.Play ();
- fireparticle.Emit (1);
- animation.clip = akatirando;
- animationak.Play ();
- Instantiate (bala, cano.position, cano.rotation);
- quantidadebala--;
- }
- // animaçao
- if ((Input.GetKeyDown (KeyCode.R) && municao > 0) &&(flagAnimacao==false)) {//acho q aki seria um: OU munição==0
- reloadaudio.audio.Play ();
- animation.clip = Take; // aniamçao
- animationak.Play ();
- if (municao > 0){
- municao--;
- if (quantidadebala <= iniciodebalas) {
- int tempobalas = iniciodebalas - quantidadebala;
- if(tempobalas >= municao)
- tempobalas = municao;
- quantidadebala += tempobalas;
- municao -= tempobalas;
- }
- }
- acumuladorTempo=0;
- flagAnimacao=true;
- }
- if(flagAnimacao==true){
- acumuladorTempo+=Time.fixedDeltaTime;
- }
- if(acumuladorTempo>=delay){
- flagAnimacao=false;
- }
- }
- void OnGUI() {
- GUI.skin.font = font;
- GUI.skin = skin;
- GUI.Label(new Rect(990, 420, 1000, 500), quantidadebala+"/" +municao);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement