예제 #1
0
 public MapCell()
 {
     cellKind = CellKind.UNUSED;
     isBorder = false;
     zoneID   = 0;       // 0 = zona no asignada.
     door     = null;
 }
예제 #2
0
 public Cell(CellKind kind, int x, int y)
 {
     this.kind = kind;
     this.x    = x;
     this.y    = y;
     this.obj  = CreateObject();
 }
예제 #3
0
 public void Init(Vector2 coords, CellKind kind, ParkingKind parkingKind, GameObject gameObjectsContainer)
 {
     this.coords               = coords;
     this.kind                 = kind;
     this.parkingKind          = parkingKind;
     this.gameObjectsContainer = gameObjectsContainer;
 }
예제 #4
0
 public MapCell()
 {
     cellKind = CellKind.UNUSED;
     isBorder = false;
     zoneID = 0; // 0 = zona no asignada.
     door = null;
 }
예제 #5
0
    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);
            }
        }
    }
예제 #6
0
 public void SetAsCompleteWall()
 {
     this.kind = CellKind.CompleteWall;
     if (obj != null)
     {
         GameObject.Destroy(obj);
     }
     this.obj = CreateObject();
 }
예제 #7
0
 public void CutWall()
 {
     this.kind = CellKind.TreeStump;
     if (obj != null)
     {
         GameObject.Destroy(obj);
     }
     this.obj = CreateObject();
 }
예제 #8
0
    public void ChangeCell(int x, int y, CellKind cell)
    {
        if (x >= rows || y >= columns || x < 0 || y < 0)
        {
            return;
        }

        board[x, y].SetCellKind(cell);
    }
예제 #9
0
    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);
    }
예제 #10
0
        private bool IsFacing(CellKind cellKind)
        {
            var point = GetFacingPoint();

            if (gathered.Contains(point))
            {
                return(false);
            }

            return(Settings.Grid[GetFacingPoint()] == cellKind);
        }
예제 #11
0
    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;
        }
    }
예제 #12
0
        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));
        }
예제 #13
0
        //"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();
        }
예제 #14
0
        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();
            }
        }
예제 #15
0
파일: Board.cs 프로젝트: HumorPlay/Tetris
        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();
        }
예제 #16
0
        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);
        }
예제 #17
0
 public Cell(CellKind type, int x, int y)
 {
     Type     = type;
     Position = new Position(x, y);
 }
예제 #18
0
 public Cell(int _row, int _col, CellKind _kind)
 {
     SetData(_row, _col, _kind);
 }
예제 #19
0
 public void TransformToFreeSpace()
 {
     CellKind = CellKind.FreeSpace;
 }
예제 #20
0
 public void TransformToBlock()
 {
     CellKind = CellKind.Block;
 }
예제 #21
0
 public Cell(CellKind cellKind)
 {
     CellKind = cellKind;
 }
예제 #22
0
 public void TransformToTetromino()
 {
     CellKind = CellKind.Tetramino;
 }
예제 #23
0
 public void SetData(int _row, int _col, CellKind _kind)
 {
     this.Row  = _row;
     this.Col  = _col;
     this.Kind = _kind;
 }
예제 #24
0
 public void ChangeCell(int newX, int newY, CellKind cellKind)
 {
     currentLevel.ChangeCell(newX, newY, cellKind);
 }
예제 #25
0
 public Coordinates(int x, int y)
 {
     this.pX        = x;
     this.pY        = y;
     this.pCellkind = CellKind.Figure;
 }
예제 #26
0
파일: Cell.cs 프로젝트: Algoists/KozasAnt
 internal Cell(int x, int y, CellKind kind)
 {
     X    = x;
     Y    = y;
     Kind = kind;
 }
예제 #27
0
 private static void PutCell(CellKind[,] cellKinds, int x, int y, Position leftDownPos, CellKind cellKind)
 {
     cellKinds[x + 1 + leftDownPos.x, y + 1 + leftDownPos.y] = cellKind;
 }
예제 #28
0
 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);
     }
     ;
 }
예제 #29
0
 public void SetCellKind(CellKind cell)
 {
     cellKind = cell;
 }
예제 #30
0
 public Cell(CellKind kind)
 {
     cellKind = kind;
 }
예제 #31
0
        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);
        }