Example #1
0
 private void CollisionCell(HexagonalCell _cell)
 {
     if (_cell.GetIsFull())
     {
         if ((int)myCard.Info.mySpecialCard >= (int)eSpecialCard.bullet1 && (int)myCard.Info.mySpecialCard <= (int)eSpecialCard.bullet5)
         {
             _cell.ShootingCard();
             if (myCard.Info.mySpecialCard == eSpecialCard.bullet1)
             {
                 CreateNewCard();
                 return;
             }
             else
             {
                 myCard.Info.mySpecialCard = (eSpecialCard)((int)myCard.Info.mySpecialCard - 1);
             }
         }
         else
         {
             HexagonalCell[] nearEmptyCell = HexagonalGrid.Instance.GetNearEmpyCells(_cell.Info.myX, _cell.Info.myY);
             float[]         distances     = new float[nearEmptyCell.Length];
             int             min           = 0;
             float           minvalue      = 999;
             for (int i = 0; i < nearEmptyCell.Length; i++)
             {
                 distances[i] = Vector3.Distance(transform.position, nearEmptyCell[i].transform.position);
                 if (minvalue > distances[i])
                 {
                     min      = i;
                     minvalue = distances[i];
                 }
             }
             FillCell(nearEmptyCell[min]);
             return;
         }
     }
     if (_cell.Info.myY == 0)
     {
         if (!_cell.GetIsFull())
         {
             if (myCard.Info.mySpecialCard == eSpecialCard.none || myCard.Info.mySpecialCard == eSpecialCard.Joker)
             {
                 FillCell(_cell);
             }
             else
             {
                 CreateNewCard();
             }
         }
         else
         {
             CreateNewCard();
         }
     }
 }
Example #2
0
 private void OnTriggerEnter2D(Collider2D obj)
 {
     if (tag == "special")
     {
         HexagonalCell _cell = obj.GetComponent <HexagonalCell>();
         if (_cell != null && _cell.GetIsFull())
         {
             eSpecialCard currentBonus = BonusManager.Instance.GetCurrentActivSlot().GetBonus();
             int          step         = 0;
             if (currentBonus == eSpecialCard.wind1)
             {
                 step = 1;
             }
             if (currentBonus == eSpecialCard.wind2)
             {
                 step = 2;
             }
             if (currentBonus == eSpecialCard.wind3)
             {
                 step = 3;
             }
             if (step == 0)
             {
                 return;
             }
             StopCoroutine("MoveNewPosition");
             imageCard.transform.localPosition = Vector3.zero;
             HexagonalGrid.Instance.WindFallNearCard(_cell.Info.myX, _cell.Info.myY, step);
             BonusManager.Instance.ClearCurrentBonusSlot();
             ManagerCombination.Instance.ClearMatchCells();
             FindObjectOfType <ActivCardMoving>().SetEnableImageCard(true);
         }
     }
 }
Example #3
0
 private void OnTriggerEnter2D(Collider2D obj)
 {
     if (isFlight)
     {
         HexagonalCell _cell = obj.GetComponent <HexagonalCell>();
         if (_cell != null && !_cell.GetIsFull())
         {
             flightCell = _cell;
         }
     }
     if (isMoving)
     {
         HexagonalCell _cell = obj.GetComponent <HexagonalCell>();
         if (_cell != null)
         {
             if (_cell.Info.myY == GlobalInfo.column - 1 && _cell.GetIsFull() && myCard.Info.mySpecialCard == eSpecialCard.none)
             {
                 isMoving = false;
                 hud.Lose();
                 return;
             }
             CollisionCell(_cell);
         }
     }
 }
Example #4
0
 public void CheckCombinationCell()
 {
     for (int y = 0; y < GlobalInfo.column; y++)
     {
         for (int x = 0; x < GlobalInfo.row; x++)
         {
             HexagonalCell _cell = HexagonalGrid.Instance.GetCell(x, y);
             if (_cell != null && _cell.GetIsFull())
             {
                 CheckCardsIn5Cells(x, y);
             }
         }
     }
 }
Example #5
0
        private void CheckCardsIn5Cells(int _x, int _y)
        {
            List <Card> _cardsX  = new List <Card>();
            List <Card> _cardsY  = new List <Card>();
            List <Card> _cardsYX = new List <Card>();

            for (int i = 0; i < 5; i++)
            {
                HexagonalCell _cell = HexagonalGrid.Instance.GetCell(_x + i, _y);
                if (_cell != null && _cell.GetIsFull() && !_cell.GetCard().GetIsClosed())
                {
                    _cardsX.Add(_cell.GetCard());
                }
                else
                {
                    break;
                }
            }
            int myXminus = _x;
            int myYleft  = _y;

            for (int i = 0; i < 5; i++)
            {
                if (i > 0)
                {
                    if ((myYleft + i) % 2 == 0)
                    {
                    }
                    else
                    {
                        myXminus--;
                    }
                }

                HexagonalCell _cell = HexagonalGrid.Instance.GetCell(myXminus, myYleft + i);
                if (_cell != null && _cell.GetIsFull() && !_cell.GetCard().GetIsClosed())
                {
                    _cardsY.Add(_cell.GetCard());
                }
                else
                {
                    break;
                }
            }
            int myXplus  = _x;
            int myYright = _y;

            for (int i = 0; i < 5; i++)
            {
                if (i > 0)
                {
                    if ((myYright + i) % 2 == 0)
                    {
                        myXplus++;
                    }
                }

                HexagonalCell _cell = HexagonalGrid.Instance.GetCell(myXplus, myYright + i);
                if (_cell != null && _cell.GetIsFull() && !_cell.GetCard().GetIsClosed())
                {
                    _cardsYX.Add(_cell.GetCard());
                }
                else
                {
                    break;
                }
            }
            CheckCombinationIn5Cards(_cardsX.ToArray());
            CheckCombinationIn5Cards(_cardsY.ToArray());
            CheckCombinationIn5Cards(_cardsYX.ToArray());
        }