Advertisement
GabrielRabeloLopes

Cozinhar

Dec 6th, 2015
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.UI;
  4.  
  5. public abstract class CookerBase : MonoBehaviour {
  6. RayCamera RC;
  7. GameController GM;
  8.  
  9. bool startToMakeFood = false;
  10. float timer;
  11. bool foodEnded;
  12.  
  13. public float timeToPrepare = 60;
  14. public int recompense;
  15. public ParticleSystem[] fire;
  16.  
  17. Touch[] phases;
  18. int amountTouches = 0;
  19. float timerTouch;
  20.  
  21. GameObject itemClick = null;
  22.  
  23. void Start ()
  24. {
  25. RC = FindObjectOfType(typeof(RayCamera)) as RayCamera;
  26. GM = FindObjectOfType(typeof(GameController)) as GameController;
  27. }
  28.  
  29. void Update ()
  30. {
  31. phases = Input.touches;
  32. timerTouch += Time.deltaTime;
  33. if (RC.collision && RC.hit.collider.gameObject.tag == "Object" && !startToMakeFood)
  34. {
  35. itemClick = RC.hit.collider.gameObject;
  36. if (phases.Length > 0 && phases[0].phase == TouchPhase.Ended || Input.GetKeyDown(KeyCode.C))
  37. {
  38. amountTouches++;
  39. if (amountTouches == 1)
  40. timerTouch = 0;
  41. if (amountTouches > 1 && timerTouch > 1)
  42. amountTouches = 0;
  43. if (amountTouches == 2 && timerTouch <= 1)
  44. {
  45. startToMakeFood = true;
  46. foodEnded = false;
  47. for (int i = 0; i < fire.Length; i++)
  48. {
  49. fire[i].Play();
  50. }
  51. amountTouches = 0;
  52. }
  53. }
  54. }
  55. switch (startToMakeFood)
  56. {
  57. case true: //COZINHANDO
  58. timer += Time.deltaTime;
  59. if (timer >= timeToPrepare) //QUANDO TERMINA DE FAZER A COMIDA
  60. {
  61. startToMakeFood = false;
  62. timer = 0;
  63. foodEnded = true;
  64. GM.currentMoney += recompense;
  65. }
  66. break;
  67.  
  68. case false: //NÃO COZINHANDO
  69. for (int i = 0; i < fire.Length; i++)
  70. {
  71. fire[i].Stop();
  72. }
  73. break;
  74. }
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement