Esempio n. 1
0
        void FindPossibleConnections()
        {
            possibleConns.Clear();
            connections.Clear();
            int     progress  = 0;
            Vector2 searchVec = transform.localPosition;

            searchVec.x -= 1;
            searchVec.y -= 1;
            for (int x = 0; x < 3; x++)
            {
                for (int y = 0; y < 3; y++)
                {
                    Vector3Int pos = new Vector3Int((int)searchVec.x + x,
                                                    (int)searchVec.y + y, 0);
                    var conns = matrix.GetElectricalConnections(pos);

                    foreach (IElectricityIO io in conns)
                    {
                        possibleConns.Add(io);

                        //Check if InputPosition and OutputPosition connect with this wire
                        if (ConnectionMap.IsConnectedToTile(GetConnPoints(), (AdjDir)progress, io.GetConnPoints()))
                        {
                            connections.Add(io);
                        }
                    }
                    progress++;
                }
            }
        }
        void FindPossibleConnections()
        {
            var conns = matrix.GetElectricalConnections(Vector3Int.RoundToInt(transform.localPosition));

            foreach (IElectricityIO io in conns)
            {
                //Check if InputPosition and OutputPosition connect with this wire
                if (ConnectionMap.IsConnectedToTile(GetConnPoints(), AdjDir.Overlap, io.GetConnPoints()) &&
                    io.GameObject() != gameObject)
                {
                    connectedWire = io;
                    connected     = true;
                    break;
                }
            }
        }