Esempio n. 1
0
  } // End of MoveSpeedSet

  // Strike target (called from animator at the time of actual strike).
  public void AttackStrike(int damage)
  {
    // If no target then exit from function.
    if(this.target==null)
    {
      return;
    }
    // Get health component.
    HealthManager health = this.target.GetComponent<HealthManager>();
    // If no health component then exit from function.
    if(health==null)
    {
      return;
    }
    // Deal damage
    health.DamageDeal(damage);
  } // End of AttackStrike
Esempio n. 2
0
    } // End of Move

    // On collision.
    private void OnTriggerEnter2D(Collider2D collision)
    {
        // Get object from collision.
        GameObject obj = collision.gameObject;

        // If not collision with attacker then exit from function.
        if (!obj.GetComponent <AttackerManager>())
        {
            return;
        }
        // Get health component.
        HealthManager health = collision.gameObject.GetComponent <HealthManager>();

        // If no health component then exit from function.
        if (health == null)
        {
            return;
        }
        // Deal damage.
        health.DamageDeal(this.damage);
        // Destroy projectile.
        Destroy(this.gameObject);
    } // End of OnTriggerEnter2D