void ChargePropagation() { OpticalFiber_Node n = nodes[0].GetComponent <OpticalFiber_Node>(); CableSetup c = cables[0].GetComponent <CableSetup>(); c.charge += (n.charge - c.charge) * propagationRate; for (int i = 1; i < nodes.Length; i++) { c = cables[i - 1].GetComponent <CableSetup>(); n = nodes[i].GetComponent <OpticalFiber_Node>(); n.charge += (c.charge - n.charge) * propagationRate; if (i < cables.Length) { c = cables[i].GetComponent <CableSetup>(); c.charge += (n.charge - c.charge) * propagationRate; } } // PROPAGATION WITHOUT CABLES: //for(int i = 0; i < nodes.Length - 1; i++) //{ // OpticalFiber_Node current = nodes[i].gameObject.GetComponent<OpticalFiber_Node>(); // OpticalFiber_Node next = nodes[i+1].gameObject.GetComponent<OpticalFiber_Node>(); // next.charge += (current.charge - next.charge) * 0.2f; //} }
void ChargeDissipation() { OpticalFiber_Node node = nodes[0].GetComponent <OpticalFiber_Node>(); if (!node.isReceivingLight()) { node.charge -= dissipateRate * propagationRate; if (node.charge < 0) { node.charge = 0; } } }