-
Notifications
You must be signed in to change notification settings - Fork 2
/
Wall.cs
43 lines (34 loc) · 1.01 KB
/
Wall.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
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class Wall : MonoBehaviour
{
protected float fadeDuration = 2;
private float timer = 0;
public static bool disableCollider;
void Start ()
{
disableCollider = false;
}
protected void Update ()
{
// Fade the walls from red to white gradually over fadeDuration.
Color change = this.GetComponent<SpriteRenderer>().material.color;
change.a = 1 - timer;
this.GetComponent<SpriteRenderer>().material.color = change;
if (timer < 1) {
timer += Time.deltaTime / fadeDuration;
}
// Light up the walls and reduce the player's power.
if (Input.GetKey (KeyCode.Space) && Global.GetPower() > 0) {
Color changeColor = this.GetComponent<SpriteRenderer> ().color;
changeColor.a = 1.0f;
this.GetComponent<SpriteRenderer>().material.color = changeColor;
Global.MinusPower(Time.deltaTime);
}
}
public void AddDuration ()
{
timer -= 0.6f;
}
}