public CutTree(int rectLength, int rectWidth, TypeOfCell kind, int index, DirectionOfCut dir, CutTree left, CutTree right) { this.Length = rectLength; this.Width = rectWidth; this.IndexOfPieceOrValueOfCut = index; this.Kind = kind; this.CutDirection = dir; this.Left = left; this.Right = right; }
/// <summary> /// Создание клетки с указанными параметрами /// </summary> /// <param name="coordinate"> Координаты клетки на карте </param> /// <param name="content"> Тип клетки </param> /// <param name="bug"> Жук, находящийся в клетке, если есть </param> public Cell(Coordinates coordinate, TypeOfCell surface, TypeOfCell content, Bug bug = null) { Coordinate = coordinate; LinkedBug = bug; Surface = surface; Content = content; }
internal SolutionCell(double value, TypeOfCell type, int indx, DirectionOfCut dir, int offs1, int offs2, int nextCut) { this.Value = value; this.Type = type; this.Index = indx; this.DirOfCut = dir; this.OffsetL = offs1; this.OffsetW = offs2; this.NextCut = nextCut; }
/// <summary> /// Проверка совместимости сущности и почвы /// </summary> /// <returns></returns> public static bool IsFriendlyGround(TypeOfCell surface, TypeOfCell content) { switch (content) { case TypeOfCell.Mineral: { return(surface == TypeOfCell.Basalt); } case TypeOfCell.Berry: { return(surface == TypeOfCell.Grass || surface == TypeOfCell.Ground); } case TypeOfCell.Poison: { return(surface == TypeOfCell.Desert || surface == TypeOfCell.Ground); } case TypeOfCell.Sun: { return(surface == TypeOfCell.Grass); } case TypeOfCell.Bamboo: { return(surface == TypeOfCell.Jungle); } case TypeOfCell.Wall: { return(surface == TypeOfCell.Jungle); } case TypeOfCell.Prickle: { return(surface == TypeOfCell.Desert); } case TypeOfCell.Seaweed: { return(surface == TypeOfCell.Sea); } case TypeOfCell.Bug: { return(surface != TypeOfCell.Sea); } default: { return(true); } } }
// Create Field public void Create(TypeOfCell TypeOfCell) { Matrix = new Cell[Width, Height]; for (int i = 0; i < Width; i++) { for (int j = 0; j < Height; j++) { Matrix[i, j] = new Cell(i, j, TypeOfCell); } } }
public Game() { var settings = WorkWithSettings.GetSettings(); Deep = settings.deep; Width = settings.width; Interval = Convert.ToInt32(Math.Round(Constants.MilisecondsInAMinute / settings.speed)); GameField = new TypeOfCell[Deep, Width]; _startColumn = Convert.ToInt32(Math.Round((double)Width / 2) - 1); }
public CellInformation(Map map, Location location, TypeOfCell type) { isUp = (location.y + 1 >= map.cells.GetLength(1)) ? false : ((map.cells[location.x, location.y + 1] == type) ? true : false); isU_R = (location.x + 1 >= map.cells.GetLength(0) || location.y + 1 >= map.cells.GetLength(1)) ? false : ((map.cells[location.x + 1, location.y + 1] == type) ? true : false); isRight = (location.x + 1 >= map.cells.GetLength(0)) ? false : ((map.cells[location.x + 1, location.y] == type) ? true : false); isR_D = ((location.y - 1 < 0) || (location.x + 1) >= map.cells.GetLength(0)) ? false : ((map.cells[location.x + 1, location.y - 1] == type) ? true : false); isDown = (location.y - 1 < 0) ? false : ((map.cells[location.x, location.y - 1] == type) ? true : false); isD_L = ((location.y - 1 < 0) || (location.x - 1 < 0)) ? false : ((map.cells[location.x - 1, location.y - 1] == type) ? true : false); isLeft = (location.x - 1 < 0) ? false : ((map.cells[location.x - 1, location.y] == type) ? true : false); isL_U = ((location.y + 1 >= map.cells.GetLength(1)) || (location.x - 1 < 0)) ? false : ((map.cells[location.x - 1, location.y + 1] == type) ? true : false); }
public void SetColor(TypeOfCell color) { typeOfCell = color; switch (color) { case TypeOfCell.Green: transform.GetChild(1).gameObject.SetActive(true); break; case TypeOfCell.White: transform.GetChild(0).gameObject.SetActive(true); break; } }
/// <summary> /// Конструктор сетки, генерирование препятствий /// </summary> public Net() { CellsOfNet = new TypeOfCell[N, N]; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { CellsOfNet[i, j] = new int(); } } EdgesFilling(); GenerateGlobalNet(N); }
// построение побочной сетки (той, которая будет отображаться) // нужно для того, чтобы алгоритм быстрее работал и не включал лишние вычисления private static TypeOfCell[,] CreateSubNet(TypeOfCell[,] cellsOfNet, Point BeginNet, int scale) { TypeOfCell[,] subNet = new TypeOfCell[scale, scale]; Point begin = new Point(BeginNet.X, BeginNet.Y); if (cellsOfNet.GetLength(0) - (BeginNet.X + scale) < 0) { begin.X = cellsOfNet.GetLength(0) - scale; } if (cellsOfNet.GetLength(1) - (BeginNet.Y + scale) < 0) { begin.X = cellsOfNet.GetLength(0) - scale; } for (int i = 0; i < scale; i++) { for (int j = 0; j < scale; j++) { subNet[j, i] = cellsOfNet[begin.X + j, begin.Y + i]; } } return(subNet); }
// возращаеь (true\false) в зависимости можно ли двигаться в указаном направлении private bool IsPosibleMoveToDirection(TypeOfCell[,] map, Position positionFrom, Direction direction, TypeOfCell selectedTypeOfCell) { switch (direction) { case Direction.Down: if (positionFrom.x + 2 >= (map.GetLength(0) - 1)) { return(false); } if (map[positionFrom.x + 2, positionFrom.y] != selectedTypeOfCell) { return(false); } break; case Direction.Left: if (positionFrom.y - 2 < (0 + 1)) { return(false); } if (map[positionFrom.x, positionFrom.y - 2] != selectedTypeOfCell) { return(false); } break; case Direction.Right: if (positionFrom.y + 2 >= (map.GetLength(1) - 1)) { return(false); } if (map[positionFrom.x, positionFrom.y + 2] != selectedTypeOfCell) { return(false); } break; case Direction.Up: if (positionFrom.x - 2 < (0 + 1)) { return(false); } if (map[positionFrom.x - 2, positionFrom.y] != selectedTypeOfCell) { return(false); } break; } return(true); }
private bool SimpleMove(int WIDTH, int HEIGHT, Cell[,] NewField, int RESOLUTION, List <Mob> mobs, TypeOfCell type) { bool flag = false; int xf = 0; int yf = 0; int minlength = 51; int lenght; for (int i = x - vision; i < x + vision; i++) { for (int j = y - vision; j < y + vision; j++) { lenght = Math.Abs(x - i) + Math.Abs(y - j); if (i < WIDTH - RESOLUTION && j < HEIGHT - RESOLUTION && i > 0 && j > 0 && NewField[i, j].Type == type && lenght < minlength) { minlength = lenght; xf = i; yf = j; } } } if (minlength != 51) { flag = true; if (x - xf != 0) { if (x > xf) { Move(WIDTH, HEIGHT, NewField, RESOLUTION, -1, 0, mobs); } else { Move(WIDTH, HEIGHT, NewField, RESOLUTION, 1, 0, mobs); } } else if (y - yf != 0) { if (y > yf) { Move(WIDTH, HEIGHT, NewField, RESOLUTION, 0, -1, mobs); } else { Move(WIDTH, HEIGHT, NewField, RESOLUTION, 0, 1, mobs); } } } return(flag); }
public Cell(int X, int Y, TypeOfCell TypeOfCell) { x = X; y = Y; Type = TypeOfCell; }
/// <summary> /// find color of block in array for print /// </summary> /// <param name="typeOfCell">type of game field cell</param> /// <returns>color of block</returns> private static ConsoleColor GetColorGameField(TypeOfCell typeOfCell) { //return console color return(typeOfCell == TypeOfCell.Empty ? Constants.MainColor : Figures.Find(figure => figure.TypeOfCell == typeOfCell).ConsoleColor); }
public Cell(int _X, int _Y, TypeOfCell _TypeOfCell) { X = _X; Y = _Y; TypeOfCell = _TypeOfCell; }
public override string ToString() { return(TypeOfCell.ToString()); }
public Cell(TypeOfCell cellType) { _cellType = cellType; }
/// <summary> /// find brush for draw by type of cell /// </summary> /// <param name="cell">current type of cell</param> /// <returns>brush for draw</returns> public static Brush GetColor(TypeOfCell cell) { Figure[] figures = new Figure[] { new FigureI(0), new FigureO(0), new FigureT(0), new FigureS(0), new FigureZ(0), new FigureL(0), new FigureJ(0) }; return(figures.FirstOrDefault(figure => figure.TypeOfCell == cell).Color); }
// возращает список направлений куда с текущей клетки можно передвигаться private List <Direction> GetPosibleMovebleDirection(TypeOfCell[,] map, Position positionFrom, TypeOfCell selectedTypeOfCell) { List <Direction> movebleDirections = new List <Direction>(); if (IsPosibleMoveToDirection(map, positionFrom, Direction.Down, selectedTypeOfCell)) { movebleDirections.Add(Direction.Down); } if (IsPosibleMoveToDirection(map, positionFrom, Direction.Left, selectedTypeOfCell)) { movebleDirections.Add(Direction.Left); } if (IsPosibleMoveToDirection(map, positionFrom, Direction.Right, selectedTypeOfCell)) { movebleDirections.Add(Direction.Right); } if (IsPosibleMoveToDirection(map, positionFrom, Direction.Up, selectedTypeOfCell)) { movebleDirections.Add(Direction.Up); } if (movebleDirections.Count == 0) { return(null); } return(movebleDirections); }