コード例 #1
0
 void Update()
 {
     if (activateTime > 0)
     {
         if (_activateTimer > 0)
         {
             _activateTimer -= Time.deltaTime;
             if (_activateTimer <= 0)
             {
                 isBurned = false;
                 for (int i = 0; i < buttonListener.Length; i++)
                 {
                     ButtonListener myListener = buttonListener[i];
                     myListener.OnButtonTrigger(gameObject);
                     myListener.OnButtonTriggerExit(gameObject);
                 }
             }
         }
     }
     if (_renderState != isBurned)
     {
         if (isBurned)
         {
             spriteRenderer.sprite = burnedSprite;
         }
         else
         {
             spriteRenderer.sprite = goodSprite;
         }
         _renderState = isBurned;
     }
 }
コード例 #2
0
    private void NotifyTriggersOff()
    {
        currentlyPressed      = false;
        spriteRenderer.sprite = offSprite;

        for (int i = 0; i < myListener.Length; i++)
        {
            ButtonListener thisListerner = myListener[i];
            thisListerner.OnButtonTrigger(gameObject);
            thisListerner.OnButtonTriggerExit(gameObject);
        }
    }
コード例 #3
0
    private void NotifyTriggersOn()
    {
        pressedAnimationCountDown = pressedTime;
        currentlyPressed          = true;
        spriteRenderer.sprite     = pressedSprite;

        for (int i = 0; i < myListener.Length; i++)
        {
            ButtonListener thisListerner = myListener[i];
            thisListerner.OnButtonTrigger(gameObject);
            thisListerner.OnButtonTriggerEnter(gameObject);
        }
    }
コード例 #4
0
    private void OnTriggerExit2D(Collider2D other)
    {
        GameObject         source = other.gameObject;
        ButtonInteractable bti    = source.GetComponent <ButtonInteractable>();

        if (bti)
        {
            for (int i = 0; i < myListener.Length; i++)
            {
                ButtonListener thisListerner = myListener[i];
                thisListerner.OnButtonTrigger(gameObject);
                thisListerner.OnButtonTriggerExit(gameObject);
            }
        }
    }
コード例 #5
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        //Debug.Log(other);
        GameObject         source = other.gameObject;
        ButtonInteractable bti    = source.GetComponent <ButtonInteractable>();

        if (bti)
        {
            Weight sourceWeight = bti.myWeight;
            if (sourceWeight >= requiredWight)
            {
                for (int i = 0; i < myListener.Length; i++)
                {
                    ButtonListener thisListerner = myListener[i];
                    thisListerner.OnButtonTrigger(gameObject);
                    thisListerner.OnButtonTriggerEnter(gameObject);
                }
            }
        }

        throw new Exception("Old button AI used. Please use new one.");
    }
コード例 #6
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        Sharp mySharp = other.gameObject.GetComponent <Sharp>();

        if (!isBurned && mySharp && (mySharp.sharpness == Sharpness.Burning || mySharp.sharpness == Sharpness.Normal))
        {
            for (int i = 0; i < buttonListener.Length; i++)
            {
                ButtonListener myListener = buttonListener[i];
                myListener.OnButtonTrigger(gameObject);
                myListener.OnButtonTriggerEnter(gameObject);
            }

            GetComponent <AudioSource>().Play();

            isBurned = true;
            if (activateTime > 0)
            {
                _activateTimer = activateTime;
            }
        }
    }