コード例 #1
0
    void KeyCollectedEventHandler(KeyCollectedEvent e)
    {
        if (e.keyType == requiredKey)
        {
            collectedKeys++;
        }

        if (collectedKeys == levelKeysCount)
        {
            EventHub.Instance.FireEvent(new ExitOpenEvent());
        }
    }
コード例 #2
0
    /*
     * TODO: Fix removal of multiple events at the same time.
     * void OnDestroy()
     * {
     *  EventHub.Instance.RemoveListener<KeyCollectedEvent>(OnKeyCollected);
     * }
     */

    void OnKeyCollected(KeyCollectedEvent e)
    {
        if (!gameObject.activeInHierarchy)
        {
            return;
        }
        if (e.keyType == requiredKey)
        {
            collectedKeys++;
        }

        if (collectedKeys == requiredKeysCount)
        {
            onOpen?.Invoke();
            gameObject.SetActive(false);
        }
    }
コード例 #3
0
 void OnKeyCollected(KeyCollectedEvent e)
 => UpdateCollectedKeys();