Example #1
0
    public void SlicePlanetoids(Ray2D laser, float laserPower)
    {
        Debug.DrawLine(laser.origin, laser.origin + laser.direction * Laser.LASER_DISTANCE, Color.red, 2.0f);

        RaycastHit2D[] hits = Physics2D.RaycastAll(laser.origin, laser.direction, Laser.LASER_DISTANCE, 1 << _planetoidPrefab.gameObject.layer);
        foreach (var hit in hits)
        {
            Planetoid hitPlanetoid = hit.transform.GetComponent <Planetoid>();
            hitPlanetoid.Slice(laser, laserPower, this);
        }
    }