Esempio n. 1
0
    public virtual void TakeDamage(float value, Vector3 hitVector, bool knockdown = false)
    {
        FlipSprite(hitVector.x > 0);
        currentLife -= value;
        if (isAlive && currentLife <= 0)
        {
            Die();
        }
        else if (knockdown)
        {
            if (knockdownRoutine == null)
            {
                Vector3 pushbackVector = (hitVector + Vector3.up * 0.75f).normalized;
                body.AddForce(pushbackVector * 250);
                knockdownRoutine = StartCoroutine(KnockdownRoutine());
            }
        }
        else
        {
            baseAnim.SetTrigger("IsHurt");
        }

        lifeBar.EnableLifeBar(true);                // 1
        lifeBar.SetProgress(currentLife / maxLife); // 2
        Color color = baseSprite.color;             // 3

        if (currentLife < 0)                        // 4
        {
            color.a = 0.75f;
        }
        lifeBar.SetThumbnail(actorThumbnail, color); // 5
    }
    public virtual void TakeDamage(float value, Vector3 hitVector, bool knockdown = false)
    {
        if (isAlive && currentLife <= 0)
        {
            Die();
        }
        else if (knockdown)
        {
            if (knockdownRoutine == null)
            {
                Vector3 pushbackVector = (hitVector + Vector3.up * 0.75f).normalized;
                body.AddForce(pushbackVector * 250);
                knockdownRoutine = StartCoroutine(KnockdownRoutine());
            }
        }
        else if (canFlinch)
        {
            baseAnim.SetTrigger("IsStunned");
        }

        //update lifebar
        lifeBar.EnableLifeBar(true);
        lifeBar.SetProgress(currentHP / maxHP);
        Color color = baseSprite.color;

        if (currentHP < 0)
        {
            color.a = 0.75f;
        }
        lifeBar.SetThumbnail(activeplayerThumbnail, color);
    }
Esempio n. 3
0
    private void CompleteCurrentEvent()
    {
        //clean the currentBatlleEvent, let camera follow and check if there's more events
        currentBattleEvent = null;
        cameraFollows      = true;
        cameraBounds.CalculateOffset(player.transform.position.x);

        hasRemainingEvents = currentLevelData.battleData.Count >
                             nextEventIndex;
        enemyLifeBar.EnableLifeBar(false);
        if (!hasRemainingEvents)
        {
            StartCoroutine(HeroWalkout());
        }
    }
Esempio n. 4
0
    private void CompleteCurrentEvent()
    {
        currentBattleEvent = null;
        cameraFollows      = true;
        cameraBounds.CalculateOffset(actor.transform.position.x);
        hasRemainingEvents = currentLevelData.battleData.Count > nextEventIndex;

        enemyLifeBar.EnableLifeBar(false);

        if (!hasRemainingEvents)
        {
            StartCoroutine(HeroWalkout());
        }
        else
        {
            ShowGoIndicator();
        }
    }
Esempio n. 5
0
    public virtual void TakeDamage(float damage, Vector3 hitVector, bool knockdown = false)
    {
        FlipSprite(hitVector.x > 0);
        baseAnim.SetTrigger("isHurt");
        currentLife -= damage;
        if (isAlive && currentLife <= 0)
        {
            Die();
        }
        else if (knockdown)
        {
            if (knockdownRoutine == null)
            {
                Vector3 pushbackVector = (hitVector + Vector3.up * 0.75f).normalized;
                characterRB.AddForce(pushbackVector * 250);
                knockdownRoutine = StartCoroutine(KnockdownRoutine());
            }
        }

        lifeBar.EnableLifeBar(true);
        lifeBar.FillHpBar(currentLife / maxLife);
        lifeBar.SetAvatar(characterAvatar, baseSprite.color);
    }