Beispiel #1
0
 public bool TryFindHint(bool isBigHint, bool onlycheck = false)
 {
     GameObject[,] allObjects = mover.GetAllObjects();
     for (int i = 0; i < allObjects.GetLength(0); i++)
     {
         for (int j = 0; j < allObjects.GetLength(1); j++)
         {
             Movable curMovable = allObjects[i, j].GetComponent <Movable>();
             if (curMovable == null)
             {
                 continue;
             }
             Movable rightMovable = curMovable.GetNeighborMovable(Vector2Int.right, allObjects);
             Movable upMovable    = curMovable.GetNeighborMovable(Vector2Int.up, allObjects);
             if (rightMovable != null)
             {
                 if (TryAnimateHint(curMovable, rightMovable, Vector2Int.right, allObjects, isBigHint, onlycheck) == true)
                 {
                     return(true);
                 }
             }
             if (upMovable != null)
             {
                 if (TryAnimateHint(curMovable, upMovable, Vector2Int.up, allObjects, isBigHint, onlycheck) == true)
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Beispiel #2
0
        public void TryToChange(FruitWithDir data)
        {
            if (gameState == GameState.Wait)
            {
                return;
            }
            Movable mainFruit  = data.Fruit.GetComponent <Movable>();
            Movable otherFruit = mainFruit.GetNeighborMovable(data.Dir, _allObjects);

            if (CanChange(mainFruit, data.Dir))
            {
                gameState = GameState.Wait;
                ChangeFruits(mainFruit, otherFruit);
                EventHolder.startAnimation.Invoke(moveSpeed);
                List <Combine> matchesList = finder.GetCombinedObjects(_allObjects);
                AudioManager.Instance.SwipeSound();
                if (matchesList.Count == 0)
                {
                    StartCoroutine(RevertGems(mainFruit, otherFruit));
                }
                else
                {
                    taskManager.MadeMove();
                    shredder.MakeDamage(matchesList);
                    StartCoroutine(shredder.FruitsDestroy(_allObjects, moveSpeed + 0.1f));
                }
            }
        }
Beispiel #3
0
 private bool CanChange(Movable movable, Vector2Int dir)
 {
     if (movable.CanFit(dir, _allObjects) == false)
     {
         return(false);
     }
     if (movable.GetNeighborMovable(dir, _allObjects) == null)
     {
         return(false);
     }
     return(true);
 }