using System.Collections; using System.Collections.Generic; using UnityEngine; public class MazeNode : MonoBehaviour { public enum Directions { TOP, RIGHT, BOTTOM, LEFT, NONE, } [SerializeField] GameObject topWall; [SerializeField] GameObject rightWall; [SerializeField] GameObject bottomWall; [SerializeField] GameObject leftWall; Dictionary walls = new Dictionary(); public Vector2Int Index { get; set; } public bool visited { get; set; } = false; Dictionary dirflags = new Dictionary(); public bool isWalkable = true; void Awake() { walls[Directions.TOP] = topWall; walls[Directions.RIGHT] = rightWall; walls[Directions.BOTTOM] = bottomWall; walls[Directions.LEFT] = leftWall; } private void SetActive(Directions dir, bool flag) { walls[dir].SetActive(flag); } public void SetDirFlag(Directions dir, bool flag) { dirflags[dir] = flag; SetActive(dir, flag); } public bool IsWall(Directions dir) { if (dirflags.ContainsKey(dir)) { return dirflags[dir]; // true jika ada dinding } return true; // default: ada dinding kalau belum diset } }