Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using UnityEngine.UI;
- public abstract class CookerBase : MonoBehaviour {
- RayCamera RC;
- GameController GM;
- bool startToMakeFood = false;
- float timer;
- bool foodEnded;
- public float timeToPrepare = 60;
- public int recompense;
- public ParticleSystem[] fire;
- Touch[] phases;
- int amountTouches = 0;
- float timerTouch;
- GameObject itemClick = null;
- void Start ()
- {
- RC = FindObjectOfType(typeof(RayCamera)) as RayCamera;
- GM = FindObjectOfType(typeof(GameController)) as GameController;
- }
- void Update ()
- {
- phases = Input.touches;
- timerTouch += Time.deltaTime;
- if (RC.collision && RC.hit.collider.gameObject.tag == "Object" && !startToMakeFood)
- {
- itemClick = RC.hit.collider.gameObject;
- if (phases.Length > 0 && phases[0].phase == TouchPhase.Ended || Input.GetKeyDown(KeyCode.C))
- {
- amountTouches++;
- if (amountTouches == 1)
- timerTouch = 0;
- if (amountTouches > 1 && timerTouch > 1)
- amountTouches = 0;
- if (amountTouches == 2 && timerTouch <= 1)
- {
- startToMakeFood = true;
- foodEnded = false;
- for (int i = 0; i < fire.Length; i++)
- {
- fire[i].Play();
- }
- amountTouches = 0;
- }
- }
- }
- switch (startToMakeFood)
- {
- case true: //COZINHANDO
- timer += Time.deltaTime;
- if (timer >= timeToPrepare) //QUANDO TERMINA DE FAZER A COMIDA
- {
- startToMakeFood = false;
- timer = 0;
- foodEnded = true;
- GM.currentMoney += recompense;
- }
- break;
- case false: //NΓO COZINHANDO
- for (int i = 0; i < fire.Length; i++)
- {
- fire[i].Stop();
- }
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement