// Start is called before the first frame update private void Start() { unit = GetComponent <EnemyUnit>(); bossUdokEnemyUnit = GetComponent <BossUdokEnemyUnit>(); wrathEnemyUnit = GetComponent <WrathEnemy>(); rb = GetComponent <Rigidbody2D>(); // navAgent = GetComponent<NavMeshAgent>(); }
void SpawnShooter() { int spawnPointIndex = Random.Range(0, spawnPoints.Length); GameObject g = Instantiate(enemy, spawnPoints [spawnPointIndex].position, spawnPoints [spawnPointIndex].rotation) as GameObject; WrathEnemy shooter = g.GetComponent <WrathEnemy> (); shooter.isShooter = true; }
void OnCollisionEnter2D(Collision2D coll) { if (coll.gameObject.tag == "Enemy") { WrathEnemy enemy = coll.gameObject.GetComponent <WrathEnemy> (); GameObject body = GetComponent <Collider2D> ().gameObject; GameObject bodyParent = body.transform.parent.gameObject; bodyParent.GetComponent <WrathCharacter> ().DamagePlayer(Damage); Debug.Log("Player took" + "34" + "damage."); WrathMaster.KillEnemy(enemy); } }
void Shoot() { Vector2 mousePosition = new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y); Vector2 firePointPosition = new Vector2(firePoint.position.x, firePoint.position.y); RaycastHit2D hit = Physics2D.Raycast(firePointPosition, mousePosition - firePointPosition, 100, whatToHit); if (Time.time >= timeToSpawnEffect) { Effect(); timeToSpawnEffect = Time.time + 1 / effectSpawnRate; } Debug.DrawLine(firePointPosition, (mousePosition - firePointPosition) * 100, Color.cyan, 4); if (hit.collider != null) { Debug.DrawLine(firePointPosition, hit.point, Color.red, 2); WrathEnemy enemy = hit.collider.GetComponent <WrathEnemy> (); if (enemy != null) { enemy.DamageEnemy(Damage); Debug.Log("We hit " + hit.collider.name + " and did " + Damage + " damage."); } } }
public static void KillEnemy(WrathEnemy enemy) { Destroy(enemy.gameObject); killCount++; }