Ejemplo n.º 1
0
 public override void Setup(Circuit circuit, CircuitTile tile)
 {
     power    = false;
     oldpower = false;
     if (points == null)
     {
         points = new List <Vector3>();
     }
     else
     {
         points.Clear();
     }
     if (tile.obj != null || tile.component != ComponentType.Wire)
     {
         gameObject.SetActive(false);
         return;
     }
     Recurse(circuit, tile.localPosition, tile.position);
     if (points.Count == 2)
     {
         points.Add(points[0]);
         points.Add(points[0]);
         points.Add(points[0]);
         points.Add(points[0]);
         points[0] += new Vector3(0.2f, 0);
         points[1] += new Vector3(0, 0.2f);
         points[2] += new Vector3(-0.2f, 0);
         points[3] += new Vector3(0, -0.2f);
         points[4] += new Vector3(0.2f, 0);
         points[5] += new Vector3(0, 0.2f);
     }
     lr.positionCount = points.Count;
     lr.SetPositions(points.ToArray());
 }
Ejemplo n.º 2
0
 public void addLink(CircuitTile link)
 {
     if (!neighbors.Contains(link))
     {
         neighbors.Add(link);
     }
 }
Ejemplo n.º 3
0
 public override void Setup(Circuit circuit, CircuitTile tile)
 {
     tile.obj           = this;
     transform.rotation = Quaternion.Euler(new Vector3(0, 0, 90 * tile.rotation));
     this.tile          = tile;
     this.circuit       = circuit;
     power = false;
 }
Ejemplo n.º 4
0
    private void linkNeighbors(CircuitTile thisTile, int i, int j)
    {
        var neighbor = getCircuitRef(i, j);

        if (neighbor != null)
        {
            thisTile.addLink(neighbor);
        }
    }
Ejemplo n.º 5
0
 public override void Setup(Circuit circuit, CircuitTile tile)
 {
     this.circuit = circuit;
     this.tile    = tile;
     tile.obj     = this;
     if (gp == null)
     {
         gp = FindObjectOfType <GameProgression>();
     }
 }
Ejemplo n.º 6
0
    public void Setup(Map map)
    {
        if (sound == null)
        {
            sound = FindObjectOfType <SoundManager>();
        }
        if (circuit != null && circuit.Length > 0)
        {
            for (int i = 0; i < circuit.Length; i++)
            {
                if (circuit[i].obj != null)
                {
                    circuit[i].obj.gameObject.SetActive(false);
                }
            }
        }
        //camera.orthographicSize = Mathf.Max(map.width, map.height+1)*0.5f;
        this.map = map;
        var layout = map.map;

        circuit = new CircuitTile[map.height * map.width];
        int w      = map.width;
        int input  = 0;
        int output = 0;

        for (int i = 0; i < map.height; i++)
        {
            for (int j = 0; j < map.width; j++)
            {
                int index = i * w + j;
                circuit[index] = new CircuitTile()
                {
                    localPosition = new IntVector(j, i), position = LocalToWorld(new IntVector(j, i))
                };
                circuit[index].component = layout[index];
                switch (layout[index])
                {
                case ComponentType.Input:
                    circuit[index].index = input++;
                    break;

                case ComponentType.Output:
                    circuit[index].index = output++;
                    break;
                }
            }
        }

        DrawOutline();
        title.text = map.title;
        title.transform.parent.position = new Vector3(0, map.height / 2, 0);
        dirty = true;
        cd    = 0;
    }
Ejemplo n.º 7
0
 public bool GetTileAt(IntVector pos, out CircuitTile tile)
 {
     if (!CheckLocalBounds(pos))
     {
         tile = new CircuitTile()
         {
             component = ComponentType.Unbuildable
         };
         return(false);
     }
     tile = circuit[LocalToIndex(pos)];
     return(true);
 }
Ejemplo n.º 8
0
 public override void Setup(Circuit circuit, CircuitTile tile)
 {
     power        = false;
     this.circuit = circuit;
     this.tile    = tile;
     tile.obj     = this;
     if (matcher.ContainsKey(tile.index))
     {
         var b = matcher[tile.index];
         b.Connect(this);
         Connect(b);
     }
     else
     {
         matcher.Add(tile.index, this);
     }
 }
Ejemplo n.º 9
0
 public abstract void Setup(Circuit circuit, CircuitTile tile);