Exemplo n.º 1
0
        public void OnRelease()
        {
            if (isCombinedBlock && isCombined.value && pairBlock)
            {
                OnDeCombine();
            }

            if (matchableSlot)
            {
                matchableSlot.slotState = SlotStates.idle;
                matchableSlot           = null;
            }
            audioSource.PlayOneShot(releaseSound, 1f);
            releaseRot = Random.rotation;
            StartCoroutine(ReleaseToIdle());
        }
Exemplo n.º 2
0
        void FindMatchableSlot()
        {
            if (isCombinedBlock && !isCombined.value)
            {
                if (matchableSlot != null)
                {
                    matchableSlot = null;
                }
                return;
            }

            float minDist = Mathf.Infinity;

            foreach (SlotBehavior s in potentialSlots)
            {
                float dist = Vector3.Distance(s.transform.position, transform.position);
                if (dist < minDist)
                {
                    if (matchableSlot != s && matchableSlot != null)
                    {
                        matchableSlot.slotState = SlotStates.idle;
                        isMatchable             = false;
                        matchableSlot           = null;
                    }

                    if (dist <= matchableDistance && !s.isMatched)
                    {
                        matchableSlot = s;
                        minDist       = dist;
                    }
                }
            }

            if (matchableSlot != null)
            {
                matchableSlot.slotState = SlotStates.hover;
                isMatchable             = true;
            }
        }