BlueGit

blue-star ggj-2020

Files

ggj-2020 / Assets / GAME / Scripts / Components / LightComponent.cs

LightComponent.cs

New modules, fancy effects
timfa Tim Falken · pushed by timfa · 6 years ago
be3de6c4 History
LightComponent.cs 723 B Download Raw
1using System.Collections;
2using System.Collections.Generic;
3using UnityEngine;
4
5public class LightComponent : Connectable
6{
7 [SerializeField] private Material offMat, onMat;
8 [SerializeField] private Renderer lightRenderer;
9 public bool LightOn { get; private set; }
10
11 public override void OnConnect()
12 {
13 base.OnConnect();
14 }
15
16 public override void OnDisconnect()
17 {
18 base.OnDisconnect();
19 TurnOff();
20 }
21
22 public void TurnOff()
23 {
24 lightRenderer.material = offMat;
25 LightOn = false;
26 }
27
28 public void TurnOn(Color color)
29 {
30 lightRenderer.material = onMat;
31 lightRenderer.material.color = color;
32
33 LightOn = true;
34 }
35}