Exemplo n.º 1
0
    //QUANDO O BOTAO É ATIVADO, ESSA FUNCAO EH CHAMADA. AQUI VOCE DEVE PROGRAMAR O SEU CODIGO PARA O SEU BOTAO...
    override public void OnInteractionTrigger(InteractionModes mode)
    {
        switch (mode)
        {
        case InteractionModes.Out:
        case InteractionModes.Up:
            switch (currentState)
            {
            case buttonHoldingStates.notstarted:
            default:
                break;

            case buttonHoldingStates.holdStart:
                TreatFailing();
                break;

            case buttonHoldingStates.holdOver:
                currentState = buttonHoldingStates.notstarted;
                OnFinish();
                break;
            }
            m_Selection.gameObject.SetActive(false);
            break;

        case InteractionModes.Click:
            currentState = buttonHoldingStates.notstarted;
            switch (currentState)
            {
            case buttonHoldingStates.notstarted:
            default:
                countDown = Time.deltaTime;
                OnHoldStart?.Invoke(this.gameObject);
                currentState = buttonHoldingStates.holdStart;
                break;

            case buttonHoldingStates.holdStart:
                break;

            case buttonHoldingStates.holdOver:
                break;
            }
            break;
        }
    }
Exemplo n.º 2
0
    private void Update()
    {
        if (!m_InteractiveItem.IsOver)
        {
            return;
        }
        switch (currentState)
        {
        case buttonHoldingStates.notstarted:
        default:
            break;

        case buttonHoldingStates.holdStart:
            countDown += Time.deltaTime;
            if (countDown >= totalHoldDuration)
            {
                OnHoldOver?.Invoke(this.gameObject);
                holdingTime  = Time.deltaTime;
                currentState = buttonHoldingStates.holdOver;
                if (afterHoldMaxTime < 0)
                {
                    OnInteractionTrigger(InteractionModes.Out);
                }
            }
            break;

        case buttonHoldingStates.holdOver:
            holdingTime += Time.deltaTime;
            m_Selection.gameObject.SetActive(true);
            m_Selection.fillAmount = holdingTime / afterHoldMaxTime;

            if (holdingTime >= afterHoldMaxTime)
            {
                TreatFailing();
                OnFinish();
            }
            break;
        }
    }