Пример #1
0
    private void DamageHouse()
    {
        houseHealth -= 1;
        healthbarscript.SetHealth(houseHealth);
        if (houseHealth > 0)
        {
            StartCoroutine(InvinceFlicker());
        }
        else
        {
            isDestroyed           = true;
            meshRenderer.material = destroyed;
            GameWatcher.objectiveCount--;
        }

        IEnumerator InvinceFlicker()
        {
            isInvincible          = true;
            meshRenderer.material = destroyed;
            yield return(new WaitForSeconds(flickerRate));

            meshRenderer.material = curMat;
            yield return(new WaitForSeconds(flickerRate));

            meshRenderer.material = destroyed;
            yield return(new WaitForSeconds(flickerRate));

            meshRenderer.material = curMat;
            isInvincible          = false;
        }
    }
Пример #2
0
 // Update is called once per frame
 void Update()
 {
     Healthbar.SetHealth(currentHealth);
     if (currentHealth <= 0)
     {
         Instantiate(deathParticle, character.transform.position, Quaternion.identity);
         Die();
     }
 }
Пример #3
0
    // Update is called once per frame
    void Update()
    {
        Vector3 direction = target.position - this.transform.position;
        //the float angle is resposible for the area where the spider can see
        //the player that will start the chasing.↓↓
        float angle = Vector3.Angle(direction, this.transform.forward);

        if (Vector3.Distance(target.position, transform.position) < 7 && angle < 30)
        {
            this.transform.rotation = Quaternion.Slerp(this.transform.rotation,
                                                       Quaternion.LookRotation(direction), 0.1f);

            direction.y = 0;
            anim.SetBool("isIdle", false);

            if (direction.magnitude > 2)
            {
                this.transform.Translate(0, 0, 0.05f);
                anim.SetBool("isRunning", true);
                anim.SetBool("isAttacking", false);
            }
            else
            {
                anim.SetBool("isRunning", false);
                anim.SetBool("isAttacking", true);
            }
        }
        else
        {
            anim.SetBool("isIdle", true);
            anim.SetBool("isRunning", false);
            anim.SetBool("isAttacking", false);
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            TakeDamage(20);
        }

        void TakeDamage(int damage)
        {
            currentHealth -= damage;
            healthBar.SetHealth(currentHealth);
        }
    }
Пример #4
0
    //Health Code

    void TakeDamage(int damage)
    {
        currentHealth -= damage;

        healthBar.SetHealth(currentHealth);
    }
Пример #5
0
 void takeDamage(int damage)
 {
     //Do damage
     currentHealth -= damage;
     healthBar.SetHealth(currentHealth);
 }