Ejemplo n.º 1
0
        private bool UpdateMatchHunter(InteractableObject interactable, InteractableObject.Kind lastKind)
        {
            InteractableObject.Kind currentKind = interactable.ObjectKind;

            if (currentKind != InteractableObject.Kind.None && (currentKind == lastKind || lastKind == InteractableObject.Kind.None))
            {
                //the hunt goes on
                _matchHunterAux.Push(interactable);
                return(false);
            }

            //we have come to an end
            CheckMatchFoundAndClear();

            //Start a new hunt
            _matchHunterAux.Push(interactable);

            return(true);
        }
Ejemplo n.º 2
0
        private bool IsThereAMatch()
        {
            bool matchFound = false;

            //Searching for a match on lines
            for (int verticalIndex = 0; verticalIndex < _gameConfig.BoardHeight; verticalIndex++)
            {
                InteractableObject.Kind lastKind = InteractableObject.Kind.None;

                for (int horizontalIndex = 0; horizontalIndex < _gameConfig.BoardWidth; horizontalIndex++)
                {
                    InteractableObject interactable = _interactableObjects[verticalIndex, horizontalIndex];
                    matchFound |= UpdateMatchHunter(interactable, lastKind);
                    lastKind    = interactable.ObjectKind;
                }

                matchFound |= CheckMatchFoundAndClear();
            }

            //searching for a match on columns
            for (int horizontalIndex = 0; horizontalIndex < _gameConfig.BoardWidth; horizontalIndex++)
            {
                InteractableObject.Kind lastKind = InteractableObject.Kind.None;

                for (int verticalIndex = 0; verticalIndex < _gameConfig.BoardHeight; verticalIndex++)
                {
                    InteractableObject interactable = _interactableObjects[verticalIndex, horizontalIndex];
                    matchFound |= UpdateMatchHunter(interactable, lastKind);
                    lastKind    = interactable.ObjectKind;
                }

                matchFound |= CheckMatchFoundAndClear();
            }

            return(matchFound);
        }
 private void OnKindUpdated(InteractableObject.Kind kind)
 {
     _image.sprite = _myInteractableObject.Config.ObjectList[(int)kind];
 }