示例#1
0
 public Cell(int id, CellWalls walls, int x, int y)
 {
     Id    = id;
     Walls = walls;
     X     = x;
     Y     = y;
 }
示例#2
0
    void Spawn()
    {
        for (int x = 0; x < this.cells.GetLength(0); x++)
        {
            for (int y = 0; y < this.cells.GetLength(1); y++)
            {
                GameObject cell = Instantiate(cellPrefab, new Vector3Int(x, y, 0), Quaternion.identity);
                cell.transform.parent = this.transform;

                #region Debug
                // DEBUG
                //TextMeshPro textField = cell.AddComponent<TextMeshPro>();
                //textField.fontSize = 3f;
                //textField.alignment = TextAlignmentOptions.Center;
                //textField.color = new Color(255f, 255f, 255f);
                //textField.text = cells[x, y].distance.ToString();

                //RectTransform rect = cell.GetComponent<RectTransform>();
                //rect.pivot = new Vector2(0,0);
                //rect.sizeDelta = new Vector2(1, 1);
                #endregion

                CellWalls walls = cell.GetComponent <CellWalls>();

                walls.WallLeft.SetActive(cells[x, y].wallLeft);
                walls.WallBottom.SetActive(cells[x, y].wallBottom);

                if (finishCell.x == x && finishCell.y == y)
                {
                    Finish finishScript = cell.AddComponent <Finish>();

                    if (finishCell.x == 0)
                    {
                        finishScript.side = Finish.Sides.Left;
                    }
                    else if (finishCell.y == 0)
                    {
                        finishScript.side = Finish.Sides.Bottom;
                    }
                    else if (finishCell.x == cells.GetLength(0) - 2)
                    {
                        finishScript.side = Finish.Sides.Right;
                    }
                    else if (finishCell.y == cells.GetLength(1) - 2)
                    {
                        finishScript.side = Finish.Sides.Top;
                    }
                }
            }
        }
    }
示例#3
0
    // Removes a wall with the help of the enum
    public void RemoveWall(CellWalls wall)
    {
        switch (wall)
        {
        case CellWalls.TopWall:
            walls[0].SetActive(false);
            break;

        case CellWalls.RightWall:
            walls[1].SetActive(false);
            break;

        case CellWalls.BottomWall:
            walls[2].SetActive(false);
            break;

        case CellWalls.LeftWall:
            walls[3].SetActive(false);
            break;
        }
    }
示例#4
0
    public bool GetWallStatus(CellWalls wall)
    {
        switch (wall)
        {
        case CellWalls.TopWall:
            if (walls[0].activeSelf)
            {
                return(true);
            }

            break;

        case CellWalls.RightWall:
            if (walls[1].activeSelf)
            {
                return(true);
            }

            break;

        case CellWalls.BottomWall:
            if (walls[2].activeSelf)
            {
                return(true);
            }

            break;

        case CellWalls.LeftWall:
            if (walls[3].activeSelf)
            {
                return(true);
            }

            break;
        }

        return(false);
    }
 public DestinationCell(int id, CellWalls walls, int x, int y)
     : base(id, walls, x, y)
 {
 }