private bool GetPointOpened(v2i point) { return( a_Maze.a_Walls.Contains(new Tuple <v2i, v2i>(Coord, point)) || a_Maze.a_Walls.Contains(new Tuple <v2i, v2i>(point, Coord)) ); }
public static void CreateEffectTexture( Material _material, ref RenderTexture _texture, v2i _wh ) { Instance._CreateEffectTexture(_material, ref _texture, _wh); }
protected void Render() { WriteMaterialData(); v2i wh = a_ImageElement.WidthHeight.Floor().Abs(); Graphic.Manager.CreateEffectTexture(Material, ref a_RenderTexture, wh); }
private void Init() { v2i wh = a_ImageElement.WidthHeight.Floor(); Material = new Material(p_Shader); a_RenderTexture = new RenderTexture(wh.width, wh.height, 16); p_UnityImage.texture = a_RenderTexture; }
private void _CreateEffectTexture( Material _material, ref RenderTexture _texture, v2i _wh ) { // по дефолту текстура закрашена хз во что Texture input = new Texture2D(_wh.width, _wh.height, TextureFormat.ARGB32, false); Graphics.Blit(input, _texture, _material); }
protected List <Tuple <v2i, v2i> > GetAllWalls(List <v2i> cells) { List <Tuple <v2i, v2i> > ret = new List <Tuple <v2i, v2i> >(); foreach (var cell in cells) { // проверяем добавлены ли уже 4 стены вокруг каждой ячейки v2i topPoint = new v2i(cell.x, cell.y + 1); if ( !ret.Contains(new Tuple <v2i, v2i>(cell, topPoint)) && !ret.Contains(new Tuple <v2i, v2i>(topPoint, cell)) ) { ret.Add(new Tuple <v2i, v2i>(cell, topPoint)); } v2i rightPoint = new v2i(cell.x + 1, cell.y); if ( !ret.Contains(new Tuple <v2i, v2i>(cell, rightPoint)) && !ret.Contains(new Tuple <v2i, v2i>(rightPoint, cell)) ) { ret.Add(new Tuple <v2i, v2i>(cell, rightPoint)); } v2i bottomPoint = new v2i(cell.x, cell.y - 1); if ( !ret.Contains(new Tuple <v2i, v2i>(cell, bottomPoint)) && !ret.Contains(new Tuple <v2i, v2i>(bottomPoint, cell)) ) { ret.Add(new Tuple <v2i, v2i>(cell, bottomPoint)); } v2i leftPoint = new v2i(cell.x - 1, cell.y); if ( !ret.Contains(new Tuple <v2i, v2i>(cell, leftPoint)) && !ret.Contains(new Tuple <v2i, v2i>(leftPoint, cell)) ) { ret.Add(new Tuple <v2i, v2i>(cell, leftPoint)); } } return(ret); }
private void SetPointOpened(v2i point, bool value) { if (value) { if (GetPointOpened(point)) { return; } a_Maze.a_Walls.Add(new Tuple <v2i, v2i>(Coord, point)); } else { a_Maze.a_Walls.Remove(new Tuple <v2i, v2i>(Coord, point)); a_Maze.a_Walls.Remove(new Tuple <v2i, v2i>(point, Coord)); } }
protected Tuple <bool, bool> IsInOutset(v2i _cellPoint) { // cellpoint (координаты ячейки) не то же самое что и координаты точки (point) PointPlace pointPlaceLeftBottom = GetPointPlace((v2f)_cellPoint); PointPlace pointPlaceLeftTop = GetPointPlace(new v2f(_cellPoint.x, _cellPoint.y + 1)); PointPlace pointPlaceRightTop = GetPointPlace(new v2f(_cellPoint.x + 1, _cellPoint.y + 1)); PointPlace pointPlaceRightBottom = GetPointPlace(new v2f(_cellPoint.x + 1, _cellPoint.y)); // inset bool inset = pointPlaceLeftBottom != PointPlace.OUTSET && pointPlaceLeftTop != PointPlace.OUTSET && pointPlaceRightTop != PointPlace.OUTSET && pointPlaceRightBottom != PointPlace.OUTSET; bool outset = (pointPlaceLeftBottom == PointPlace.INSET || pointPlaceLeftTop == PointPlace.INSET || pointPlaceRightTop == PointPlace.INSET || pointPlaceRightBottom == PointPlace.INSET) || (pointPlaceLeftBottom == PointPlace.BORDER && pointPlaceLeftTop == PointPlace.BORDER && pointPlaceRightTop == PointPlace.BORDER && pointPlaceRightBottom == PointPlace.BORDER); return(new Tuple <bool, bool>(inset, outset)); }
public override void CalculateCells() { // если бы реализация всегда оставалась такой - это можно было бы вынести в отдельную функцию в базовом классе и не печатать один и тот же код сто раз // однако когда мы это будем оптимизировать реализация у каждого дочернего класса от Field поменяется, поэтому код дублируется, его немного так шо пох int xMin = (int)(Center.x - Radius), xMax = (int)(Center.x + Radius), yMin = (int)(Center.y - Radius), yMax = (int)(Center.y + Radius); HashSet <v2i> inset = new HashSet <v2i>(); HashSet <v2i> outset = new HashSet <v2i>(); for (int x = xMin; x <= xMax; x++) { for (int y = yMin; y <= yMax; y++) { v2i cellPoint = new v2i(x, y); Tuple <bool, bool> pointPlace = IsInOutset(cellPoint); if (pointPlace.Item1) { inset.Add(cellPoint); } if (pointPlace.Item2) { outset.Add(cellPoint); } } } a_CellsInset = inset.ToList(); a_CellsOutset = outset.ToList(); }
public int RandomeIntRange(v2i _ab) => a_Root.RandomeIntRange(_ab);
public void GoLeft() { CheckMove(a_Maze.GetCellFromPoint(a_Coord.LeftPoint)); a_Coord = a_Coord.LeftPoint; }
public void GoBottom() { CheckMove(a_Maze.GetCellFromPoint(a_Coord.BottomPoint)); a_Coord = a_Coord.BottomPoint; }
public void GoRight() { CheckMove(a_Maze.GetCellFromPoint(a_Coord.RightPoint)); a_Coord = a_Coord.RightPoint; }
public void GoTop() { CheckMove(a_Maze.GetCellFromPoint(a_Coord.TopPoint)); a_Coord = a_Coord.TopPoint; }
public Walker(AldousBroderBelyakov _maze, int _zoneId, v2i _coord) { a_Maze = _maze; a_Coord = _coord; a_ZoneId = _zoneId; }
private AldousBroderBelyakovCell GetCellFromPoint(v2i _cell) { return(a_MazeCells[_cell] as AldousBroderBelyakovCell); }
protected override TreeMazeCell CreateCellFromPoint(v2i _cell) { return(new AldousBroderBelyakovCell(this, _cell)); }
public TreeMazeCell(TreeMaze _maze, v2i _coord) { a_Maze = _maze; Coord = _coord; }
/*protected override void InitDefault() * { * base.InitDefault(); * * List<v2i> allCells = CutingBorderCells ? Field.CellsInset : Field.CellsOutset; * * List<Tuple<v2i,v2i>> walls = GetAllWalls( allCells ); * }*/ protected abstract TreeMazeCell CreateCellFromPoint(v2i _cell);
static int createmaze() { System.DateTime now = System.DateTime.Now; System.Random r = new System.Random(System.DateTime.Now.Millisecond + System.DateTime.Now.Second); v2i previous = new v2i(r.Next(H), 9); v2i operation = previous; v2i next = previous; set[previous.x, previous.y] = true; map[previous.x, previous.y] = allwall - up; distance[previous.x, previous.y] = 1; int assigned = 1; while (assigned < mazeSize) { operation = operations[r.Next(operations.Length)]; next = previous + operation; if (next.x >= 0 && next.x < H && next.y >= 2 && next.y < V) { if (!set[next.x, next.y]) { distance[next.x, next.y] = distance[previous.x, previous.y] + 1; assigned++; set[next.x, next.y] = true; switch (operation.ToString()) { case "-1 0": map[next.x, next.y] &= (allwall - right); map[previous.x, previous.y] &= (allwall - left); break; case "1 0": map[next.x, next.y] &= (allwall - left); map[previous.x, previous.y] &= (allwall - right); break; case "0 1": map[next.x, next.y] &= (allwall - down); map[previous.x, previous.y] &= (allwall - up); break; case "0 -1": map[next.x, next.y] &= (allwall - up); map[previous.x, previous.y] &= (allwall - down); break; default: break; } } previous = next; } } Game.text = ""; for (int i = V - 1; i >= 0; i--) { for (int j = 0; j < H; j++) { if (distance[j, i] < 100) { if (distance[j, i] < 10) { Game.text += "_" + distance[j, i] + " "; } else { Game.text += distance[j, i] + " "; } } } Game.text += "\n"; } entranceID = 0; int currmax = -1; for (int i = 0; i < H; i++) { if (distance[i, 2] < 16 && distance[i, 2] > currmax) { entranceID = i; currmax = distance[i, 2]; } } map[entranceID, 2] -= down; return(currmax); }
public int RandomeIntRange(v2i _ab) { return(RandomeIntRange(_ab.x, _ab.y)); }
public override bool Equals(object o) { v2i b = (v2i)o; return(x == b.x && y == b.y); }
public static int IntRange(v2i _ab) { return(IntRange(_ab.x, _ab.y)); }
public AldousBroderBelyakovCell(TreeMaze _maze, v2i _coord) : base(_maze, _coord) { WasVisited = false; }