Beispiel #1
0
    /* function to be called by Equipment::Use() */
    void UpdateAnimReference()
    {
        equipmentAnim = transform.GetChild(0).GetComponentsInChildren <SpriteAnimator> ();

        /* if body animation is playing (to make both body and equipment play simultaneously) */
        if (anim.playing)
        {
            anim.ForcePlay(anim.currentAnimation.name, false, anim.currentFrame);

            /* play current playing animation for all equipment character equipped */
            for (int i = 0; i < equipmentAnim.Length; ++i)
            {
                equipmentAnim [i].ForcePlay(anim.currentAnimation.name, false, anim.currentFrame);
            }
        }
    }
Beispiel #2
0
    public void OnDamage(int damage, float knockback, Vector2 targetPosition, float coolDown, bool isBuff)
    {
        if (isAlive && canTakeDamage)
        {
            if (damage != 0)
            {
                health -= damage;
                GameUIManager.singleton.RemoveHeart(health);
                if (health > 0)
                {
                    Debug.Log("Health: " + health);
                    _motor.ForceJump(knockback * _motor.jumpHeight * 10);
                    int rAudio    = Random.Range(0, damageAudio.Length);
                    int rDialogue = Random.Range(0, damageDialogue.Length);
                    _bubbleDialogue.ForcePlay(damageDialogue[rDialogue], false, 0, damageAudio[rAudio]);
                    Instantiate(damageBlood, new Vector3(transform.position.x, transform.position.y + 0.5f), Quaternion.identity);
                }

                if (health <= 0)
                {
                    isAlive = false;
                    Debug.Log("Health: Dead");
                    Instantiate(deathBlood, new Vector3(transform.position.x, transform.position.y + 0.5f), Quaternion.identity);
                    Fade.singleton.FadeIn(3f);
                    GameManager.singleton.EndingGame(false);
                }
            }
            else
            {
                _motor.ForceJump(knockback * _motor.jumpHeight * 10);
            }
            if (isAlive)
            {
                StartCoroutine(CoolDownWait(coolDown, damage, isBuff));
            }
        }
    }