Esempio n. 1
0
        private void DoSubmit()
        {
            SubmitFormData.SaveSizeForm(SelectedItem.SerializeForm());

            if (CanGoNext())
            {
                DoGoNext();
                _items.RemoveAt(_selectedIndex - 1);
            }
            else if (CanGoBack())
            {
                DoGoBack();
                _items.RemoveAt(_selectedIndex + 1);
            }
            else
            {
                _items.RemoveAt(_selectedIndex);
                _selectedIndex.Value = -1;
            }

            if (_items.Count == 0)
            {
                OnEmpty?.Invoke();
            }
        }
Esempio n. 2
0
        public IEnumerator DoorOpen()
        {
            //Load the itemPrefab from resouces
            GameObject itemPrefab = Resources.Load <GameObject>("Prefabs/Item");
            //Getting player position value so it will spawn on top of the player
            Vector3 playerPos = player.transform.position;

            //Instantiate the item into the world
            itemPrefab = Object.Instantiate(itemPrefab, playerPos, Quaternion.identity);
            //Getting onEmpty Script reference
            onEmpty = game.GetComponentInChildren <OnEmpty>();
            //Checking if the Parent has no children in them (or all items have been collected)
            if (onEmpty.transform.childCount == 0)
            {
                //Then Call the OpenDoor Function
                onEmpty.OpenDoor();
            }
            //Wait for a while for it to run
            yield return(new WaitForFixedUpdate());

            yield return(new WaitForEndOfFrame());

            //Return true if the door has been opened;
            Assert.IsTrue(onEmpty.isOpen = true);
        }
Esempio n. 3
0
 public void Decrement(int value = 1)
 {
     SetValue(Value - value);
     if (Value <= 0)
     {
         OnEmpty?.Invoke();
     }
 }
Esempio n. 4
0
        public void Remove(ICard card)
        {
            var action = cards.Remove(card);

            if (action && cards.Count == 0)
            {
                OnEmpty.Invoke();
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Remove the oldObject from the list if it can be found.
        /// </summary>
        /// <param name="oldObject"></param>
        public void Remove(T oldObject)
        {
            if (objects.Contains(oldObject))
            {
                objects.Remove(oldObject);
                OnRemoved?.Invoke(oldObject);
            }

            if (objects.Count <= 0)
            {
                OnEmpty?.Invoke();
            }
        }
Esempio n. 6
0
        public void Lose(int _amount, ISource _source)
        {
            int prev = current;

            current -= _amount;
            current  = Mathf.Clamp(current, min, max);

            if (current != prev)
            {
                OnResourceLost?.Invoke(prev - current, _source);
                OnChanged?.Invoke(prev, current);
                OnFillValueChanged?.Invoke();
            }

            if (current == min)
            {
                OnEmpty?.Invoke();
            }
        }
Esempio n. 7
0
    public void IsCorrect(string input)
    {
        // 未記入.
        if (string.IsNullOrEmpty(input))
        {
            OnEmpty.Invoke();
            return;
        }

        // 数字じゃない.
        if (!int.TryParse(input, out int inputNumber))
        {
            return;
        }

        // チェック.
        bool IsCorrect = inputNumber == Question.Answer;

        if (IsCorrect)
        {
            // TODO:正解時のリアクション.
            // 正解
            Debug.Log("Correct!");
            OnCorrect.Invoke();

            audioSource.clip = correctAudioSource;
        }
        else
        {
            // TODO:不正解時のリアクション.
            // 不正解
            Debug.Log("Incorrect...");
            OnIncorrect.Invoke();

            audioSource.clip = incorrectAudioSource;
        }

        audioSource.Play();

        OnAfterChecking.Invoke(IsCorrect);
    }
        private void DoSubmit()
        {
            if (CanGoNext())
            {
                DoGoNext();
                _items.RemoveAt(_selectedIndex - 1);
            }
            else if (CanGoBack())
            {
                DoGoBack();
                _items.RemoveAt(_selectedIndex + 1);
            }
            else
            {
                _items.RemoveAt(_selectedIndex);
                _selectedIndex.Value = -1;
            }

            if (_items.Count == 0)
            {
                OnEmpty?.Invoke();
            }
        }
Esempio n. 9
0
        private IEnumerator EmptyAnimation(int n, int count, System.Action callback)
        {
            spriteRenderer.sortingOrder += 10 + n;
            int remaining = count - n;

            // Easy constants access
            //---------------------------------------------------

            // Timings
            const float BLINK_DURATION = 0.5f;
            const float GROW_DURATION  = 0.15f;
            const float WAIT_BEFORE_EXPLOSION_DURATION = 0.2f;
            const float EXPLOSION_DURATION             = 0.1f;
            const float EXPLOSION_DURATION_SHIFT       = 0.1f;

            // Values
            const float GROW_SCALE_BONUS = 0.105f;

            //---------------------------------------------------

            if (IsHidden)
            {
                Reveal(0, 2.5f);
            }

            // Blink fade
            spriteRenderer.DOFade(0.5f, 0.1f).SetLoops(-1, LoopType.Yoyo);

            yield return(new WaitForSeconds(BLINK_DURATION));

            spriteRenderer.DOKill();
            spriteRenderer.DOFade(0.75f, 0f);

            // Grow...
            var previousScale = transform.localScale;

            StartCoroutine(Interpolators.Curve(Interpolators.EaseOutCurve, 0f, 1f, GROW_DURATION,
                                               (step) =>
            {
                transform.localScale = Vector3.one * (1 + (GROW_SCALE_BONUS * step));

                Vector3 shitToCenter = (transform.localScale - previousScale);
                shitToCenter.x       = -shitToCenter.x / 2f;
                shitToCenter.y       = 0;

                shift = shitToCenter;
            }, null));

            yield return(new WaitForSeconds(GROW_DURATION + WAIT_BEFORE_EXPLOSION_DURATION));

            // Wait
            var duration = (n * EXPLOSION_DURATION_SHIFT);

            yield return(new WaitForSeconds(duration));

            // Block disappear
            spriteRenderer.DOFade(0f, 0.15f).SetEase(Ease.InCubic)
            .SetDelay(0.1f);

            yield return(new WaitForSeconds(EXPLOSION_DURATION));

            OnEmpty.Raise(block.Definition);

            // THIS synchronize falls between all blocks.
            yield return(new WaitForSeconds(remaining * EXPLOSION_DURATION_SHIFT));

            // Reset
            shift = Vector2.zero;
            transform.localScale = Vector3.one;

            spriteRenderer.sortingOrder -= 10 + n;

            callback.Raise();
        }
Esempio n. 10
0
 /// <summary>
 ///     Emits on empty event.
 /// </summary>
 protected virtual void OnEmptyQueue() => OnEmpty?.Invoke();
Esempio n. 11
0
 protected virtual void TriggerOnEmpty() => OnEmpty?.Invoke();