-
Notifications
You must be signed in to change notification settings - Fork 0
/
LightScript
153 lines (137 loc) · 3.65 KB
/
LightScript
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Experimental.Rendering.LWRP;
public class LightScript : MonoBehaviour
{
//De tre lys der styres gennem scriptet:
public UnityEngine.Experimental.Rendering.Universal.Light2D global;
public UnityEngine.Experimental.Rendering.Universal.Light2D local;
public UnityEngine.Experimental.Rendering.Universal.Light2D bossLight;
public movementController mC;
public sceneTransitionScript sT;
public Color bossLight1;
public Color bossLight2;
float GstandardInt = 0.4f;
float LstandardInt = 0;
float Gchange;
float Lchange;
float Gbit;
float Lbit;
float GchangeSpeed = 0.001f;
float LchangeSpeed = 0.01f;
//Levelindex
int start = 0;
int level1 = 1;
int steal = 2;
int level2 = 3;
int level3 = 4;
int change = 5;
bool waterLight;
public int changeState;
// Start is called before the first frame update
void Start()
{
global.intensity = GstandardInt;
local.intensity = LstandardInt;
}
// Update is called once per frame
void Update()
{
//Det bliver her tjekket hvor i levelet man er, og lyset ændrer sig ud fra det
if (mC.inPool)
{
global.enabled = false;
local.enabled = true;
Gchange = 0;
Lchange = 1.5f;
}
else if (sT.stage == start)
{
if(changeState == 0)
{
global.enabled = true;
local.enabled = false;
Gchange = 0f;
Lchange = 0;
bossLight.color = bossLight1;
}
if(changeState == 1)
{
global.enabled = true;
local.enabled = false;
Gchange = 0.4f;
Lchange = 0;
bossLight.color = bossLight2;
}
}
else if (sT.stage == level1)
{
global.enabled = true;
local.enabled = true;
Gchange = 0;
Lchange = 1;
}
else if (sT.stage == level2)
{
global.enabled = true;
local.enabled = true;
Gchange = 0;
Lchange = 1;
}
else if(sT.stage == level3)
{
global.enabled = true;
local.enabled = true;
Gchange = 0;
Lchange = 1;
}
else if(sT.stage == steal)
{
global.enabled = true;
local.enabled = true;
Gchange = 0;
Lchange = 1;
}
else if(sT.stage == change)
{
if(changeState == 0)
{
global.enabled = true;
local.enabled = false;
Gchange = 0.2f;
Lchange = 0;
}
if(changeState == 1)
{
global.enabled = true;
local.enabled = false;
Gchange = 0.6f;
Lchange = 0;
}
}
changeIntensity();
}
//Denne funktion er den der faktisk ændrer intesiteten af de lys der skal ændres
void changeIntensity()
{
if (Gbit < Gchange)
{
Gbit += GchangeSpeed;
}
if (Gbit > Gchange)
{
Gbit -= GchangeSpeed;
}
global.intensity = GstandardInt + Gbit;
if (Lbit < Lchange)
{
Lbit += LchangeSpeed;
}
if (Lbit > Lchange)
{
Lbit -= LchangeSpeed;
}
local.intensity = LstandardInt + Lbit;
}
}