void Start() { registeredAtomCreateCommands.Add(new EnemyAtomCreateCommand(AtomPool.GetInstance())); registeredAtomCreateCommands.Add(new FriendlyAtomCreateCommand(AtomPool.GetInstance())); Collider leftCollider = leftWall.GetComponent <Collider>(); Collider rightCollider = rightWall.GetComponent <Collider>(); xLeftOfPlayfield = leftWall.transform.position.x + leftCollider.bounds.extents.x + horizontalSafetyMargin; xRightOfPlayfield = rightWall.transform.position.x - rightCollider.bounds.extents.x - horizontalSafetyMargin; }
void OnCollisionEnter(Collision collision) { if (isDestroyed) { return; } //If the atom we collided with is friendly, we do our stuff if (collision.gameObject.GetComponentInChildren <EnemyController>() == null) { isDestroyed = true; foreach (Docker docker in dockers) { docker.OnHitEnemy(); } destroyAnimator.ResetTrigger("Reset"); destroyAnimator.SetTrigger("Destroy"); const int secondsTillDestruction = 1; AtomPool.GetInstance().DestroyEnemyAtom(transform.parent.gameObject, secondsTillDestruction); } }