public override void NeedPower(Relay relay) { if (nodes.Count != 0) { foreach (var node in nodes) { node.NeedPower(relay); } } }
public override void NeedPower(Relay relay) { if (residual > (relay.ratedPower - relay.nowPower)) { residual -= (relay.ratedPower - relay.nowPower); relay.nowPower += (relay.ratedPower - relay.nowPower); relay.StopCoroutine(relay.scan); } else { relay.nowPower += residual; residual = 0; } }
private void OnTriggerExit2D(Collider2D collision) { if (collision.gameObject.layer == AppManage.Instance.BuildLayer)//图层为build { //if (collision.gameObject.GetComponent<Relay>() != null) //{ // nodes.Remove(collision.gameObject.GetComponent<Relay>()); //} if (collision.gameObject.GetComponent <Source>() != null) { nodes.Remove(collision.gameObject.GetComponent <Source>()); } Relay relay = collision.gameObject.GetComponent <Relay>(); if (relay != null) { relay.node = null; } } }
private void OnTriggerEnter2D(Collider2D collision) //将范围内发用点加入node { if (collision.gameObject.layer == AppManage.Instance.BuildLayer) //图层为build { //if (collision.gameObject.GetComponent<Relay>()!=null) //{ // nodes.Add(collision.gameObject.GetComponent<Relay>()); //} if (collision.gameObject.GetComponent <Source>() != null) { nodes.Add(collision.gameObject.GetComponent <Source>()); } Relay relay = collision.gameObject.GetComponent <Relay>(); if (relay != null) { relay.node = this; } // collision.gameObject.GetComponent<BuildControl>().TryConnect(); } }
public virtual void NeedPower(Relay relay) { }