Beispiel #1
0
    public static void Spawn()
    {
        var position = SceneHelper.GetSpawnPosition(Random.Range(3, 6));

        position.Set(position.x * SceneHelper.GetRandomMultiplier(), position.y); // spawn from left side as well
        var ufo = ResourcesLoader.GetUFO();

        Instantiate(ufo, position, Quaternion.identity);
    }
    public void Start()
    {
        //add teleportable behaviour
        _tb = new TeleportableBehaviour(transform, imageWidth, imageHeight);

        _eb           = gameObject.AddComponent <ExplodableBehaviour>();
        _eb.Transform = transform;
        _eb.Bounty    = AsteroidHelper.GetBounty(stage);

        //add random forces
        Vector2 velocity = new Vector2(Random.Range(minVelocity, maxVelocity) * SceneHelper.GetRandomMultiplier(),
                                       Random.Range(minVelocity, maxVelocity) * SceneHelper.GetRandomMultiplier());
        float torque = Random.Range(-maxTorque, maxTorque);

        rb.AddForce(velocity);
        rb.AddTorque(torque);

        //link to the particles
        _explosion = ResourcesLoader.GetExplosion();
    }