public MapCell() { cellKind = CellKind.UNUSED; isBorder = false; zoneID = 0; // 0 = zona no asignada. door = null; }
public Cell(CellKind kind, int x, int y) { this.kind = kind; this.x = x; this.y = y; this.obj = CreateObject(); }
public void Init(Vector2 coords, CellKind kind, ParkingKind parkingKind, GameObject gameObjectsContainer) { this.coords = coords; this.kind = kind; this.parkingKind = parkingKind; this.gameObjectsContainer = gameObjectsContainer; }
public MapCell() { cellKind = CellKind.UNUSED; isBorder = false; zoneID = 0; // 0 = zona no asignada. door = null; }
void InitCells(Dictionary <Vector2, Cell> cells) { ArrayList fireEngineSpots = new ArrayList(); fireEngineSpots.Add(new Vector2(0, 1)); fireEngineSpots.Add(new Vector2(0, 2)); fireEngineSpots.Add(new Vector2(7, 0)); fireEngineSpots.Add(new Vector2(8, 0)); fireEngineSpots.Add(new Vector2(1, 7)); fireEngineSpots.Add(new Vector2(2, 7)); fireEngineSpots.Add(new Vector2(9, 5)); fireEngineSpots.Add(new Vector2(9, 6)); ArrayList ambulanceSpots = new ArrayList(); ambulanceSpots.Add(new Vector2(0, 3)); ambulanceSpots.Add(new Vector2(0, 4)); ambulanceSpots.Add(new Vector2(5, 0)); ambulanceSpots.Add(new Vector2(6, 0)); ambulanceSpots.Add(new Vector2(3, 7)); ambulanceSpots.Add(new Vector2(4, 7)); ambulanceSpots.Add(new Vector2(9, 3)); ambulanceSpots.Add(new Vector2(9, 4)); for (int i = 0; i < cellsWide; i++) { for (int j = 0; j < cellsHigh; j++) { Vector2 coords = new Vector2(i, j); GameObject newCell = Object.Instantiate(cellPrefab); GameObject newGameObjectContainer = Object.Instantiate(gameObjectsContainer); CellKind kind = IsOutdoor(coords) ? CellKind.OUTDOOR : CellKind.INDOOR; ParkingKind parkingKind = ParkingKind.NONE; foreach (Vector2 fireEngineSpot in fireEngineSpots) { if (fireEngineSpot.Equals(coords)) { fireEngineSpots.Remove(fireEngineSpot); parkingKind = ParkingKind.FIRE_ENGINE; break; } } foreach (Vector2 ambulanceSpot in ambulanceSpots) { if (ambulanceSpot.Equals(coords)) { ambulanceSpots.Remove(ambulanceSpot); parkingKind = ParkingKind.AMBULANCE; break; } } newCell.GetComponent <Cell>().Init(coords, kind, parkingKind, newGameObjectContainer); cells.Add(coords, newCell.GetComponent <Cell>()); newCell.transform.SetParent(cellLayer.transform, false); newGameObjectContainer.transform.SetParent(gameObjectsLayer.transform, false); } } }
public void SetAsCompleteWall() { this.kind = CellKind.CompleteWall; if (obj != null) { GameObject.Destroy(obj); } this.obj = CreateObject(); }
public void CutWall() { this.kind = CellKind.TreeStump; if (obj != null) { GameObject.Destroy(obj); } this.obj = CreateObject(); }
public void ChangeCell(int x, int y, CellKind cell) { if (x >= rows || y >= columns || x < 0 || y < 0) { return; } board[x, y].SetCellKind(cell); }
public bool TryMovePlayerByDirection(int lastX, int lastY, int newX, int newY, Direction direction) { CellKind futureCell = GameController.Instance.GetCellByPosition(newX, newY); bool result = false; switch (futureCell) { case CellKind.Dirt: case CellKind.Empty: GameController.Instance.ChangeCell(newX, newY, CellKind.Player); GameController.Instance.ChangeCell(lastX, lastY, CellKind.Empty); result = true; break; case CellKind.Gem: GameController.Instance.ChangeCell(newX, newY, CellKind.Player); GameController.Instance.ChangeCell(lastX, lastY, CellKind.Empty); GameController.Instance.IncreaseGems(); result = true; break; case CellKind.Boulder: if (direction == Direction.Left && GameController.Instance.GetCellByPosition(newX, newY - 1) == CellKind.Empty) { GameController.Instance.PushBoulder(newX, newY, newX, newY - 1); GameController.Instance.ChangeCell(newX, newY - 1, CellKind.Boulder); GameController.Instance.ChangeCell(newX, newY, CellKind.Player); GameController.Instance.ChangeCell(lastX, lastY, CellKind.Empty); result = true; } else if (direction == Direction.Right && GameController.Instance.GetCellByPosition(newX, newY + 1) == CellKind.Empty) { GameController.Instance.PushBoulder(newX, newY, newX, newY + 1); GameController.Instance.ChangeCell(newX, newY + 1, CellKind.Boulder); GameController.Instance.ChangeCell(newX, newY, CellKind.Player); GameController.Instance.ChangeCell(lastX, lastY, CellKind.Empty); result = true; } break; case CellKind.Exit: if (GameController.Instance.ExitAvailable) { GameController.Instance.ChangeCell(newX, newY, CellKind.Player); GameController.Instance.ChangeCell(lastX, lastY, CellKind.Empty); GameController.Instance.PlayerReachedExit(); result = true; } break; default: result = false; break; } return(result); }
private bool IsFacing(CellKind cellKind) { var point = GetFacingPoint(); if (gathered.Contains(point)) { return(false); } return(Settings.Grid[GetFacingPoint()] == cellKind); }
public void SetCell(CellKind cellKind) { if (image == null) { image = GetComponent <Image>(); } image.color = Color.white; currentLook = cellKind; switch (cellKind) { case CellKind.Empty: image.sprite = null; image.color = Color.black; break; case CellKind.Player: image.sprite = spriteConfig.Character2; if (gameObject.activeInHierarchy) { StartCoroutine(Jump()); } break; case CellKind.DeadPlayer: image.sprite = spriteConfig.CharacterDead; break; case CellKind.Gem: image.sprite = spriteConfig.Gem[0]; break; case CellKind.Exit: image.sprite = spriteConfig.Exit[0]; break; case CellKind.Dirt: image.sprite = spriteConfig.Dirt; break; case CellKind.Boulder: image.sprite = spriteConfig.Boulder; break; case CellKind.Brick: case CellKind.OutOfBounds: default: image.sprite = spriteConfig.Brick; break; } }
public static GridMap Generate(Structure structure) { var cellKinds = new CellKind[structure.width, structure.height]; foreach (var room in structure.rooms) { PutRoom(cellKinds, room); } foreach (var road in structure.roads) { PutRoad(cellKinds, road); } return(new GridMap(cellKinds)); }
//"Dig" the cell, if it is a wall, then it becomes a floor. If it is a Floor it randomly becomes a Wall or a treeStump public void Dig() { if (kind.Equals(CellKind.Floor)) { this.kind = CellKind.Wall; } else { this.kind = CellKind.Floor; } if (obj != null) { GameObject.Destroy(obj); } this.obj = CreateObject(); }
public static CellState ToCellState(this CellKind kind) { switch (kind) { case CellKind.Food: return(CellState.Food); case CellKind.Gap: return(CellState.Gap); case CellKind.Empty: return(CellState.Empty); default: throw new ArgumentOutOfRangeException(); } }
private void RemoveBlocks() { int multy = 0; for (int i = 0; i < boardHeight - 1; i++) { if (HasFreeSpace(cells[i])) { continue; } for (int j = 1; j < boardWidth - 1; j++) { cells[i][j] = new Cell(CellKind.FreeSpace); } for (int j = i - 1; j > 0; j--) { for (int k = 1; k < boardWidth - 1; k++) { CellKind kind = cells[j][k].CellKind; if (kind == CellKind.FreeSpace) { continue; } Cell cell = cells[j][k]; cells[j][k] = new Cell(CellKind.FreeSpace); cells[j + 1][k] = cell; } } lines++; multy++; } points = points + 80 * multy * multy; //ShowLines(); //ShowPoints(); }
private void RemoveBlocks() { int combo = 0; for (int i = 0; i < boardHeight - 1; i++) { if (HasFreeSpace(cells[i])) { continue; } lines++; combo++; for (int j = 1; j < boardWidth - 1; j++) { cells[i][j] = new Cell(CellKind.FreeSpace); } for (int j = i - 1; j > 0; j--) { for (int k = 1; k < boardWidth - 1; k++) { CellKind kind = cells[j][k].CellKind; if (kind == CellKind.FreeSpace) { continue; } Cell cell = cells[j][k]; cells[j][k] = new Cell(CellKind.FreeSpace); cells[j + 1][k] = cell; } } } points += GetPoints(combo); }
public Cell(CellKind type, int x, int y) { Type = type; Position = new Position(x, y); }
public Cell(int _row, int _col, CellKind _kind) { SetData(_row, _col, _kind); }
public void TransformToFreeSpace() { CellKind = CellKind.FreeSpace; }
public void TransformToBlock() { CellKind = CellKind.Block; }
public Cell(CellKind cellKind) { CellKind = cellKind; }
public void TransformToTetromino() { CellKind = CellKind.Tetramino; }
public void SetData(int _row, int _col, CellKind _kind) { this.Row = _row; this.Col = _col; this.Kind = _kind; }
public void ChangeCell(int newX, int newY, CellKind cellKind) { currentLevel.ChangeCell(newX, newY, cellKind); }
public Coordinates(int x, int y) { this.pX = x; this.pY = y; this.pCellkind = CellKind.Figure; }
internal Cell(int x, int y, CellKind kind) { X = x; Y = y; Kind = kind; }
private static void PutCell(CellKind[,] cellKinds, int x, int y, Position leftDownPos, CellKind cellKind) { cellKinds[x + 1 + leftDownPos.x, y + 1 + leftDownPos.y] = cellKind; }
private static void PutWeakCell(CellKind[,] cellKinds, int x, int y, Position leftDownPos, CellKind cellKind) { if (cellKinds[x + 1 + leftDownPos.x, y + 1 + leftDownPos.y] == CellKind.Empty) { PutCell(cellKinds, x, y, leftDownPos, cellKind); } ; }
public void SetCellKind(CellKind cell) { cellKind = cell; }
public Cell(CellKind kind) { cellKind = kind; }
private static TreeCell AddCell(ExtList <TreeCell> row, GEDCOMIndividualRecord iRec, CellKind cellKind) { TreeCell result = new TreeCell(); result.ColIndex = row.Add(result); result.Kind = cellKind; result.Rec = iRec; result.Row = row; if (iRec != null) { result.Name = iRec.GetPrimaryFullName(); } return(result); }