예제 #1
0
    protected override void Update()
    {
        timer += Time.deltaTime;

        if (startHoldingTime < 0f) // Not holding yet
        {
            transform.Translate(-transform.right * Time.deltaTime * speed);
        }

        if (timer > 3f && isInteractable && startHoldingTime < 0f)
        {
            isInteractable = false;
            OnEnemyStopInteract?.Invoke(int.Parse(gameObject.name));
        }

        if (timer >= 4f)
        {
            Destroy(gameObject);
        }
    }
예제 #2
0
    private IEnumerator Dissolving()
    {
        isInteractable = false;
        OnEnemyStopInteract?.Invoke(int.Parse(gameObject.name));

        float alpha = 1f;
        float rate  = 0.01f / dissolveTimeLength;

        while (alpha > 0f)
        {
            alpha -= rate;
            if (alpha <= 0f)
            {
                alpha = 0f;
            }
            spriteRenderer.color = new Color(1f, 1f, 1f, alpha);
            yield return(new WaitForSeconds(0.01f));
        }

        Destroy(gameObject);
    }