public void NpcDeath()
 {
     setHealthPoints(HealthyObject.GetComponent <Character>().getHealthPoints);
     //действия, происходящие при значении очков здоровья <= 0
     //TODO: анимация смерти, возможно шейдерами; частицы.
     if (HealthPoints <= 0)
     {
         LoseWindow.SetActive(true);
         //GameObject.Destroy(HealthyObject);
     }
 }
Exemplo n.º 2
0
    //// Update is called once per frame
    //public virtual void Update () {

    //}

    public bool Attack(HealthyObject obj)
    {
        if ((obj.transform.position - transform.position).magnitude < range)
        {
            if (Time.time - lastAttackTime > 1.0f / attackRate)
            {
                obj.health    -= damage;
                lastAttackTime = Time.time;
                return(true);
            }
        }
        return(false);
    }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        float         nearestDist   = 1000.0f;
        HealthyObject nearestObject = null;

        for (int i = 0; i < zManager.zombies.Count; i++)
        {
            float dist = (new Vector2(zManager.zombies[i].transform.position.x, zManager.zombies[i].transform.position.z) - new Vector2(transform.position.x, transform.position.z)).magnitude;
            if (dist < nearestDist)
            {
                nearestDist   = dist;
                nearestObject = zManager.zombies[i];
            }
        }

        bool attacked = Attack(nearestObject);

        if (attacked)
        {
            gunSound.Play();
        }
    }
 public void NpcDeath()
 {
     HealthPoints = HealthyObject.GetComponent <Character>().getHealthPoints;
     //действия, происходящие при значении очков здоровья <= 0
     //TODO: анимация смерти, возможно шейдерами; частицы.
     if (HealthPoints <= 0)
     {
         if (isNotPlaying)
         {
             ssDeath.MakeSound();
             isNotPlaying = false;
         }
         if (Fade > 0)
         {
             Fade -= Time.deltaTime;
             shaderMaterial.SetFloat("_Fade", Fade);
         }
         else
         {
             GameObject.Destroy(HealthyObject);
             Fade = 0;
         }
     }
 }