private void CreateBomb(Direction dir) { Vector3 offset; switch (dir) { case Direction.UP: offset = Vector2.up; break; case Direction.DOWN: offset = Vector2.down; break; case Direction.RIGHT: offset = Vector2.right; break; case Direction.LEFT: offset = Vector2.left; break; default: offset = new Vector3(0, 0, 0); break; } LitBomb bomb; bomb = Instantiate(bombPrefab, transform.position + offset, Quaternion.identity).GetComponent <LitBomb>(); sm.AddBomb(bomb); }