public void _killEnemy(Enmy _enemy) { Transform _clone = Instantiate(_enemy.deatheathParticles, _enemy.transform.position, Quaternion.identity) as Transform; Destroy(_clone.gameObject, 5f); cameraShake.Shake(_enemy.shakeAmt, _enemy.shakeLength); Destroy(_enemy.gameObject); }
void Shoot() { Vector2 mausePosition = 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, mausePosition - firePointPosition, 100, whatToHit); Debug.DrawLine(firePointPosition, (mausePosition - firePointPosition) * 100, Color.cyan); if (hit.collider != null) { Debug.DrawLine(firePointPosition, hit.point, Color.red); Enmy enemy = hit.collider.GetComponent <Enmy>(); if (enemy != null) { enemy.DamageEnemy((int)Damage); Debug.Log("We hit " + hit.collider.name + " and dif " + Damage + " damage."); } } if (Time.time >= timeToSpawnEffect) { Vector3 hitpos; Vector3 hitNormal; if (hit.collider == null) { hitpos = (mausePosition - firePointPosition) * 30; hitNormal = new Vector3(9999, 9999, 9999); } else { hitpos = hit.point; hitNormal = hit.normal; } Effect(hitpos, hitNormal); timeToSpawnEffect = Time.time + 1 / effectSpawnRate; } }
public void AddEnmy(Enmy enmy) { enmies.Add(enmy); }
public static void killEnemy(Enmy enemy) { gm._killEnemy(enemy); }