Advertisement
Guest User

Untitled

a guest
Sep 19th, 2014
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class AK : MonoBehaviour {
  5. public Bala bala;
  6. public Transform cano;
  7. public int quantidadebala = 15 ;
  8. public int municao = 64 ;
  9. private int iniciodebalas;
  10. public ParticleSystem fireparticle;
  11. public GameObject audiotiro;
  12. public GameObject reloadaudio;
  13. public Font font;
  14. public GUISkin skin;
  15. public Transform troca;
  16.  
  17.  
  18. public float fireBate = 0.01f;
  19. private float currentTimeToFire =0;
  20. private float delay;
  21. private float acumuladorTempo;
  22. public AnimationClip akatirando;
  23. public AnimationClip Take ;
  24. public Animation animationak;
  25. private bool flagAnimacao;
  26.  
  27.  
  28.  
  29.  
  30. void Start (){
  31. iniciodebalas = quantidadebala;
  32. Time.timeScale = 1.0F;
  33. Time.fixedDeltaTime = 2*Time.timeScale/100;
  34. delay = 1.10f;
  35. //delay = 100* Time.fixedDeltaTime;
  36. acumuladorTempo=0;
  37. flagAnimacao=false;
  38. }
  39.  
  40.  
  41. void Update () {
  42. if ((Input.GetButton ("Fire1") && quantidadebala > 0)&&(flagAnimacao==false)) {
  43.  
  44. audiotiro.audio.Play ();
  45. fireparticle.Emit (1);
  46.  
  47. animation.clip = akatirando;
  48. animationak.Play ();
  49. Instantiate (bala, cano.position, cano.rotation);
  50. quantidadebala--;
  51. }
  52.  
  53. // animaçao
  54. if ((Input.GetKeyDown (KeyCode.R) && municao > 0) &&(flagAnimacao==false)) {//acho q aki seria um: OU munição==0
  55. reloadaudio.audio.Play ();
  56. animation.clip = Take; // aniamçao
  57. animationak.Play ();
  58. if (municao > 0){
  59. municao--;
  60. if (quantidadebala <= iniciodebalas) {
  61. int tempobalas = iniciodebalas - quantidadebala;
  62. if(tempobalas >= municao)
  63. tempobalas = municao;
  64. quantidadebala += tempobalas;
  65. municao -= tempobalas;
  66.  
  67. }
  68.  
  69. }
  70. acumuladorTempo=0;
  71. flagAnimacao=true;
  72. }
  73.  
  74. if(flagAnimacao==true){
  75. acumuladorTempo+=Time.fixedDeltaTime;
  76. }
  77.  
  78. if(acumuladorTempo>=delay){
  79. flagAnimacao=false;
  80. }
  81.  
  82.  
  83.  
  84.  
  85. }
  86.  
  87.  
  88.  
  89.  
  90.  
  91. void OnGUI() {
  92. GUI.skin.font = font;
  93. GUI.skin = skin;
  94. GUI.Label(new Rect(990, 420, 1000, 500), quantidadebala+"/" +municao);
  95. }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement