void OnTriggerEnter2D(Collider2D other) { if ((other.gameObject.name == "EnemyBullet(Clone)") || (other.gameObject.name == "BossBullet(Clone)") || (other.gameObject.tag == "JellyFish")) { playerHealth.TakeDamage(attackDamage); invulnerabilityTimer = 2.0f; gameObject.layer = 11; material.color = Color.red; AudioSource.PlayClipAtPoint(playerGetHit1, transform.position); } else if (other.gameObject.name == "EnemyEnergyBall(Clone)") { playerHealth.TakeDamage(attackDamage + 25); invulnerabilityTimer = 2.0f; gameObject.layer = 11; material.color = Color.red; AudioSource.PlayClipAtPoint(playerGetHit1, transform.position); } else if (other.gameObject.name == "EnemyFireBall(Clone)") { playerHealth.TakeDamage(attackDamage + 50); invulnerabilityTimer = 2.0f; gameObject.layer = 11; material.color = Color.red; AudioSource.PlayClipAtPoint(playerGetHit1, transform.position); } }
void OnTriggerStay2D(Collider2D collider) { if (collider.tag.Equals("Player") && _timer >= Interval) { _playerHealthScript.TakeDamage(Damage); _timer = 0; } }
void Attack() { timer = 0f; if (playerHealth.currentHealth > 0) { playerHealth.TakeDamage(attackDamage); } }
IEnumerator EnemyAttack() { yield return(new WaitForSeconds(0.4f)); if (distanceToTarget <= minDistance && !dead) { playerHealth.TakeDamage(DamageValue); } yield return(null); }
void OnTriggerEnter2D(Collider2D other) { //Debug.Log("Collided"); if (other.tag == "Player") { targetHealth = other.GetComponent <PlayerHealthScript>(); targetHealth.TakeDamage(10); //Debug.Log("Damage Done"); Destroy(gameObject); } }
// Update is called once per frame void Update() { transform.position = (Vector2.MoveTowards(transform.position, position, speed * Time.deltaTime)); timer += Time.deltaTime; if (TakingDamage && timer >= poisonTickTime) { targetHealth.TakeDamage(5); Debug.Log("Taking damage"); timer = 0; } Destroy(gameObject, cloudLifeTime); }
private void Attack() { RaycastHit2D hit; if (m_FacingRight) { Vector3 originCentral = new Vector3(transform.position.x - 0.5f, transform.position.y + 0.95f, transform.position.z); Debug.DrawRay(originCentral, new Vector3(-1, 0, 0), Color.blue, 10.0f, false); hit = Physics2D.Raycast(originCentral, new Vector3(-1, 0, 0), 10); } else { Vector3 originCentral = new Vector3(transform.position.x + 0.5f, transform.position.y + 0.95f, transform.position.z); Debug.DrawRay(originCentral, new Vector3(1, 0, 0), Color.blue, 10.0f, false); hit = Physics2D.Raycast(originCentral, new Vector3(1, 0, 0), 3); } if (hit.collider != null) { //Debug.Log("hit"); PlayerHealthScript PlayerHealth = hit.collider.gameObject.GetComponent <PlayerHealthScript>(); if (PlayerHealth != null) { if (superAttackReady) { PlayerHealth.TakeDamage(30); Debug.Log("Super Attack"); superAttackReady = false; } else { PlayerHealth.TakeDamage(10); } } } }
public void Attack(ushort damage) { PlayerHealthScript playerhealth = player.GetComponent <PlayerHealthScript>(); playerhealth.TakeDamage(10); }