Beispiel #1
0
 public void TakeDamage(float dmg, ElementType spellType)
 {
     if (alive && elementType == spellType)
     {
         alive = false;
         gateHealth.TakeDamage(1, spellType);
         //TODO: Remove if it has animation
         gameObject.SetActive(false);
     }
 }
Beispiel #2
0
 void Attack()
 {
     timer = 0f;
     if (genTargetInRange == true)
     {
         genHealth.TakeDamage(attackDamage);
     }
     else if (gateTargetInRange == true)
     {
         gateHealth.TakeDamage(attackDamage);
     }
 }
Beispiel #3
0
    // Update is called once per frame
    void Update()
    {
        if (currentHealth > 0)
        {
            nav.destination = generator.transform.position;
        }
        else
        {
            nav.enabled = false;
        };

        timer += Time.deltaTime;
        if ((timer >= timeBetweenAttacks) && (gateTargetInRange || genTargetInRange))
        {
            timer = 0f;
            if (genTargetInRange == true)
            {
                genHealth.TakeDamage(attackDamage);
            }
            else if (gateTargetInRange == true)
            {
                gateHealth.TakeDamage(attackDamage);
            }
        }

        if (isTracked)
        {
            this.gameObject.GetComponentInChildren <TextMesh>().text = "X";
            currentHealth -= damage;
            if (currentHealth <= 0)
            {
                EnemySPManager.count -= 1;
                ScoreManager.score   += scoreValue;
                VRFilterManager.enemList.Remove(this.gameObject);
                Destroy(gameObject);
            }
        }
    }
 // Attacks at a given enemy only when 'attacking'
 public override void Attack(GateHealth g)
 {
     print("MoveOnPath is attacking '" + g.name + "'");
     g.TakeDamage(damage);
     // Note (Manny): The way you're using Inheritance & Polymorphism here is wrong. Come and see me for more details.
 }