コード例 #1
0
    public void GenerateBoard()
    {
        cells = new CellController[boardWidth, boardHeight];
        string     holderName = "Generated Board";
        GameObject board      = transform.Find(holderName).gameObject;

        if (board != null)
        {
            DestroyImmediate(board);
        }

        board = new GameObject(holderName);
        board.transform.parent = transform;

        for (int x = 0; x < boardWidth; x++)
        {
            for (int y = 0; y < boardHeight; y++)
            {
                Vector2    cellPosition = new Vector2(-boardWidth / 2 + .5f + x, boardHeight / 2 - .5f - y);
                GameObject newCell      = Instantiate(cellPrefab, cellPosition, Quaternion.identity, board.transform);
                newCell.name = "cell(" + x + "," + y + ")";
                CellController cellController = newCell.GetComponent <CellController>();
                cellController.x = x;
                cellController.y = y;
                cells[x, y]      = cellController;
            }
        }
    }
コード例 #2
0
    private TokenMenuCloseButton m_tmcb; // entire-screen button in the background that will close the menu when clicked

    public void OpenMenuAtCell(GameObject cell)
    {
        m_selectedCell = cell.GetComponent <CellController>();

        // positioning
        RectTransform rt       = m_tokenMenu.GetComponent <RectTransform>();
        Vector2       rtSize   = rt.sizeDelta;
        Vector2       cellSize = cell.GetComponent <RectTransform>().sizeDelta;

        rt.position = new Vector3(
            Screen.width / 2,
            cell.transform.position.y + rtSize.y / 2f + cellSize.y / 2f,
            0);

        // buttons; assign self as TMM
        m_tokenButtons = m_tokenMenu.GetComponentsInChildren <TokenButton>();
        foreach (var tb in m_tokenButtons)
        {
            tb.tokenMenuManager = gameObject.GetComponent <TokenMenuManager>();
        }

        m_tmcb = m_tokenMenu.GetComponentInChildren <TokenMenuCloseButton>();
        m_tmcb.tokenMenuManager = gameObject.GetComponent <TokenMenuManager>();

        // colors
        IndicateConflictingTokens();

        m_tokenMenu.SetActive(true);
    }
コード例 #3
0
        public FormCreate(CellController controller, Size clientSize, Point loc)
        {
            InitializeComponent();
            //Рандомизация значений трекбаров для цвета
            this.trackBar1.Value = r.Next(0, this.trackBar1.Maximum);
            this.trackBar2.Value = r.Next(0, this.trackBar2.Maximum);
            this.trackBar3.Value = r.Next(0, this.trackBar3.Maximum);

            //Определение максимальных значений длины и ширины
            this.numericUpDown1.Maximum = clientSize.Width / 2;
            this.label10.Text           = this.numericUpDown1.Maximum.ToString();
            this.numericUpDown2.Maximum = clientSize.Height / 2;
            this.label11.Text           = this.numericUpDown2.Maximum.ToString();

            //Таймер для изменения цвета кнопки (косметика)
            buttonTimer.Interval = 1;
            buttonTimer.Tick    += ButtonTimer_Tick;
            buttonTimer.Start();

            this.controller = controller;
            this.location   = loc;

            //Трекбары плохо работают с цветами. Ужасно выглядит.
            //if (DateTime.Now.Hour >= 18 || DateTime.Now.Hour <= 6)
            //{
            //    this.BackColor = Color.Black;
            //    this.numericUpDown1.BackColor = this.numericUpDown2.BackColor = this.numericUpDown3.ForeColor = Color.Black;
            //}
        }
コード例 #4
0
ファイル: Cell.cs プロジェクト: StudioShader/DoNotExplode
    public Cell(int X, int Y)
    {
        Coordinate coord = new Coordinate(X, Y);

        if (CellController.FindCell(coord) != null)
        {
            Cell alreadyCell = CellController.FindCell(coord);
            if (alreadyCell.empty == -1)
            {
                alreadyCell.del();
                empty                 = -1;
                Coordinate            = coord;
                Position              = new Vector2(coord.x * CellController.CellSize + CellController.CellSize / 2, coord.y * CellController.CellSize + CellController.CellSize / 2);
                cell                  = PoolScript.instance.GetObjectFromPool("Cell", Position, Quaternion.Euler(0, 0, 0));
                cell.transform.parent = CellController.instance.transform;
                CellController.cells.Add(this);
            }
        }
        else
        {
            empty                 = -1;
            Coordinate            = coord;
            Position              = new Vector2(coord.x * CellController.CellSize + CellController.CellSize / 2, coord.y * CellController.CellSize + CellController.CellSize / 2);
            cell                  = PoolScript.instance.GetObjectFromPool("Cell", Position, Quaternion.Euler(0, 0, 0));
            cell.transform.parent = CellController.instance.transform;
            CellController.cells.Add(this);
        }
    }
コード例 #5
0
    private void CheckLine(int y)
    {
        CellController cellController = null;

        for (int x = 0; x < boardWidth; x++)
        {
            cellController = GetCellController(x, y);
            if (cellController.TilesCount == 0)
            {
                if (y == 0)
                {
                    cellController.CreateTile();
                    CellController lowerCellController = GetLowerCellController(cellController);
                    if (lowerCellController != null)
                    {
                        StartMoveFromUpperCellCoroutine(lowerCellController);
                    }
                }
                else
                {
                    StartMoveFromUpperCellCoroutine(cellController);
                }
            }
            if (isSecondLeft && previousTime % helpTimer == 0)
            {
                Help(cellController);
            }
        }
    }
コード例 #6
0
    public override bool Grow()
    {
        bool hasGrown = false;

        foreach (ActionPattern actionPattern in actionPatterns)
        {
            if (MatchesPattern(actionPattern.GetPattern()))
            {
                if (actionPattern.action == Action.Die)
                {
                    this.Kill();
                    return(hasGrown);
                }
            }
        }

        foreach (ActionPattern actionPattern in actionPatterns)
        {
            if (MatchesPattern(actionPattern.GetPattern()))
            {
                if (actionPattern.action == Action.Expand)
                {
                    CellController cell = this.Grid.GetCellInDirection(this.X, this.Y, actionPattern.expandDirection);

                    if (CanClaim(cell))
                    {
                        cell.Claim(this);
                        hasGrown = true;
                    }
                }
            }
        }
        return(hasGrown);
    }
コード例 #7
0
    // Each combatant lose 1% in defend after each combat
    // Organ can reflect the attack (1/2 defense - attack on the pathogen
    public bool defend(CellController pathogen)
    {
        float combat = pathogen.power() - defense();
        bool  successful;

        if (combat <= 0)                             // successful defense against the pathogen
        {
            pathogen.updateHealthStats(-combat / 2); // pathogen is damaged
            pathogen.updateDefenseStats(-1f);
            updateDefenseStats(-1.0f);               // organ loses a bit of defense
            successful = true;
        }
        else             // Lost
        {
            updateHealthStats(-combat);
            updateDefenseStats(-1.0f);
            pathogen.updateDefenseStats(-1f);             // pathogen loses a bit of defense
            damageBody();
            if (stats_health <= 0)
            {
                Destroy(gameObject);                  // Die!
            }
            else
            {
                inContact [pathogen.GetInstanceID()] = new Damage(combat, Time.time + 1);
            }
            successful = false;
            // Keeps track of the damage if contact continues;
        }
        //Debug.Log(gameObject.name+"."+defense()+" defends against "+ pathogen.name
        //	+"."+pathogen.power()+ " "+ showStats()+ (successful?" success":"failed"));

        return(successful);
    }
コード例 #8
0
ファイル: GridController.cs プロジェクト: Wania8462/Sudoku
    CellController _clickedCellController; // выделеная яечкйка
    void Start()
    {
        _puzzle = PuzzleGame.Instance.GetNewGame(1);

        for (int x = 0; x < 9; x++)
        {
            for (int y = 0; y < 9; y++)
            {
                PuzzleCell cell = _puzzle.GetCell(x, y);
                cell.OnCellOpen += OnCellOpened;
                var cellButton = GameObject.Find($"{x}_{y}");

                CellController controller = cellButton.GetComponent <CellController>();
                controller.Cell         = cell;
                controller.X            = x; //колонка
                controller.Y            = y; //строка
                controller.CellName     = cellButton.name;
                controller.CellClicked += OnCellClicked;
                _cells[x, y]            = controller;
                controller.DrawCell();
            }
        }

        //Find keypad buttons
        for (int i = 1; i < 10; i++)
        {
            var keyPadButton = GameObject.Find($"Num{i}").GetComponent <Button>();
            int number       = i;
            keyPadButton.onClick.AddListener(() => OnKeyPadButtonClicked(number));
        }
    }
コード例 #9
0
 void Depoint()
 {
     lineRenderer.enabled      = false;
     leftBarbRenderer.enabled  = false;
     rightBarbRenderer.enabled = false;
     targetCell = null;
 }
コード例 #10
0
    public void FillArray() //das wird für die Methode GetAdjacentCells in der Cellcontrollerklasse verwendet
    {
        // lokales Hilfs-Array
        CellController[] arrayOfObjects = GameObject.FindObjectsOfType <CellController>();
        Debug.Log("objekt: " + arrayOfObjects[0]);
        Debug.Log("Hilfsarray arrayOfObjects.Length: " + arrayOfObjects.Length);

        int nummer = 0;

        for (var i = 0; i < GridSize; i++)
        {
            for (var j = 0; j < GridSize; j++)
            {
                for (int k = 0; k < 64; k++)
                {
                    if (arrayOfObjects[k].cellNum == nummer)
                    {
                        ArrayOfCells[i, j] = arrayOfObjects[k].GetComponent <CellController>();;//checkNumber(nummer, arrayOfObjects[k], i, j);
                        ListOfCells.Add(ArrayOfCells[i, j]);
                        cellController        = ArrayOfCells[i, j];
                        cellController.xCoord = i;
                        cellController.yCoord = j;
                        break;
                    }
                }
                nummer++;
            }
        }
    }
コード例 #11
0
    //private float animSpeed = 1f;
    private void Update()
    {
        if (Input.GetMouseButtonDown(0) && Input.mousePosition.x >= g.camera.pixelRect.x)
        {
            targetCell = g.map.GetCellFromCamera(Input.mousePosition);
            if (targetCell != cell)
            {
                moveToCell(targetCell);
//                g.c.Trigger(Channel.Camera.SetTarget, targetCell);
//                ListenTo(g.c, Channel.Camera.SetTarget, SetTarget);
            }
        }
        if (Input.GetKeyDown(KeyCode.Space) && g.map.obtacles[cell].GetType() != typeof(BombController))
        {
            SetPlayerBomb();
        }

        /*
         * if (Input.GetKeyDown(KeyCode.A)) {
         *  animatorFactor -= 0.01f;
         *  console.log(animatorFactor);
         * }
         * if (Input.GetKeyDown(KeyCode.D)) {
         *  animatorFactor += 0.01f;
         *  console.log(animatorFactor);
         * }
         */
    }
コード例 #12
0
    public void LoadMap(string str)
    {
        gameController.ships.Clear();
        string[] ships = str.Split(';');
        foreach (string ship in ships)
        {
            string[] ship_datas            = ship.Split('|');
            Ship     newShip               = new Ship(0);
            List <CellController> cellList = new List <CellController>();
            foreach (string ship_data in ship_datas)
            {
                string[] keypair = ship_data.Split('=');
                switch (keypair[0])
                {
                case "amount":
                    newShip.PieceAmount = int.Parse(keypair[1]);
                    break;

                case "pieces":
                    string[] pieces = keypair[1].Split(',');
                    foreach (string piece in pieces)
                    {
                        string[]       p = piece.Split(':');
                        CellController c = playerController.Cells[int.Parse(p[1])][int.Parse(p[0])];
                        c.EnemyCell = true;
                        cellList.Add(c);
                    }
                    newShip.Cells = cellList.ToArray();
                    break;
                }
            }
            gameController.ships.Add(newShip);
        }
    }
コード例 #13
0
ファイル: WorldManager.cs プロジェクト: MarkianovNikita/GGJ19
    private void ConnectCells(CellController cell1, CellController cell2)
    {
        if (cell1 != null && cell2 != null)
        {
            if (!cell1.Empty && !cell2.Empty)
            {
                if (cell1.ZoneID != cell2.ZoneID)
                {
                    var zone1 = _zones.Find(x => x.ZoneID == cell1.ZoneID);
                    var zone2 = _zones.Find(x => x.ZoneID == cell2.ZoneID);

                    if (zone1 == null || zone2 == null)
                    {
                        return;
                    }
                    if (zone1.Neighbors.Contains(zone2))
                    {
                        return;
                    }

                    zone1.Neighbors.Add(zone2);
                    zone2.Neighbors.Add(zone1);
                }
            }
        }
    }
コード例 #14
0
    public CellController ReplaceCell(MapPoint point, CellController prefab)
    {
        if (point.X < 0 || point.Y < 0 || point.X > 0xffff || point.Y > 0xffff)
        {
            return(null);
        }


        CellController newCell = CellController.InstantiateMe(prefab, transform, point);


        MapRect rect = prefab.GetCellIndexes(point, selectedRotation);

        rect.Foreach((MapPoint p) => {
            int key = p.toInt();
            if (cells.ContainsKey(key))
            {
                GameObject.Destroy(cells[key].gameObject);
                cells.Remove(key);
                cells[key] = newCell;
            }
        });

        newCell.SetRotation(selectedRotation);

        return(newCell);
    }
コード例 #15
0
 private void InitCellController(CellController cellController, int hor, int vert)
 {
     cellController.SetFieldManager(fieldManager);
     cellController.SetSceneManager(sceneManager);
     cellController.SetPosition(new CellPosition(hor, vert));
     cellController.CellChange += fieldManager.GetWinnerCheckerCellChangeHandler();
 }
コード例 #16
0
    private CellController SpawnCell(int x, int y, CellController prefab)
    {
        if (x > TilesWide - 1 || y > TilesHigh - 1 || x < 0 || y < 0)
        {
            return(prefab);
        }


        if (foregroundArray[x, y] != null)
        {
            int indexToRemove = cellsToUpdate.IndexOf(foregroundArray[x, y]);

            if (indexToRemove > 0)
            {
                cellsToUpdate.RemoveAt(indexToRemove);
            }

            Destroy(foregroundArray[x, y].gameObject);
        }


        Vector3 scale    = this.transform.localScale;
        Vector3 position = new Vector3((bottomLeft.x / scale.x) + x, (bottomLeft.y / scale.x) + y, 0.1f);

        CellController cell = Instantiate(prefab, position, new Quaternion());

        cell.X = x;
        cell.Y = y;


        AddForegroundCellToGrid(cell);

        return(cell);
    }
コード例 #17
0
    void GetAdjacentCells()
    {
        adjacentCells = new List <CellController> ();

        CellController northCell = null, westCell = null, eastCell = null, southCell = null;

        if (xCoord - 1 >= 0)
        {
            northCell = GMInstance.ArrayOfCells [xCoord - 1, yCoord];
            adjacentCells.Add(northCell);
        }

        if (yCoord - 1 >= 0)
        {
            Debug.Log("cellNumber of this clicked box: " + GMInstance.ArrayOfCells[xCoord, yCoord - 1].cellNum);
            westCell = GMInstance.ArrayOfCells[xCoord, yCoord - 1];
            adjacentCells.Add(westCell);
        }

        if (yCoord + 1 <= GMInstance.GridSize - 1)
        {
            eastCell = GMInstance.ArrayOfCells [xCoord, yCoord + 1];
            adjacentCells.Add(eastCell);
        }
        if (xCoord + 1 <= GMInstance.GridSize - 1)
        {
            southCell = GMInstance.ArrayOfCells [xCoord + 1, yCoord];
            adjacentCells.Add(southCell);
        }
    }
コード例 #18
0
 void GenerateMap()
 {
     for (int i = 0; i < GRID_SIZE + 1; i++)
     {
         Cells.Add(new List <CellController>());
         for (int j = 0; j < GRID_SIZE + 1; j++)
         {
             if (!(i == 0 && j == 0))
             {
                 CellPrefab.GetComponent <RectTransform>().sizeDelta = new Vector2(CELL_SIZE, CELL_SIZE);
                 GameObject o = Instantiate(CellPrefab, new Vector2((j - (GRID_SIZE + 1) / 2) * CELL_SIZE, (-i + (GRID_SIZE + 1) / 2) * CELL_SIZE) + MAP_OFFSET, Quaternion.identity) as GameObject;
                 o.transform.SetParent(canvas.transform, false);
                 if (i > 0 && j > 0)
                 {
                     CellController c = o.AddComponent <CellController>();
                     c.ID_i = i - 1;
                     c.ID_j = j - 1;
                     o.name = c.ID_i + ":" + c.ID_j;
                     Cells[c.ID_i].Add(c);
                     Destroy(o.transform.Find("Text").gameObject);
                 }
                 else
                 {
                     //HEADER
                     Text t = o.transform.Find("Text").GetComponent <Text>();
                     t.text  = i == 0 ? LETTERS[j - 1] : i.ToString();
                     t.color = Color.white;
                     o.name  = "Header-" + t.text;
                     Destroy(o.GetComponent <Image>());
                     Destroy(o.GetComponent <Button>());
                 }
             }
         }
     }
 }
コード例 #19
0
    public void Clicked(CellController cell)
    {
        if (!Attack)
        {
            switch (this.state)
            {
            case CellState.None:
                if (SelectedCells.Count < ShipAmount.TotalCellAmount)
                {
                    this.state = CellState.Selected;
                    SelectedCells.Add(this);
                }
                break;

            case CellState.Selected:
                this.state = CellState.None;
                SelectedCells.Remove(this);
                break;
            }
            this.Invalidate();
        }
        else
        {
            if (!Locked)
            {
                if (EnemyCell)
                {
                    state = CellState.Selected;
                    Invalidate();
                    ShipAmount.TotalCellAmount--;
                }
                MainController.DoAttack();
            }
        }
    }
コード例 #20
0
 private void MoveToClosest()
 {
     if (!isDragging)
     {
         float minDistance = 0f;
         bool  firstPass   = true;
         currentCell.SetIsFree(true);
         Transform currentTf = gameObject.transform;
         foreach (var cell in cells)
         {
             if (cell.GetIsFree())
             {
                 float currentDistance = CalculateDistance(currentTf, cell.transform);
                 if (firstPass || currentDistance < minDistance)
                 {
                     minDistance = currentDistance;
                     currentCell = cell;
                 }
                 firstPass = false;
             }
         }
         currentCell.SetIsFree(false);
         gameObject.transform.position = new Vector3(currentCell.transform.position.x, yHeight, currentCell.transform.position.z);
     }
 }
コード例 #21
0
    public void handleCellClicked(CellController cell)
    {
        var pos = getPos(cell.x, cell.y);

        if (currentPlayer == Player.Wheel)
        {
            cell.addWheel();
            choices[pos] = Player.Wheel;
        }
        else
        {
            cell.addTurbo();
            choices[pos] = Player.Turbo;
        }

        var winner = getWinner();

        if (winner != null)
        {
            GameOverController.setText(winner.ToString() + " won!");
            SceneManager.LoadScene("gameOverScene");
        }
        else if (isAllCellsFilled())
        {
            GameOverController.setText("tie :(");

            SceneManager.LoadScene("gameOverScene");
        }

        togglePlayer();
    }
コード例 #22
0
        static void Main(string[] args)
        {
            var time = DateTime.Now;

            Console.Write("Enter height: ");
            int.TryParse(Console.ReadLine(), out int height);

            Console.Write("Enter width: ");
            int.TryParse(Console.ReadLine(), out int width);

            Console.Write("Enter the shape of your living cells (dead cells will be just empty spaces): ");
            string shape = Console.ReadLine();

            Console.Clear();

            var life = new CellController(shape);

            life.GenerateCells(height, width);

            life.DrawCells();
            while (life.GameIsNotOver)
            {
                var newTime = DateTime.Now;
                if (newTime.Second != time.Second)
                {
                    time = newTime;
                    life.UpdateGrid();
                    life.DrawCells();
                }
            }

            Console.WriteLine("Game is over. No conditions for the cells to reproduce.");
        }
コード例 #23
0
    // This cell defend against another
    public bool defendAgainst(CellController other)
    {
        //Debug.Log (name + " defends against " + other.name);
        float combat = other.power() - defense();
        bool  win;

        if (combat <= 0)           // successful defense against the others
        {
            other.updateHealthStats(combat);
            other.updateDefenseStats(-1.0f);
            updateDefenseStats(-1.0f);
            win = true;
        }
        else             // Lost
        {
            updateHealthStats(-combat);
            updateDefenseStats(-1.0f);
            other.updateDefenseStats(-1.0f);
            if (stats_health <= 0)
            {
                Destroy(gameObject);
                //Debug.Log (name + " dies ");
            }
            else
            {
                inContact [other.GetInstanceID()] = new Damage(combat, Time.time + 1);
            }
            win = false;
            // Keeps track of the damage if contact continues;
        }
        //Debug.Log(gameObject.name+"."+gameObject.tag+" defends against "+ other.name+"."+other.tag + " "+
        //	showStats()+ (win?"succeeded":"failed") );
        return(win);
    }
コード例 #24
0
    private void expand(CellController cell)
    {
        if (gameEnd)
        {
            return;
        }
        if (!cell.tile.activeInHierarchy)
        {
            return;
        }
        cell.tile.SetActive(false);

        if (checkGameEnd(cell))
        {
            endGame();
            cell.mine3.SetActive(true);
            return;
        }

        CellController[] neighbours = getNeighbours(cell);
        int bombsCount = countBombs(neighbours);

        if (bombsCount > 0)
        {
            cell.text.SetActive(true);
            cell.text.GetComponent <Text>().text = "" + bombsCount;
            return;
        }

        expandNeighbours(neighbours);
    }
コード例 #25
0
 void OnMouseDown()
 {
     // start the game once a cell is clicked
     if (selectedCell == null)   // nothing selected yet
     // if nothing on this cell, ignore
     {
         if (spriteRenderer.sprite != null && !IsHighlighted() &&
             spriteRenderer.sprite != highlightSprite)
         {
             selectedCell = this;
             Select();
             SoundManager.Instance.PlaySound(SoundType.TypeSelect);
         }
         return;
     }
     if (selectedCell == this)   // deselect
     {
         selectedCell = null;
         Clear();
     }
     else     // try moving from selectedCell to this
     {
         bool hasMoved = GameManager.Instance.TryMoveCell(selectedCell.indices, indices);
         if (hasMoved)   // deselect
         {
             selectedCell = null;
         }
         // else retains selection
     }
 }
コード例 #26
0
    Vector2[] GetCellsInShip(ShipController shipController)
    {
        CellController rootCell = shipController.root.GetComponent <CellController>();
        Vector2        rootPos  = new Vector2(rootCell.row, rootCell.col);
        Vector2        tailPos  = rootPos + new Vector2(
            shipController.direction.deltaVertical * (shipController.length - 1),
            shipController.direction.deltaHorizontal * (shipController.length - 1)
            );

        Vector2[] shipCells = new Vector2[shipController.length];
        int       i         = 0;
        int       maxRow    = Math.Max((int)rootPos.x, (int)tailPos.x);
        int       minRow    = Math.Min((int)rootPos.x, (int)tailPos.x);
        int       maxCol    = Math.Max((int)rootPos.y, (int)tailPos.y);
        int       minCol    = Math.Min((int)rootPos.y, (int)tailPos.y);

        for (int row = minRow; row <= maxRow; row++)
        {
            for (int col = minCol; col <= maxCol; col++)
            {
                shipCells[i] = new Vector2(row, col);
                i++;
            }
        }
        return(shipCells);
    }
コード例 #27
0
 public void FindPath(CellController start, CellController finish, Action <List <BlockController> > callback, bool checkObtacles = false)
 {
     Observable.Start(() => FindPathThread(start, finish, checkObtacles))
     //.TakeUntilDestroy(g.c)
     .ObserveOnMainThread()
     .Subscribe(callback);
 }
コード例 #28
0
ファイル: CellController.cs プロジェクト: gh272b/Corners
 // Start is called before the first frame update
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
 }
コード例 #29
0
ファイル: WorldManager.cs プロジェクト: MarkianovNikita/GGJ19
    private void SetZone(int zoneID, CellController cell, ZoneController zone, int currentSize)
    {
        cell.ZoneID = zoneID;
        zone.Cells.Add(cell);

        currentSize++;
        if (currentSize > _maxZoneSize)
        {
            return;
        }

        if (cell.LeftCell != null && cell.LeftCell.ZoneID < 0 && !cell.LeftCell.Empty)
        {
            SetZone(zoneID, cell.LeftCell, zone, currentSize);
        }
        if (cell.RightCell != null && cell.RightCell.ZoneID < 0 && !cell.RightCell.Empty)
        {
            SetZone(zoneID, cell.RightCell, zone, currentSize);
        }
        if (cell.TopCell != null && cell.TopCell.ZoneID < 0 && !cell.TopCell.Empty)
        {
            SetZone(zoneID, cell.TopCell, zone, currentSize);
        }
        if (cell.BottomCell != null && cell.BottomCell.ZoneID < 0 && !cell.BottomCell.Empty)
        {
            SetZone(zoneID, cell.BottomCell, zone, currentSize);
        }
    }
コード例 #30
0
 public Entity ReplaceCellView(CellController newTile) {
     var componentPool = GetComponentPool(CellsComponentIds.CellView);
     var component = (CellViewComponent)(componentPool.Count > 0 ? componentPool.Pop() : new CellViewComponent());
     component.Tile = newTile;
     ReplaceComponent(CellsComponentIds.CellView, component);
     return this;
 }
コード例 #31
0
 public void Clicked(CellController cell)
 {
     if (!Attack)
     {
         switch (this.state)
         {
             case CellState.None:
                 if (SelectedCells.Count < ShipAmount.TotalCellAmount)
                 {
                     this.state = CellState.Selected;
                     SelectedCells.Add(this);
                 }
                 break;
             case CellState.Selected:
                 this.state = CellState.None;
                 SelectedCells.Remove(this);
                 break;
         }
         this.Invalidate();
     }
     else
     {
         if (!Locked)
         {
             if (EnemyCell)
             {
                 state = CellState.Selected;
                 Invalidate();
                 ShipAmount.TotalCellAmount--;
             }
             MainController.DoAttack();
         }
     }
 }
コード例 #32
0
ファイル: GridManager.cs プロジェクト: ZuitSuit/GridTD
    // Update is called once per frame
    void Update()
    {
        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        if (Input.GetButtonDown("Fire"))
        {
            if (Physics.Raycast(ray, out hit, 1000f, FighterVision - 5)) //-1 to invert mask, -4 to ignore raycast
            {
                SelectActiveCell(false);

                if (hit.collider.gameObject.GetComponent <CellManager>() != null)
                {
                    selectedCell   = hit.collider.gameObject.GetComponent <CellManager>();
                    cellController = selectedCell.controller;
                    UIManager.Instance.BuildUI(cellController);
                    selectedCell.Selected(true);
                    //TODO controller calls build UI
                }

                else if (hit.collider.gameObject.GetComponent <WhereIs>() != null)
                {
                    whereIsBuffer = hit.collider.gameObject.GetComponent <WhereIs>();
                    fighterBuffer = whereIsBuffer.GetFighter();
                    if (fighterInFocus != null)
                    {
                        fighterInFocus.ToggleInFocus(false);
                    }
                    fighterInFocus = fighterBuffer;
                    fighterInFocus.ToggleInFocus(true);
                    UIManager.Instance.TrackFighter(fighterInFocus, whereIsBuffer, fighterBuffer.GetFighterType() == typeof(Tower));
                }
            }
        }
    }
コード例 #33
0
ファイル: PlayerController.cs プロジェクト: Bloodyaugust/ld33
 public void TargetCell(CellController cell)
 {
     if (selectedCell) {
         selectedCell.Target(cell);
         EnableTarget(cell.transform.position);
         AudioSource.PlayClipAtPoint(selectSource.clip, GameObject.FindWithTag("MainCamera").GetComponent<Camera>().ScreenToWorldPoint(new Vector3(0, 0, 0)));
     }
 }
コード例 #34
0
ファイル: CellInfo.cs プロジェクト: VegK/Interface
 /// <summary>
 /// Перенести дополнительные параметры ячейки и предмета в ячейке.
 /// </summary>
 /// <param name="cell">Ячейка.</param>
 public void MoveMoreParams(CellController cell)
 {
     var item = cell.Item;
     if (item != null)
     {
         item.Modification = Modification;
         item.RarityItem = (Rarity)RarityItem;
     }
 }
コード例 #35
0
ファイル: BaseInventory.cs プロジェクト: VegK/Interface
 /// <summary>
 /// Уничтожить объект в ячейке.
 /// </summary>
 /// <param name="cell">Ячейка с предметом.</param>
 public static void RecycleItem(CellController cell)
 {
     if (cell.Item != null)
     {
         Destroy(cell.Item.gameObject);
         LogController.Instance.AddString(String.Format("Предмет \"{0}\" удалён.", cell.Item.BaseItem.Name));
     }
     cell.Item = null;
 }
コード例 #36
0
ファイル: BaseInventory.cs プロジェクト: VegK/Interface
 /// <summary>
 /// Создать клона указанного предмета в указанной ячейки.
 /// </summary>
 /// <param name="cell">Ячейка в которой будет создан клон.</param>
 /// <param name="item">Предмет для клонирования.</param>
 public static ItemController CreateCloneItem(CellController cell, ItemController item)
 {
     ItemController clone = null;
     if (cell.CheckPutItem(item))
     {
         clone = Instantiate(item);
         clone.BaseItem = item.BaseItem;
         // TODO: Случайно задаём редкость предмета.
         clone.RarityItem = (Rarity)UnityEngine.Random.Range(0, 4);
         cell.PutItem(clone);
     }
     return clone;
 }
コード例 #37
0
ファイル: CellInfo.cs プロジェクト: VegK/Interface
        /// <summary>
        /// Получить CellInfo на основе CellController.
        /// </summary>
        /// <param name="cell">Ячейка.</param>
        public static CellInfo ToCellInfo(CellController cell)
        {
            var res = new CellInfo();
            res.IndexCell = cell.Index;

            var item = cell.Item;
            if (item != null)
            {
                res.IndexItem = item.BaseItem.Index;
                res.Modification = item.Modification;
                res.RarityItem = (int)item.RarityItem;
            }

            return res;
        }
コード例 #38
0
ファイル: FieldController.cs プロジェクト: VegK/Match3
    /// <summary>
    /// Создать новое поле.
    /// </summary>
    public void CreateField()
    {
        ClearField();

        _cells = new CellController[Width, Height];

        for (int x = 0; x < Width; x++)
        {
            for (int y = 0; y < Height; y++)
            {
                var obj = CreateCell(x, y);
                _cells[x, y] = obj;
            }
        }
    }
コード例 #39
0
ファイル: SpotController.cs プロジェクト: GreatVV/tactics
 public void Init(CellController cellController, int newDefenseRating = 1)
 {
     var position = transform.position;
     _spot = Pools.cells.CreateEntity()
                  .AddPosition(position.x, position.y, position.z)
                  .AddDefenseRating(newDefenseRating)
                  .AddView(gameObject);
     if (cellController != null)
     {
         _spot.ReplaceSpot(cellController.Entity, 0);
     }
     else
     {
         _spot.RemoveSpot();
     }
     Cell = cellController;
 }
コード例 #40
0
ファイル: VirionController.cs プロジェクト: Bloodyaugust/ld33
    void FixedUpdate()
    {
        float actualSpeed, randX, randY;

        if (target && target.owner != "body") {
            target = null;
            state = "untargeted";
        }

        if (target && state == "targeted") {
            actualSpeed = ((Mathf.Cos((Time.time + instanceID) * 12) + 1) / 2) * topSpeed;

            Vector3 directionVector = target.transform.position - transform.position;
            Vector2 directionVector2D;

            directionVector.Normalize();
            directionVector *= actualSpeed;

            directionVector2D = new Vector2(directionVector.x, directionVector.y);

            physicsBody.AddForce(directionVector2D);
        } else if (state == "untargeted") {
            timeToNewRoamHeading -= Time.deltaTime;

            if (timeToNewRoamHeading <= 0) {
                timeToNewRoamHeading = newRoamHeadingInterval;

                randX = Random.Range(-1f, 1f);
                randY = Random.Range(-1f, 1f);
                roamHeading = new Vector3(randX, randY, 0);
                roamHeading.Normalize();
            }
            actualSpeed = ((Mathf.Cos((Time.time + instanceID) * 12) + 1) / 2) * topSpeed;

            physicsBody.AddForce(roamHeading * actualSpeed);
        }
    }
コード例 #41
0
ファイル: FieldController.cs プロジェクト: VegK/Match3
    /// <summary>
    /// Изменить размер поля.
    /// </summary>
    /// <param name="clear">Очистить поле.</param>
    public void ResizeField(bool clear)
    {
        if (clear)
            ClearField();

        // Уничтожаем лишние объекты.
        if (Width < _cells.GetLength(0))
        {
            for (int x = Width; x < _cells.GetLength(0); x++)
                for (int y = 0; y < _cells.GetLength(1); y++)
                    if (_cells[x, y] != null)
                        DestroyImmediate(_cells[x, y].gameObject);
        }

        if (Height < _cells.GetLength(1))
        {
            for (int y = Height; y < _cells.GetLength(1); y++)
                for (int x = 0; x < _cells.GetLength(0); x++)
                    if (_cells[x, y] != null)
                        DestroyImmediate(_cells[x, y].gameObject);
        }

        // Формируем новое поле.
        var newCells = new CellController[Width, Height];

        // Создаём новые ячейки, если новый размер поля больше старого.
        if (Width > _cells.GetLength(0))
        {
            for (int x = _cells.GetLength(0); x < Width; x++)
                for (int y = 0; y < Height; y++)
                    if (newCells[x, y] == null)
                        newCells[x, y] = CreateCell(x, y);
        }

        if (Height > _cells.GetLength(1))
        {
            for (int y = _cells.GetLength(1); y < Height; y++)
                for (int x = 0; x < Width; x++)
                    if (newCells[x, y] == null)
                        newCells[x, y] = CreateCell(x, y);
        }

        // Переносим данные в новое поле.
        var minWidht = Width;
        if (_cells.GetLength(0) < Width)
            minWidht = _cells.GetLength(0);

        var minHeight = Height;
        if (_cells.GetLength(1) < Height)
            minHeight = _cells.GetLength(1);

        for (int x = 0; x < minWidht; x++)
            for (int y = 0; y < minHeight; y++)
                newCells[x, y] = _cells[x, y];
        _cells = newCells;
    }
コード例 #42
0
ファイル: FieldElements.cs プロジェクト: VegK/Match3
    /// <summary>
    /// Запустить анимацию смены местами элементов в ячейках.
    /// </summary>
    /// <param name="cell1">Ячейка.</param>
    /// <param name="cell2">Ячейка.</param>
    private IEnumerator PlaySwapAnimation(CellController cell1, CellController cell2)
    {
        _fixedField++;

        if (cell1.Y == cell2.Y)
        {
            if (cell1.X > cell2.X)
            {
                cell1.Element.AnimationLeft();
                cell2.Element.AnimationRight();
            }
            else
            {
                cell1.Element.AnimationRight();
                cell2.Element.AnimationLeft();
            }
        }
        else
        {
            if (cell1.Y > cell2.Y)
            {
                cell1.Element.AnimationDown();
                cell2.Element.AnimationUp();
            }
            else
            {
                cell1.Element.AnimationUp();
                cell2.Element.AnimationDown();
            }
        }

        // Ждём окончания анимаций.
        while (cell1.Element.AnimationIsPlay() && cell2.Element.AnimationIsPlay())
            yield return null;

        cell1.Element.transform.localPosition = new Vector3(0, 0, -1);
        cell2.Element.transform.localPosition = new Vector3(0, 0, -1);

        _fixedField--;
    }
コード例 #43
0
ファイル: BaseInventory.cs プロジェクト: VegK/Interface
 /// <summary>
 /// Положить предмет в ячейку.
 /// </summary>
 /// <param name="item">Предмет.</param>
 /// <param name="cell">Ячейка.</param>
 public static bool SetItemInCell(ItemController item, CellController cell)
 {
     if (cell == null)
         throw new NullReferenceException("Ячейка не может быть NULL.");
     return cell.PutItem(item);
 }
コード例 #44
0
ファイル: BaseInventory.cs プロジェクト: VegK/Interface
    /// <summary>
    /// Поменять местами предметы в ячейках.
    /// </summary>
    public static void SwapItemsInCell(CellController from, CellController to)
    {
        if (from == null || to == null)
            return;

        // Проверяем возможно ли перемещение предмета из ячейке назначения в ячейку "от куда".
        if (!from.CheckPutItem(to.Item))
            return;

        var tempItem = to.Item;
        var swap = SetItemInCell(from.Item, to);
        if (swap)
            SetItemInCell(tempItem, from);
    }
コード例 #45
0
ファイル: FieldElements.cs プロジェクト: VegK/Match3
 /// <summary>
 /// Опустить элемент если под ним пустая ячейка.
 /// </summary>
 /// <param name="cell">Ячейка с элементом.</param>
 private void LowerElement(CellController cell)
 {
     var x = cell.X;
     for (int y = cell.Y - 1; y >= 0; y--)
     {
         var cellY = _cells[x, y];
         if (cellY == null)
             continue;
         if (cellY.Element == null)
             StartCoroutine(LowerColumn(cell, cellY));
         break;
     }
 }
コード例 #46
0
	public CellController EditorSetCell(MapPoint point, CellController prefab)
	{
		if(point.X<0 || point.Y<0 || point.X>0xffff || point.Y>0xffff)
			return  null;
		
		CellController newCell = null;
		int key = point.toInt();
		if(!cells.ContainsKey(key))
		{
			newCell = CellController.InstantiateMe(prefab,transform,point);
			cells.Add(key,newCell);
		}
		else
			newCell = cells[key];
		
		return newCell;
	}
コード例 #47
0
ファイル: CellController.cs プロジェクト: Bloodyaugust/ld33
 public void Detarget()
 {
     targetCell = null;
 }
コード例 #48
0
ファイル: VirionController.cs プロジェクト: Bloodyaugust/ld33
 public void TargetCell(CellController cell)
 {
     target = cell;
 }
コード例 #49
0
ファイル: FieldElements.cs プロジェクト: VegK/Match3
    /// <summary>
    /// Уничтожить элементы с пометкой "Должен быть уничтожен".
    /// </summary>
    /// <param name="cell">Ячейка для проверки.</param>
    private void DestroyElementMustByDestroyed(CellController cell)
    {
        if (cell != null && cell.Element.MustByDestroyed)
            DestroyElement(cell);

        #region Горизонталь.
        // Вправо.
        for (int x = cell.X + 1; x < _cells.GetLength(0); x++)
        {
            var c = _cells[x, cell.Y];
            if (c != null && c.Element.MustByDestroyed)
                DestroyElement(c);
            else
                break;
        }
        // Влево.
        for (int x = cell.X - 1; x >= 0; x--)
        {
            var c = _cells[x, cell.Y];
            if (c != null && c.Element.MustByDestroyed)
                DestroyElement(c);
            else
                break;
        }
        #endregion
        #region Вертикаль.
        // Вверх.
        for (int y = cell.Y + 1; y < _cells.GetLength(1); y++)
        {
            var c = _cells[cell.X, y];
            if (c != null && c.Element.MustByDestroyed)
                DestroyElement(c);
            else
                break;
        }
        // Вниз.
        for (int y = cell.Y - 1; y >= 0; y--)
        {
            var c = _cells[cell.X, y];
            if (c != null && c.Element.MustByDestroyed)
                DestroyElement(c);
            else
                break;
        }
        #endregion
    }
コード例 #50
0
ファイル: FieldElements.cs プロジェクト: VegK/Match3
    /// <summary>
    /// Опустить элементы в столбце включая текущий и выше.
    /// </summary>
    /// <param name="cell">Ячейка содержащая элемент для опускания.</param>
    /// <param name="toCell">Куда опускать.</param>
    private IEnumerator LowerColumn(CellController cell, CellController toCell)
    {
        var x = cell.X;

        _fixedField++;
        while (_fixedColumn[x] > 0)
            yield return null;

        var prevCell = toCell;
        for (int y = cell.Y; y < _cells.GetLength(1); y++)
        {
            var cellY = _cells[x, y];
            if (cellY == null)
                continue;
            if (cellY.Element == null)
                break;

            StartCoroutine(LowerColumnElement(cellY, prevCell));
            prevCell = cellY;
        }
        _fixedField--;
    }
コード例 #51
0
ファイル: FieldElements.cs プロジェクト: VegK/Match3
    /// <summary>
    /// Опустить элемент до дна.
    /// </summary>
    /// <param name="cell">Элемент.</param>
    /// <param name="toCell">Свободная ячейка под элементом.</param>
    private IEnumerator LowerColumnElement(CellController cell, CellController toCell)
    {
        _fixedField++;
        _fixedColumn[cell.X]++;

        cell.Element.AnimationLower();
        while (cell.Element.AnimationIsPlay())
            yield return null;

        _fixedField--;
        _fixedColumn[cell.X]--;

        cell.Element.transform.localPosition = new Vector3(0, 0, -1);
        SwapElements(toCell, cell);

        LowerElement(toCell);
    }
コード例 #52
0
ファイル: CellController.cs プロジェクト: Bloodyaugust/ld33
    // Update is called once per frame
    void Update()
    {
        GameObject newVirion;
        VirionController newVirionController;
        float integrityScale, infectionScale, indicatorScale;

        if (!dead) {
            if (owner == "body") {
                if (generatesBodies) {
                    indicatorScale = (Mathf.Cos(Time.time * 16) * 0.1f) + 2;

                    generationIndicator.transform.localScale = new Vector3(indicatorScale, indicatorScale, 1);
                }
            } else {
                timeToSpawn -= Time.deltaTime;
                timeToFire -= Time.deltaTime;

                if (timeToSpawn <= 0) {
                    timeToSpawn = spawnInterval;
                    virusCount++;
                    virusCountText.text = virusCount + "";
                }

                if (targetCell) {
                    if (targetCell.owner != "body") {
                        targetCell = null;
                    }
                }

                if (targetCell && virusCount > 1 && timeToFire <= 0) {
                    newVirion = Instantiate(VirionPrefab, transform.position, Quaternion.identity) as GameObject;
                    newVirionController = newVirion.GetComponent<VirionController>();
                    newVirionController.TargetCell(targetCell);
                    virusCount--;
                    virusCountText.text = virusCount + "";
                    timeToFire = fireInterval;
                }
            }

            integrityScale = Mathf.Lerp(0, 1, integrity / maxIntegrity);
            infectionScale = Mathf.Lerp(0, 1, infection / integrity);

            integrityBar.localScale = new Vector3(integrityScale, 1, 1);
            infectionBar.localScale = new Vector3(infectionScale, 1, 1);
        } else {
            Destroy(gameObject);
        }
    }
コード例 #53
0
	public CellController ReplaceCell(MapPoint point, CellController prefab)
	{
		if(point.X<0 || point.Y<0 || point.X>0xffff || point.Y>0xffff)
			return null;


		CellController newCell = CellController.InstantiateMe(prefab,transform,point);


		MapRect rect = prefab.GetCellIndexes(point,selectedRotation);
		rect.Foreach((MapPoint p) => {

			int key = p.toInt();
			if(cells.ContainsKey(key))
			{
				GameObject.Destroy(cells[key].gameObject);
				cells.Remove(key);
				cells[key] = newCell;
			}
		});

		newCell.SetRotation(selectedRotation);

		return newCell;
	}
コード例 #54
0
ファイル: FieldElements.cs プロジェクト: VegK/Match3
    /// <summary>
    /// Поменять местами элементы в ячейках.
    /// </summary>
    /// <param name="cell1">Ячейка.</param>
    /// <param name="cell2">Ячейка.</param>
    private void SwapElements(CellController cell1, CellController cell2)
    {
        if (cell1.Element != null)
            cell1.Element.transform.SetParent(cell2.transform, false);
        if (cell2.Element != null)
            cell2.Element.transform.SetParent(cell1.transform, false);

        var element = cell1.Element;
        cell1.Element = cell2.Element;
        cell2.Element = element;
    }
コード例 #55
0
ファイル: FieldElements.cs プロジェクト: VegK/Match3
    /// <summary>
    /// Уничтожить элемент в ячейке.
    /// </summary>
    /// <param name="cell">Ячейка.</param>
    private void DestroyElement(CellController cell)
    {
        var trans = cell.transform;
        Instantiate(Parameters.Instance.PrefabExplosion, trans.position, trans.rotation);

        Destroy(cell.Element.gameObject);
        cell.Element = null;
        DestroyElementsCount++;
    }
コード例 #56
0
	public static CellController InstantiateMe(CellController prefab, Transform parent, MapPoint point)
	{
		CellController newCell = Instantiate<CellController>(prefab);
		newCell.PrefabName = prefab.name;
		newCell.transform.parent = parent;
		newCell.Position = point;
		return newCell;
	}
コード例 #57
0
ファイル: Level2Controller.cs プロジェクト: Bloodyaugust/ld33
 // Use this for initialization
 void Start()
 {
     healthyCellController = healthyCell.GetComponent<CellController>();
     winText = winText.GetComponent<Text>();
 }
コード例 #58
0
ファイル: FieldElements.cs プロジェクト: VegK/Match3
    /// <summary>
    /// Создать случайный элемент в ячейке.
    /// </summary>
    /// <param name="cell">Ячейка в которой будет элемент.</param>
    /// <returns>Созданный элемент.</returns>
    private ElementController CreateElement(CellController cell)
    {
        var rnd = UnityEngine.Random.Range(0, PrefabElements.Length);
        var element = PrefabElements[rnd];
        var res = Instantiate(element);

        cell.Element = res;

        var pos = Vector3.zero;
        pos.z = -1;
        res.transform.position = pos;
        res.transform.SetParent(cell.transform, false);
        return res;
    }
コード例 #59
0
ファイル: FieldElements.cs プロジェクト: VegK/Match3
    /// <summary>
    /// Выбрать элемент.
    /// </summary>
    /// <param name="cell">Ячейка.</param>
    private IEnumerator SelectionElement(CellController selected)
    {
        if (_fixedField > 0)
            yield break;

        if (_firstSelected == selected || selected == null)
        {
            _firstSelected.Element.StopAnimations();
            _firstSelected = null;
            yield break;
        }

        if (_firstSelected == null)
        {
            _firstSelected = selected;
            _firstSelected.Element.AnimationSelected();
        }
        else
        {
            _firstSelected.Element.StopAnimations();
            selected.Element.StopAnimations();

            var swap = false;
            if (selected.X <= _firstSelected.X + 1 &&
                selected.X >= _firstSelected.X - 1 &&
                selected.Y == _firstSelected.Y ||
                selected.Y <= _firstSelected.Y + 1 &&
                selected.Y >= _firstSelected.Y - 1 &&
                selected.X == _firstSelected.X)
                swap = true;
            if (swap)
            {
                yield return StartCoroutine(PlaySwapAnimation(selected, _firstSelected));
                SwapElements(selected, _firstSelected);

                var dest = (CheckElementDestroyed(selected).Count > 0);
                if (!dest)
                    dest = (CheckElementDestroyed(_firstSelected).Count > 0);
                if (dest)
                {
                    StartCoroutine(FullCheckField());
                }
                else
                {
                    yield return StartCoroutine(PlaySwapAnimation(selected, _firstSelected));
                    SwapElements(_firstSelected, selected);
                }
            }

            _firstSelected = null;
        }
    }
コード例 #60
0
ファイル: FieldElements.cs プロジェクト: VegK/Match3
    /// <summary>
    /// Проверить элемент на уничтожение.
    /// </summary>
    /// <param name="cell">Ячейка для проверки.</param>
    /// <returns>Список ячеек для уничтожения.</returns>
    private List<CellController> CheckElementDestroyed(CellController cell)
    {
        var res = new List<CellController>();
        var element = cell.Element;

        #region Горизонталь.
        var destroy = false;

        if (cell.X - 1 >= 0 && cell.X + 1 < _cells.GetLength(0) &&
            _cells[cell.X - 1, cell.Y] != null &&
            _cells[cell.X + 1, cell.Y] != null &&
            _cells[cell.X - 1, cell.Y].Element.Type == element.Type &&
            _cells[cell.X + 1, cell.Y].Element.Type == element.Type)
        {
            destroy = true;
        }
        else if (cell.X - 2 >= 0 &&
            _cells[cell.X - 1, cell.Y] != null &&
            _cells[cell.X - 2, cell.Y] != null &&
            _cells[cell.X - 1, cell.Y].Element.Type == element.Type &&
            _cells[cell.X - 2, cell.Y].Element.Type == element.Type)
        {
            destroy = true;
        }
        else if (cell.X + 2 < _cells.GetLength(0) &&
            _cells[cell.X + 1, cell.Y] != null &&
            _cells[cell.X + 2, cell.Y] != null &&
            _cells[cell.X + 1, cell.Y].Element.Type == element.Type &&
            _cells[cell.X + 2, cell.Y].Element.Type == element.Type)
        {
            destroy = true;
        }

        if (destroy)
        {
            // Вправо.
            for (int x = cell.X + 1; x < _cells.GetLength(0); x++)
            {
                var c = _cells[x, cell.Y];
                if (c != null && c.Element.Type == element.Type)
                    res.Add(c);
                else
                    break;
            }
            // Влево.
            for (int x = cell.X - 1; x >= 0; x--)
            {
                var c = _cells[x, cell.Y];
                if (c != null && c.Element.Type == element.Type)
                    res.Add(c);
                else
                    break;
            }
        }
        #endregion
        #region Вертикаль.
        destroy = false;

        if (cell.Y - 1 >= 0 && cell.Y + 1 < _cells.GetLength(1) &&
            _cells[cell.X, cell.Y - 1] != null &&
            _cells[cell.X, cell.Y + 1] != null &&
            _cells[cell.X, cell.Y - 1].Element.Type == element.Type &&
            _cells[cell.X, cell.Y + 1].Element.Type == element.Type)
        {
            destroy = true;
        }
        else if (cell.Y - 2 >= 0 &&
            _cells[cell.X, cell.Y - 1] != null &&
            _cells[cell.X, cell.Y - 2] != null &&
            _cells[cell.X, cell.Y - 1].Element.Type == element.Type &&
            _cells[cell.X, cell.Y - 2].Element.Type == element.Type)
        {
            destroy = true;
        }
        else if (cell.Y + 2 < _cells.GetLength(1) &&
            _cells[cell.X, cell.Y + 1] != null &&
            _cells[cell.X, cell.Y + 2] != null &&
            _cells[cell.X, cell.Y + 1].Element.Type == element.Type &&
            _cells[cell.X, cell.Y + 2].Element.Type == element.Type)
        {
            destroy = true;
        }

        if (destroy)
        {
            // Вверх.
            for (int y = cell.Y + 1; y < _cells.GetLength(1); y++)
            {
                var c = _cells[cell.X, y];
                if (c != null && c.Element.Type == element.Type)
                    res.Add(c);
                else
                    break;
            }
            // Вниз.
            for (int y = cell.Y - 1; y >= 0; y--)
            {
                var c = _cells[cell.X, y];
                if (c != null && c.Element.Type == element.Type)
                    res.Add(c);
                else
                    break;
            }
        }
        #endregion

        if (res.Count > 0)
            res.Add(cell);
        return res;
    }