-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimePressure.cs
More file actions
48 lines (42 loc) · 1.17 KB
/
TimePressure.cs
File metadata and controls
48 lines (42 loc) · 1.17 KB
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TimePressure : MonoBehaviour
{
// as time pressure decreases, filter on screen increases
// press pump button many times to increase pressure
float pressure = 400;
float MAX_PRESSURE = 500;
public Slider fill;
public Image filter;
CommandPrompt CP;
private void Start()
{
CP = FindObjectOfType<CommandPrompt>();
StartCoroutine(LeakPressure());
}
private void Update()
{
// filter on screen makes it hard to see
Color temp = filter.color;
filter.color = new Color(temp.r, temp.g, temp.b, (MAX_PRESSURE - pressure) / MAX_PRESSURE);
}
public void Pump()
{
if (pressure < MAX_PRESSURE)
{
pressure += 25;
fill.value = pressure / MAX_PRESSURE;
}
}
IEnumerator LeakPressure()
{
while (pressure > 0 && CP.running)
{
pressure--;
fill.value = pressure / MAX_PRESSURE;
yield return new WaitForSeconds(0.1f);
}
}
}