Ejemplo n.º 1
0
    private void CheckNeighbours(PipeCell cell)
    {
        List <PipeCell> n = GetNeighbours(cell);

        int[] neighbourType = new int[4];

        for (int i = 0; i < n.Count; i++)
        {
            switch (n[i].watertype)
            {
            case WaterTypes.NoWater:
                neighbourType[0]++;
                break;

            case WaterTypes.CleanWater:
                neighbourType[1]++;
                break;

            case WaterTypes.AcidWater:
                neighbourType[2]++;
                break;

            case WaterTypes.TrashWater:
                neighbourType[3]++;
                break;

            default:
                break;
            }
        }

        CheckType(cell, neighbourType);
    }
Ejemplo n.º 2
0
    public void Placement()
    {
        myCell = FindCell();
        myCell.SetPipe(pipetype, ReCalculateState(), transform.localEulerAngles.y);

        PipeGrid.instance.CheckGrid();
        //print("Placement: " + transform.name + " >mycell: " + myCell);
    }
Ejemplo n.º 3
0
    public void Breaking()
    {
        //myCell = FindCell();
        //print("Breaking: " + transform.name + " >mycell: " + myCell);


        myCell.DisabledPipe();
        PipeGrid.instance.CheckGrid();
        myCell = null;
    }
Ejemplo n.º 4
0
    private void CreateGrit(int floorId)
    {
        int pointId = 0;

        for (int x = 0; x < gridSize.x; x++)
        {
            for (int y = 0; y < gridSize.y; y++)
            {
                Vector3 pos = snapPoints[pointId].position;
                pos.y = pos.y - (floorId * PipeLineManager.instance.f_floorDistance);
                grid[floorId, x, y] = new PipeCell(pos, new Vector3Int(floorId, x, y));
                pointId++;
            }
        }
    }
Ejemplo n.º 5
0
 private void CheckType(PipeCell cell, int[] neighbourType)
 {
     for (int j = neighbourType.Length - 1; j >= 0; j--)
     {
         if (neighbourType[j] > 0)
         {
             if (cell.watertype != (WaterTypes)j)
             {
                 cell.watertype = (WaterTypes)j;
                 CheckNeighbours(cell);
                 break;
             }
             else
             {
                 break;
             }
         }
     }
 }
Ejemplo n.º 6
0
    private List <PipeCell> GetNeighbours(PipeCell cell)
    {
        List <PipeCell> neigbours     = new List <PipeCell>();
        string          cellOpeningId = GetOpeningsId(cell.pipeForm, cell.angle);
        int             cellId        = 0;

        for (int x = -1; x <= 1; x++)
        {
            for (int y = -1; y <= 1; y++)
            {
                if (Mathf.Abs(x) == Mathf.Abs(y))
                {
                    continue;
                }

                int checkPosX = cell.gridPosition.y + x;
                int checkPosY = cell.gridPosition.z + y;

                if (checkPosX >= 0 && checkPosX < 4 &&
                    checkPosY >= 0 && checkPosY < 4)
                {
                    PipeCell n          = grid[PipeLineManager.instance.i_Floor, checkPosX, checkPosY];
                    string   nOpeningId = GetOpeningsId(n.pipeForm, n.angle);

                    if (ConnectedPipe(cellOpeningId, nOpeningId, cellId))
                    {
                        neigbours.Add(n);
                    }
                }

                cellId++;
            }
        }

        return(neigbours);
    }
Ejemplo n.º 7
0
    IEnumerator SlowStart()
    {
        yield return(null);

        childCell = PipeGrid.instance.grid[gridChildId.x, gridChildId.y, gridChildId.z];
    }