Example #1
0
    public void Hurt()
    {
        hitClip?.Play(Toolbox.Instance.Get <SoundKit>());
        // if (isDying) return;
        if (tween.isRunning())
        {
            tween.stop(true, true);
        }
        tween.initialize(tweenTarget, 0f, 0.2f);
        tween.setFrom(1.0f).start();

        if (--hp <= 0)
        {
            deathClip?.Play(Toolbox.Instance.Get <SoundKit>());
            // isDying = true;
            GameObject obj = Instantiate(snailDie, transform.position, Quaternion.identity);
            obj.transform.localScale = transform.localScale;

            if (tween.isRunning())
            {
                tween.stop(true, true);
            }
            Destroy(gameObject);
        }
        else
        {
            AddKnockback();
        }
    }
Example #2
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (isEnding)
        {
            return;
        }

        if (other.tag.Equals(Tags.ENEMY))
        {
            // Debug.Log("Crystal: touched");
            hudManager?.SetHealth(--health);

            if (tween.isRunning())
            {
                tween.stop(true, true);
            }
            tween.initialize(tweenTarget, 0f, 0.1f);
            tween.setFrom(0.5f).start();

            if (health <= 0)
            {
                //StartCoroutine(CoroutineUtils.DelaySeconds(() =>
                // {
                //rend.ZKalphaTo(0, 1).start();
                //}, 2));
                anim.SetTrigger(AnimatorParams.DIE);
                GameObject.FindWithTag(Tags.MAIN_GAME)?.GetComponent <MainGame>()?.Lose();
            }

            other.gameObject.GetComponent <EnemyMover>().StopTween();
            Destroy(other.gameObject);
        }
    }
    public void Flash()
    {
        SpriteFlash.SetMaterialFlashColor(spriteRenderer, flashColour);

        if (tween.isRunning())
        {
            tween.stop(true, true);
        }

        tween.jumpToElapsedTime(0f);
        tween.setDuration(duration);
        tween.setEaseType(easeType);
        tween.start();
    }