Exemplo n.º 1
0
 private void addConnection(IPowerConduit node, IPowerConduit neighbor)
 {
     if (!connectionMap.ContainsKey(node))
     {
         connectionMap.Add(node, new HashSet <IPowerConduit>());
     }
     connectionMap[node].Add(neighbor);
 }
Exemplo n.º 2
0
 // Start is called before the first frame update
 void Start()
 {
     conduit = GetComponent <IPowerConduit>();
     if (conduit == null)
     {
         conduit = GetComponentInParent <IPowerConduit>();
     }
     conduit.OnPowerFlowed += onPowerFlowed;
 }
Exemplo n.º 3
0
 // Start is called before the first frame update
 void Start()
 {
     lightEffectRenderer = GetComponent <SpriteRenderer>();
     text    = GetComponent <TMP_Text>();
     conduit = GetComponent <IPowerConduit>();
     if (conduit == null)
     {
         conduit = GetComponentInParent <IPowerConduit>();
     }
     conduit.OnPowerFlowed += onPowerFlowed;
 }
    // Start is called before the first frame update
    void Start()
    {
        //get RectTransform
        rectTransform = GetComponent <RectTransform>();
        //set heights
        parentHeight = transform.parent.GetComponent <RectTransform>().sizeDelta.y;
        selfHeight   = rectTransform.sizeDelta.y;
        //register delegate
        IPowerConduit conduit = GetComponent <IPowerConduit>();

        if (conduit == null)
        {
            conduit = GetComponentInParent <IPowerConduit>();
        }
        conduit.OnPowerFlowed += onPowerFlowed;
        //set position
        resetPosition();
    }
Exemplo n.º 5
0
    private void generateConnections(IPowerConduit ipc)
    {
        //Don't process a conduit twice
        if (connectionMap.ContainsKey(ipc))
        {
            return;
        }
        else
        {
            connectionMap.Add(ipc, new HashSet <IPowerConduit>());
        }
        //Get list of connecting conduits
        List <IPowerConduit> connectingConduits = getConnectingConduits(ipc);

        //Connect this conduit with a connecting one
        connectingConduits.ForEach(cc => addConnection(ipc, cc));
        //Connect further
        connectingConduits.ForEach(cc => generateConnections(cc));
    }
Exemplo n.º 6
0
    public List <IPowerConduit> getConnectingConduits(IPowerConduit ipc)
    {
        Collider2D coll2d = ipc.GameObject.GetComponent <Collider2D>();

        Collider2D[]    colls  = new Collider2D[Utility.MAX_HIT_COUNT];
        ContactFilter2D filter = new ContactFilter2D();

        filter.NoFilter();
        int count = coll2d.OverlapCollider(filter, colls);

        Utility.checkMaxReturnedList("getConnectingConduits", count);
        List <IPowerConduit> conduits = new List <IPowerConduit>();

        for (int i = 0; i < count; i++)
        {
            IPowerConduit conduit = colls[i].gameObject.GetComponent <IPowerConduit>();
            if (conduit != null)
            {
                conduits.Add(conduit);
            }
        }
        return(conduits);
    }