Example #1
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);
        }
    }
Example #2
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 #3
0
    public static FloatTween CreateOneWayTween(
        SpriteRenderer spriteRenderer, float from, float to, float duration,
        EaseType easeType = EaseType.QuartIn)
    {
        FloatTween             tween       = new FloatTween();
        SpriteFlashTweenTarget tweenTarget = new SpriteFlashTweenTarget(spriteRenderer);

        tween.setRecycleTween(false);
        tween.initialize(tweenTarget, to, duration);
        tween.setFrom(from).setEaseType(easeType);
        return(tween);
    }
Example #4
0
 private void Start()
 {
     tween.initialize(tweenTarget, 0f, 0.2f);
     tween.setFrom(1.0f).start();
 }