BlueGit

blue-star ggj-2020

Files

ggj-2020 / Assets / GAME / Scripts / Modules / X9_T804.cs

X9_T804.cs

New modules, fancy effects
timfa Tim Falken · pushed by timfa · 6 years ago
be3de6c4 History
X9_T804.cs 2.2 KiB Download Raw
1using System.Collections;
2using System.Collections.Generic;
3using UnityEngine;
4
5public class X9_T804 : ModuleBase
6{
7 [SerializeField] private Connector lightConnector, switchConnector, wireConnectorA1, wireConnectorB1, wireConnectorA2, wireConnectorB2;
8 private bool buttonPressedCorrectly;
9
10 protected override bool TestCorrectness()
11 {
12 return buttonPressedCorrectly;
13 }
14
15 void Update()
16 {
17 if (switchConnector.Connected && switchConnector.Connected is FlipSwitch && ((FlipSwitch)switchConnector.Connected).IsFlipped)
18 {
19 bool ok = true;
20
21 if (lightConnector.Connected != null)
22 {
23 if (lightConnector.Connected is LightComponent)
24 {
25 //ok
26 }
27 else
28 {
29 ok = false;
30 }
31 }
32 else
33 {
34 ok = false;
35 }
36
37 if (wireConnectorA1.Connected != null)
38 {
39 if (wireConnectorA1.Connected is WireHead)
40 {
41 if (((WireHead)wireConnectorA1.Connected).MatchingWireHead != wireConnectorA2.Connected)
42 {
43 ok = false;
44 }
45 }
46 else
47 {
48 ok = false;
49 }
50 }
51 else
52 {
53 ok = false;
54 }
55
56 if (wireConnectorB1.Connected != null)
57 {
58 if (wireConnectorB1.Connected is WireHead)
59 {
60 if (((WireHead)wireConnectorB1.Connected).MatchingWireHead != wireConnectorB2.Connected)
61 {
62 ok = false;
63 }
64 }
65 else
66 {
67 ok = false;
68 }
69 }
70 else
71 {
72 ok = false;
73 }
74
75 buttonPressedCorrectly = ok;
76
77 if (ok)
78 ((LightComponent)lightConnector.Connected).TurnOn(Color.green);
79
80 if (!ok)
81 EjectComponents();
82 }
83 }
84}