private void SpawnObjectInWireSlot(WireSlot wireSlot, GameObject wirePrefab) { var wireGO = Instantiate(wirePrefab) as GameObject; wireGO.transform.parent = wireRoots[wireSlot.index]; wireGO.transform.localPosition = Vector3.zero; wireGO.transform.localRotation = Quaternion.identity; wireGO.GetComponent <WireColorizer>()?.SetWireColor(wireSlot.wire); foreach (var cc in wireGO.GetComponentsInChildren <WireColorizer>()) { cc.SetWireColor(wireSlot.wire); } }
void RegenerateWireSlots() { if (wireSlots != null) { foreach (var slot in wireSlots) { DeleteWireVisuals(slot.index); } } wireSlots = new WireSlot[3]; for (var i = 0; i < 3; i++) { wireSlots[i] = new WireSlot(Utility.GetRandomWire(), i); RegenerateSingleWireVisuals(wireSlots[i]); } }
void RegenerateSingleWireVisuals(WireSlot wireSlot) { DeleteWireVisuals(wireSlot.index); if (currentDamageState == DamageState.Operational) { SpawnObjectInWireSlot(wireSlot, ObjectManager.Instance.WireSpawner.wirePrefabInSituFull); } if (currentDamageState == DamageState.Destroyed) { SpawnObjectInWireSlot(wireSlot, ObjectManager.Instance.WireSpawner.wirePrefabInSituDestroyed); } if (currentDamageState == DamageState.Malfunction) { SpawnObjectInWireSlot(wireSlot, wireSlot.occupied ? ObjectManager.Instance.WireSpawner.wirePrefabInSituFull : ObjectManager.Instance.WireSpawner.wirePrefabInSituMalfunction); } }