Esempio n. 1
0
        public HexagonalCell GetEmptyCellFromNearVector(Vector3 _pos)
        {
            float         distanceMin = 999;
            HexagonalCell cellNear    = null;

            for (int y = 0; y < GlobalInfo.column; y++)
            {
                for (int x = 0; x < GlobalInfo.row; x++)
                {
                    HexagonalCell _cell = GetCell(x, y);
                    if (_cell != null && !_cell.GetIsFull())
                    {
                        float distanceCurrent = Vector3.Distance(_cell.transform.position, _pos);
                        if (distanceMin > distanceCurrent)
                        {
                            distanceMin = distanceCurrent;
                            cellNear    = _cell;
                            if (distanceMin < 20)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            return(cellNear);
        }
Esempio n. 2
0
        private void InitCells(float distanceX, float distanceY, int x, int y)
        {
            GameObject obj = Instantiate(prefabCell, new Vector3(distanceX, distanceY, 0), Quaternion.identity) as GameObject;

            obj.transform.SetParent(transform);
            obj.transform.localScale = Vector3.one;
            obj.name = x.ToString() + "x " + y.ToString() + "y";
            HexagonalCell _cell = obj.GetComponent <HexagonalCell>();

            cells[x, y] = _cell;
            _cell.InitCoordinate(x, y);

            if (LoadManager.Instance != null && LoadManager.Instance.needLoad)
            {
                CardData _card = LoadManager.Instance.SaveInfo.Cards.FirstOrDefault(card => card.myX == x && card.myY == y);
                if (_card != null && _card.myColor != 0 && _card.myColor != 0)
                {
                    _cell.InitCardInCellWithCheckClosed((int)_card.myColor, _card.myNumCard, _card.mySpecialCard, _card.isClosed);
                }
            }
            else
            {
                if (y <= startInitCell)
                {
                    InitCardInCell(_cell);
                }
            }
        }
Esempio n. 3
0
        public HexagonalCell[]  GetAllCells()
        {
            List <HexagonalCell> allCells = new List <HexagonalCell>();

            for (int y = 0; y < GlobalInfo.column; y++)
            {
                for (int x = 0; x < GlobalInfo.row; x++)
                {
                    HexagonalCell _cell = GetCell(x, y);
                    if (_cell != null)
                    {
                        allCells.Add(_cell);
                    }
                }
            }
            return(allCells.ToArray());
        }
Esempio n. 4
0
        public HexagonalCell[] GetAllClosedCard()
        {
            List <HexagonalCell> allClosed = new List <HexagonalCell> ();

            for (int y = 0; y < GlobalInfo.column; y++)
            {
                for (int x = 0; x < GlobalInfo.row; x++)
                {
                    HexagonalCell _cell = GetCell(x, y);
                    if (_cell != null)
                    {
                        _cell.SetFlashingBack(false);
                        if (_cell.GetIsFull() && _cell.GetCard().GetIsClosed())
                        {
                            allClosed.Add(_cell);
                        }
                    }
                }
            }
            return(allClosed.ToArray());
        }
Esempio n. 5
0
        public HexagonalCell GetRandomEmptyCellNearFull()
        {
            HexagonalCell _cell   = null;
            int           _random = Random.Range(1, GlobalInfo.row);

            for (int y = 0; y < GlobalInfo.column; y++)
            {
                for (int x = 0; x < GlobalInfo.row; x++)
                {
                    if (ExistCell(x, y) && !cells[x, y].GetIsFull() && GetNearIsFull(x, y))
                    {
                        _cell = cells[x, y];
                        _random--;
                        if (_random <= 0)
                        {
                            return(_cell);
                        }
                    }
                }
            }
            return(_cell);
        }
Esempio n. 6
0
        private void InitCardInCell(HexagonalCell _cell)
        {
            CardData _card = PollCards.Instance.GetNewCard();

            _cell.InitCardInCell((int)_card.myColor, _card.myNumCard, _card.mySpecialCard);
        }