本文整理汇总了C#中EnemyHealth.TakeDamage方法的典型用法代码示例。如果您正苦于以下问题:C# EnemyHealth.TakeDamage方法的具体用法?C# EnemyHealth.TakeDamage怎么用?C# EnemyHealth.TakeDamage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EnemyHealth
的用法示例。
在下文中一共展示了EnemyHealth.TakeDamage方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCollisionEnter
void OnCollisionEnter(Collision col)
{
if(col.gameObject.tag == "Zombie")
{
enemy = col.gameObject;
enemyHealth = col.gameObject.GetComponent<EnemyHealth>();
enemyHealth.TakeDamage(Damage);
GameObject bloodSplat = (GameObject)Instantiate(BloodSplat, col.transform.position + Vector3.up * 1.5f, col.transform.rotation);
Destroy(bloodSplat, 1f);
}
DestroyBullet();
}
示例2: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.tag == "Enemy")
{
Debug.Log("Bullet entered a collider");
enemyHealth = other.GetComponent<EnemyHealth>();
enemyHealth.TakeDamage(amount);
Destroy(gameObject);
}
if (other.gameObject.tag == "Ground")
Destroy(gameObject);
}
示例3: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
//enemy = GameObject.FindGameObjectWithTag("Enemy");
if (other.gameObject.tag == "Enemy")
{
enemy = other.gameObject;
enemyHealth = enemy.GetComponent<EnemyHealth>();
if (enemyHealth != null)
{
enemyHealth.TakeDamage(damage);
}
}
}
示例4: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D other){
if((other.gameObject.tag == "Enemy" && count == 0))
{
enemyHealth = other.gameObject.GetComponent<EnemyHealth>();
//APPLYING DAMAGE TO ENEMY
enemyHealth.TakeDamage(batonDamage);
count++;
GetComponent<AudioSource>().Play();
}
}
示例5: Awake
//public bool rocket = false;
void Awake()
{
RaycastHit hit;
if(Physics.Raycast(transform.position, transform.forward,out hit, maxDist))
{
if(hit.transform.tag == "Enemies" )
{
Debug.Log("BULLET HAS HIT");
enemyHealth = hit.transform.GetComponent<EnemyHealth>();
enemyHealth.TakeDamage(damage, hit.point);
Destroy(gameObject);
}
}
Destroy(gameObject);
}
示例6: Attack
void Attack()
{
//Debug.Log ("turn: " + turnController.playerTurn);
if (turnController.giveBonus == false) {
turnController.BeginTurn();
}
turnController.giveBonus = true;
endTurnButton.onClick.AddListener (() => turnController.pressButton = true);
if (turnController.playerTurn == 1 && turnController.pressButton == true) {
GameObject enemy = GameObject.FindGameObjectWithTag ("Enemy");
enemyHealth = enemy.GetComponent<EnemyHealth> ();
if (enemyHealth.currentHealth > 0) {
enemyHealth.TakeDamage (attackPoint);
}
turnController.giveBonus = false;
turnController.EndTurn();
}
}
示例7: OnTriggerEnter
void OnTriggerEnter(Collider collision)
{
enemyHealth = collision.gameObject.GetComponent<EnemyHealth> ();
switch (attackType) {
case AttackType.AOEAttack:
Debug.Log ("AOE Attack!");
if (collision.gameObject.tag == "Enemy") {
Rigidbody enemy = collision.gameObject.GetComponentInChildren<Rigidbody> ();
Vector3 force = enemy.position - weaponCollider.transform.position;
force.Normalize ();
force *= AOEPower;
enemy.AddForce (force, ForceMode.Impulse);
enemyHealth.TakeDamage(5);
//SFX
soundManager.spinHitSound();
}
break;
case AttackType.meleeAttack:
Debug.Log ("PUNCH!");
if (collision.gameObject.tag == "Enemy") {
Rigidbody enemy = collision.gameObject.GetComponentInChildren<Rigidbody> ();
Vector3 force = attackVector;
force.Normalize ();
force *= meleePower;
enemy.AddForce (force, ForceMode.Impulse);
enemyHealth.TakeDamage(10);
//SFX
soundManager.punchHitSound();
}
break;
}
}
示例8: TakeAttack
public void TakeAttack()
{
state = animator.GetCurrentAnimatorStateInfo(0);
bool inRightState = false;
foreach (string attackName in attackNames)
{
// Debug.Log(attackName);
if (state.IsName(attackName))
{
inRightState = true;
break;
}
}
if (!inRightState)
{
return;
}
foreach (GameObject enemy in contactGameObjects)
{
enemyHealth = enemy.GetComponent <EnemyHealth>();
if (enemyHealth != null && enemyHealth.currentHealth > 0)
{
if (state.IsName("attack05"))
{
Time.timeScale = 0.1f;
animator.SetFloat("AnimationSpeed", 0f);
StartCoroutine("resetAnimationSpeed");
}
else
{
animator.SetFloat("AnimationSpeed", 1f);
}
playerMovement.ChangeDirection(enemy.transform.position - player.transform.position);
enemyHealth.TakeDamage(10, Vector3.zero, m_attackType, player.transform.position);
}
}
}