void OnTriggerEnter(Collider col) { if (col.gameObject.tag == "Enemy" || col.gameObject.tag == "Enemy2" || col.gameObject.tag == "Pathway") { mortarshell_model.SetActive(false); m_render.enabled = true; exploding = true; rb.isKinematic = true; rendr.material.color = explosion_color; if (col.gameObject.tag == "Enemy") { enemy_script = col.GetComponent <enemy>(); enemy_script.ReceiveDamage(damage); } else if (col.gameObject.tag == "Enemy2") { enemy_script2 = col.GetComponent <enemy2>(); enemy_script2.ReceiveDamage(damage); } else { //add fix here if necessary } } }
IEnumerator SpawnWave(int waveIndex) { currentWave = waves[waveIndex]; for (int i = 0; i < currentWave.count; i++) { if (player == null) { yield break; } enemy2 randomEnemy = currentWave.enemies[Random.Range(0, currentWave.enemies.Length)]; Transform randomSpawnPoint = spawnPoints[Random.Range(0, spawnPoints.Length)]; Instantiate(randomEnemy, randomSpawnPoint.position, transform.rotation); if (i == currentWave.count - 1) { spawningFinished = true; } else { spawningFinished = false; } yield return(new WaitForSeconds(currentWave.timeBetweenSpawns)); } }
void OnTriggerEnter(Collider col) { if (col.gameObject.tag == "Enemy") { enemy_script = col.GetComponent <enemy>(); if (!enemy_script.frozen) { enemy_script.Freeze(duration); durability--; if (durability <= 0) { Destroy(this.gameObject); } } } if (col.gameObject.tag == "Enemy2") { enemy_script2 = col.GetComponent <enemy2>(); if (!enemy_script2.frozen) { enemy_script2.Freeze(duration); durability--; if (durability <= 0) { Destroy(this.gameObject); } } } }
void SpawnEnemy2(GameObject enemy2) { GameObject spawned_enemy2 = Instantiate(enemy2, spawn_point2.position, spawn_point2.rotation); enemy2_scr = spawned_enemy2.GetComponent <enemy2>(); enemy2_scr.IncreaseHealth(wave_number); }
void OnTriggerEnter(Collider col) { //Destroy(col.gameObject); if (col != null) { if (col.gameObject.tag == "Enemy") { GameObject effect = (GameObject)Instantiate(damage_effect, transform.position, transform.rotation); Destroy(effect, 1f); enemy_script = col.GetComponent <enemy>(); enemy_script.ReceiveDamage(damage); Destroy(gameObject); } if (col.gameObject.tag == "Enemy2") { GameObject effect = (GameObject)Instantiate(damage_effect, transform.position, transform.rotation); Destroy(effect, 1f); enemy_script2 = col.GetComponent <enemy2>(); enemy_script2.ReceiveDamage(damage); Destroy(gameObject); } else { Destroy(gameObject); } } }
// public Sprite imgNoEnemy; void Awake() { if (instance == null) { instance = this; } }
void OnTriggerEnter(Collider col) { if (col.gameObject.tag == "Enemy") { GameObject effect = (GameObject)Instantiate(damage_effect, transform.position, transform.rotation); Destroy(effect, 1f); enemy_script = col.GetComponent<enemy>(); enemy_script.ReceiveDamage(damage); durability--; if(durability <= 0) { Destroy(this.gameObject); } } if (col.gameObject.tag == "Enemy2") { GameObject effect = (GameObject)Instantiate(damage_effect, transform.position, transform.rotation); Destroy(effect, 1f); enemy_script2 = col.GetComponent<enemy2>(); enemy_script2.ReceiveDamage(damage); durability--; if (durability <= 0) { Destroy(this.gameObject); } } }
// Use this for initialization void Start() { en = FindObjectOfType <enemy>(); en1 = FindObjectOfType <enemy1>(); en2 = FindObjectOfType <enemy2>(); bos = FindObjectOfType <Boss>(); }
void OnTriggerEnter(Collider col) { if (col.gameObject.tag == "Enemy") { enemy_script = col.GetComponent <enemy>(); enemy_script.SlowDown(); durability--; if (durability <= 0) { Destroy(this.gameObject); } } if (col.gameObject.tag == "Enemy2") { enemy_script2 = col.GetComponent <enemy2>(); enemy_script2.SlowDown(); durability--; if (durability <= 0) { Destroy(this.gameObject); } } }
// Use this for initialization void Start() { if (transform.parent.gameObject.tag == "Enemy") { enemy_scr = transform.parent.GetComponent <enemy>(); } else { enemy2_scr = transform.parent.GetComponent <enemy2>(); } }
// Start is called before the first frame update void Start() { Instance = this; speed = 25; rb = GetComponent <Rigidbody2D>(); spriteRenderer = GetComponent <SpriteRenderer>(); rb.velocity = Vector2.left * speed; StartCoroutine(spawnBullet()); }
public void ReactToHit() { WanderingAI behavior = GetComponent <WanderingAI>(); enemy2 behavior2 = GetComponent <enemy2>(); _animator = this.GetComponent <Animator> (); if (behavior != null) { behavior.SetAlive(false); StartCoroutine(Die()); } else if (behavior2 != null) { behavior2.SetAlive(false); StartCoroutine(Die()); } }
void OnTriggerEnter(Collider other) { PlayerCharacter player = other.GetComponent <PlayerCharacter>(); if (player != null) { // print("hit"); player.Hurt(damage); } enemy2 zombie = other.GetComponent <enemy2>(); boss boss = other.GetComponent <boss>(); WanderingAI reptile = other.GetComponent <WanderingAI>(); if (zombie != null) { ReactiveTarget target = zombie.GetComponent <ReactiveTarget>(); print("child found"); zombie.transform.Find("blood").gameObject.active = true; // the code here is called // for each child named Bone target.ReactToHit(); } else if (reptile != null) { print("reptile hit"); ReactiveTarget target = reptile.GetComponent <ReactiveTarget>(); target.ReactToHit(); } else if (boss != null) { boss.hurt(10); } Destroy(this.gameObject); }
void OnTriggerEnter(Collider col) { if (col.gameObject.tag == "Enemy") { GameObject effect = (GameObject)Instantiate(damage_effect, transform.position, transform.rotation); Destroy(effect, 1f); enemy_script = col.GetComponent <enemy>(); if (enemy_script.slowed) { damage += damage_bonus; enemy_script.ReceiveDamage(damage); damage -= damage_bonus; } else { enemy_script.ReceiveDamage(damage); } enemy_script.GetBurned(); } if (col.gameObject.tag == "Enemy2") { GameObject effect = (GameObject)Instantiate(damage_effect, transform.position, transform.rotation); Destroy(effect, 1f); enemy_script2 = col.GetComponent <enemy2>(); if (enemy_script2.slowed) { damage += damage_bonus; enemy_script2.ReceiveDamage(damage); damage -= damage_bonus; } else { enemy_script2.ReceiveDamage(damage); } enemy_script2.GetBurned(); } }
void OnTriggerEnter(Collider col) { if (col != null) { if (col.gameObject.tag == "Enemy") { enemy_script = col.GetComponent <enemy>(); enemy_script.ReceiveDamage(damage); exploding = true; rb.isKinematic = true; rendr.material.color = explosion_color; } if (col.gameObject.tag == "Enemy2") { enemy_script2 = col.GetComponent <enemy2>(); enemy_script2.ReceiveDamage(damage); exploding = true; rb.isKinematic = true; rendr.material.color = explosion_color; } } }