Example #1
0
    // Setters
    public void ChangeHealth(int amount)
    {
        if (!invincibility && amount < 0)
        {
            camera_controller.HitProcess(0.5f, 50f); // camera shake
            effect_controller.PlayerHit();

            int iter = currentHealth;
            currentHealth = Mathf.Clamp(currentHealth + amount, 0, maxHealth);
            Debug.Log(currentHealth + " / " + maxHealth);
            iter -= currentHealth;

            for (int i = 0; i < iter; i++)
            {
                Image todel = healthes.Pop();
                // Debug.Log("delete" + todel);
                Destroy(todel);
            }
            if (currentHealth <= 0)
            {
                animator.SetTrigger("die");
                invincibility = true;
                Destroy(gameObject, 2f);
                die = true;
                Destroy(hand);
            }
            else
            {
                invincibility = true;
                StartCoroutine(InvincibleTime());
            }
        }
        else if (!invincibility && amount == 0) // shiled state 확인 이 더 낫나
        {
            camera_controller.ShieldProcess(0.2f, 30f);
            effect_controller.SuccessShield();
        }
    }