-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cook.cs
100 lines (71 loc) · 2.5 KB
/
Cook.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Cook : MonoBehaviour
{
public GameObject[] meals;
private int mealIndex = 0;
private int mealLength;
public GameObject openDoor;
public GameObject microwave;
public GameObject[] mealsPerfect;
public GameObject[] mealsDestroyed;
public GameObject[] mealsRaw;
public AudioSource sound;
public AudioSource start;
public AudioSource end;
public int[] mealTimeMin;
public int[] mealTimeMax;
private bool firstTimePressed = true;
public bool restart;
public bool stop;
public int time;
void Start()
{
mealLength = meals.Length;
sound = GetComponent<AudioSource>();
}
void Update()
{
}
public void StartCooking() {
if (firstTimePressed) {
start.Play();
sound.Play();
restart = true;
stop = false;
openDoor.SetActive(false);
microwave.SetActive(true);
firstTimePressed = false;
Debug.Log("aaa");
meals[mealIndex].SetActive(false);
var trans = 0.5f;
var col = meals[mealIndex].GetComponent<Renderer>().material.color;
col.a = trans;
mealsDestroyed[mealIndex].SetActive(false);
mealsRaw[mealIndex].SetActive(false);
mealsPerfect[mealIndex].SetActive(false);
} else if (!firstTimePressed) {
sound.Stop();
end.Play();
time = GetComponent<Timer>().seconds + 60 * GetComponent<Timer>().minutes;
openDoor.SetActive(true);
microwave.SetActive(false);
firstTimePressed = true;
if (time >= mealTimeMax[mealIndex]) {
meals[mealIndex].SetActive(false);
mealsDestroyed[mealIndex].SetActive(true);
Debug.Log("overcooked");
} else if (time >= mealTimeMin[mealIndex] && time <= mealTimeMax[mealIndex]) {
meals[mealIndex].SetActive(false);
mealsPerfect[mealIndex].SetActive(true);
Debug.Log("perf");
} else if (time <= mealTimeMin[mealIndex]) {
meals[mealIndex].SetActive(false);
mealsRaw[mealIndex].SetActive(true);
Debug.Log("raw");
}
stop = true;
}
}
}