public void SetLastConnect(HexagonalCell last) { lastCellConnect = last; if (lastCellConnect == null) { return; } if (allCombinations.Count >= 1) { for (int _combo = 0; _combo < allCombinations.Count; _combo++) { if (allCombinations[_combo].currentCombination == last.GetCurrentCombination()) { int lenght = allCombinations[_combo].cards.Length; for (int _card = 0; _card < lenght; _card++) { if (allCombinations[_combo].cards[_card].Info.myX == lastCellConnect.Info.myX && allCombinations[_combo].cards[_card].Info.myY == lastCellConnect.Info.myY) { var _swap = allCombinations[_combo]; allCombinations[_combo] = allCombinations[0]; allCombinations[0] = _swap; StopCoroutine("FlashCombinationAlternately"); StartCoroutine("FlashCombinationAlternately"); } } } } } }
public void ActivatePanel(HexagonalCell _cell) { currentCell = _cell; panel.SetActive(true); eCards color = currentCell.GetCard().Info.myColor; bubna.SetActive(true); chirwa.SetActive(true); cross.SetActive(true); pika.SetActive(true); if (color == eCards.Bubna) { bubna.SetActive(false); } if (color == eCards.Chirwa) { chirwa.SetActive(false); } if (color == eCards.Cross) { cross.SetActive(false); } if (color == eCards.Pika) { pika.SetActive(false); } }
public void SetCellSwapDown(HexagonalCell _cell) { if (currentActivSlot != null && currentActivSlot.GetBonus() == eSpecialCard.swap) { swapCell = _cell; } }
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); } } }
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); } } }
private void AutoAddComboCombination(CombinationData _combination) { List <CombinationData> _combo = new List <CombinationData>(); _combo.Add(_combination); int lenghAll = allCombinations.Count; if (lenghAll < 1) { return; } for (int all = 0; all < lenghAll; all++) { if (!_combo.Contains(allCombinations[all])) { for (int current = 0; current < _combo.Count; current++) { int lenghCard = _combo[current].cards.Length; for (int card = 0; card < lenghCard; card++) { if (allCombinations[all].cards.Contains(_combo[current].cards[card])) { HexagonalCell _cell = HexagonalGrid.Instance.GetCell(_combo[current].cards[card].Info.myX, _combo[current].cards[card].Info.myY); BonusManager.Instance.CreateBonus(_cell, allCombinations[all]); _combo.Add(allCombinations[all]); card = lenghCard; current = _combo.Count; all = 0; } } } } } AddScores(_combo.ToArray()); }
public void SetCellSwapEnter(HexagonalCell _cell) { if (isNeedActivateBonus && currentActivSlot != null && currentActivSlot.GetBonus() == eSpecialCard.swap && swapCell != null) { if (!HexagonalGrid.Instance.GetNearFullCells(swapCell.Info.myX, swapCell.Info.myY).Contains(_cell)) { swapCell = null; return; } SoundManager.Instance.PlayBonusStart(eSpecialCard.swap, false); GlobalInfo.canCombination = false; CardData swapCard = new CardData(); swapCard.myColor = swapCell.GetCard().Info.myColor; swapCard.myNumCard = swapCell.GetCard().Info.myNumCard; swapCard.mySpecialCard = swapCell.GetCard().Info.mySpecialCard; swapCard.isClosed = swapCell.GetCard().GetIsClosed(); swapCell.GetCard().SetMovePositionCallBack(_cell.transform.position, (delegate() { swapCell.InitCardInCellWithCheckClosed((int)_cell.GetCard().Info.myColor, _cell.GetCard().Info.myNumCard, _cell.GetCard().Info.mySpecialCard, _cell.GetCard().GetIsClosed()); })); _cell.GetCard().SetMovePositionCallBack(swapCell.transform.position, (delegate() { _cell.InitCardInCellWithCheckClosed((int)swapCard.myColor, swapCard.myNumCard, swapCard.mySpecialCard, swapCard.isClosed); swapCell = null; ManagerCombination.Instance.ClearMatchCells(); GlobalInfo.canCombination = true; })); currentActivSlot.ClearSlot(); } }
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(); } } }
private void ClearCellFromCard(float maxScore, CombinationData _combinations) { int lenght = _combinations.cards.Length; float scoreOnCell = maxScore / lenght; for (int i = 0; i < lenght; i++) { HexagonalCell _cell = HexagonalGrid.Instance.GetCell(_combinations.cards[i].Info.myX, _combinations.cards[i].Info.myY); _cell.ClearFromCard((int)scoreOnCell, _combinations.currentCombination); } }
private void FlashingCoroutineInCell(CombinationData _combination) { int lengCard = _combination.cards.Length; for (int y = 0; y < lengCard; y++) { eCombination _comb = _combination.currentCombination; HexagonalCell _cell = HexagonalGrid.Instance.GetCell(_combination.cards[y].Info.myX, _combination.cards[y].Info.myY); _cell.FlashingCoroutine(_comb); } }
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); } } } }
private void CreateClosedCardNearFull() { int lenght = ManagerCombination.Instance.GetLenghtAllCombination(); for (int i = 0; i < lenght; i++) { HexagonalCell _cell = HexagonalGrid.Instance.GetRandomEmptyCellNearFull(); if (_cell != null) { CardData _card = PollCards.Instance.GetNewCard(); _cell.InitCardInCell((int)_card.myColor, _card.myNumCard, _card.mySpecialCard); _cell.GetCard().SetIsClosed(true); } } currentProgress = 0; }
public void SetCellOnClick(HexagonalCell _cell) { if (isNeedActivateBonus) { if (currentActivSlot != null) { currentActivSlot.ActivateBackImageCard(false); } isNeedActivateBonus = false; MechanicsBonuses(_cell); } else { currentActivSlot = null; } }
private void FillCell(HexagonalCell _cell) { /* * if ( HexagonalGrid.Instance.CheckSameCard(_cell.myX, _cell.myY, myCard.info)) * { * Debug.Log("same card"); * SoundManager.Instance.PlaySameCard(); * RestartCard(); * } * else * { * } */ lastConnect = _cell; _cell.InitCardInCell((int)myCard.Info.myColor, myCard.Info.myNumCard, myCard.Info.mySpecialCard); CreateNewCard(); }
public void AutoCombinationCheck(HexagonalCell _card) { for (int i = 0; i < allCombinations.Count; i++) { if (allCombinations[i].currentCombination == _card.GetCurrentCombination()) { int lenght = allCombinations[i].cards.Length; for (int y = 0; y < lenght; y++) { if (allCombinations[i].cards[y].Info.myX == _card.Info.myX && allCombinations[i].cards[y].Info.myY == _card.Info.myY) { AutoAddComboCombination(allCombinations[i]); return; } } } } }
public void CreateBonus(HexagonalCell _cell, CombinationData _combination) { int random = UnityEngine.Random.Range(0, 100); if (random > GlobalInfo.changeDropBonus) { return; } int maxNumCard = GetMaxNumCard(_combination); string _combo = _combination.currentCombination.ToString() + maxNumCard.ToString(); eSpecialCard _bonus = GetBonusReward(_combo); if (_bonus != eSpecialCard.none) { BonusItem _items = GetNotActiveBonusItem(); _items.gameObject.SetActive(true); _items.transform.position = _cell.transform.position; _items.Init(_bonus); BonusSlot _freeslot = GetFreeBonusSlot(); if (_freeslot != null) { _items.MoveFreeSlot(_freeslot); } else { // _freeslot = GetSameBonusInSlot(_bonus); if (_freeslot != null) { _items.MoveFreeSlot(_freeslot); } else { _items.InvokeDeactivate(); } } } else { Debug.LogError("_bonus == eSpecialCard.none"); } }
private void FindVectroMove() { if (Input.GetMouseButtonUp(0)) { if (canMoving && isTouch) { if (myCard.Info.mySpecialCard == eSpecialCard.Joker || myCard.Info.mySpecialCard.ToString().Contains("bullet")) { SoundManager.Instance.PlayBonusStart(myCard.Info.mySpecialCard, false); } VectorMove(Input.mousePosition); } if (isFlight && flightCell != null) { FillCell(flightCell); flightCell = null; RestartCard(); } } }
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()); }
// Use this for initialization void Awake() { myCell = transform.GetComponentInParent <HexagonalCell>(); }
private void MechanicsBonuses(HexagonalCell _cell) { SoundManager.Instance.PlayBonusStart(currentBonus, false); string strCurrentBonus = currentBonus.ToString(); if (strCurrentBonus.Contains("upend")) { isNeedActivateBonus = true; if (!_cell.GetCard().GetIsClosed()) { return; } currentActivSlot.ActivateBackImageCard(true); _cell.SetFlashingBack(false); _cell.GetCard().SetIsClosed(false); canUppend--; ManagerCombination.Instance.ClearMatchCells(); if (canUppend <= 0) { currentActivSlot.ClearSlot(); isNeedActivateBonus = false; HexagonalCell[] closedCells = HexagonalGrid.Instance.GetAllClosedCard(); for (int i = 0; i < closedCells.Length; i++) { closedCells[i].SetFlashingBack(false); } } } else if (strCurrentBonus.Contains("wind")) { int step = 0; if (currentBonus == eSpecialCard.wind1) { step = 1; } if (currentBonus == eSpecialCard.wind2) { step = 2; } if (currentBonus == eSpecialCard.wind3) { step = 3; } currentActivSlot.GetMyCard().SetMovePositionCallBack(_cell.transform.position, (delegate() { HexagonalGrid.Instance.WindFallNearCard(_cell.Info.myX, _cell.Info.myY, step); BonusManager.Instance.ClearCurrentBonusSlot(); ManagerCombination.Instance.ClearMatchCells(); activCard.SetEnableImageCard(true); })); } else if (strCurrentBonus.Contains("fireworks")) { int step = 0; if (currentBonus == eSpecialCard.fireworks2) { step = 1; } if (currentBonus == eSpecialCard.fireworks3) { step = 2; } currentActivSlot.GetMyCard().SetMovePositionCallBack(_cell.transform.position, (delegate() { HexagonalGrid.Instance.FallNearCard(_cell.Info.myX, _cell.Info.myY, step); BonusManager.Instance.ClearCurrentBonusSlot(); ManagerCombination.Instance.ClearMatchCells(); activCard.SetEnableImageCard(true); })); } else if (currentBonus == eSpecialCard.copy && !_cell.GetCard().GetIsClosed()) { if (!activCard.GetIsMoving()) { activCard.AppearanceInit((int)_cell.GetCard().Info.myColor, _cell.GetCard().Info.myNumCard, eSpecialCard.none); currentActivSlot.ClearSlot(); } } else if (currentBonus == eSpecialCard.chameleon && !_cell.GetCard().GetIsClosed() && _cell.GetCard().Info.mySpecialCard == eSpecialCard.none) { chameleonPanel.ActivatePanel(_cell); currentActivSlot.ClearSlot(); } else if (currentBonus == eSpecialCard.decrease && !_cell.GetCard().GetIsClosed() && _cell.GetCard().Info.myNumCard > 2) { _cell.GetCard().DecreaseCard(); currentActivSlot.ClearSlot(); } else if (currentBonus == eSpecialCard.increase && !_cell.GetCard().GetIsClosed() && _cell.GetCard().Info.myNumCard < 14) { _cell.GetCard().IncreaseCard(); currentActivSlot.ClearSlot(); } }