private void Update()
    {
        switch (Mode)
        {
        case TriggerMode.Never:
            break;

        case TriggerMode.Once:
            if (!ScenarioTriggerManager.IsTriggered(this))
            {
                ScenarioInterpreter.Instance.EnqueueScript(Script);
            }
            break;

        case TriggerMode.EveryOnceInScene:
        case TriggerMode.Always:
            ScenarioInterpreter.Instance.EnqueueScript(Script);
            break;

        default:
            Debug.LogError("Unknown trigger mode : " + Mode);
            break;
        }
        Destroy(gameObject);
    }
Esempio n. 2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (InteractableMask.Contains(collision.gameObject.layer))
        {
            if (lastContact + MinimumTriggerInterval > Time.time)
            {
                return;
            }
            else
            {
                lastContact = Time.time;
            }

            switch (Mode)
            {
            case TriggerMode.Never:
                break;

            case TriggerMode.Once:
                if (!ScenarioTriggerManager.IsTriggered(this))
                {
                    ScenarioInterpreter.Instance.EnqueueScript(Script);
                }
                Destroy(this);
                break;

            case TriggerMode.EveryOnceInScene:
                ScenarioInterpreter.Instance.EnqueueScript(Script);
                Destroy(this);
                break;

            case TriggerMode.Always:
                ScenarioInterpreter.Instance.EnqueueScript(Script);
                break;

            default:
                Debug.LogError("Unknown trigger mode : " + Mode);
                break;
            }
        }
    }