Beispiel #1
0
    private void Start()
    {
        float spawnY = MathHelper.randomRangeFromVector(spawnRange);
        var   flip   = false;

        if (flipYMode == FlipYMode.Alternating)
        {
            if (flipInstruction == FlipAlternateInstruction.FlipSecond)
            {
                flip = true;
            }
            else if (flipInstruction == FlipAlternateInstruction.Awaiting)
            {
                flipInstruction = MathHelper.randomBool() ? FlipAlternateInstruction.FlipFirst : FlipAlternateInstruction.FlipSecond;
                if (flipInstruction == FlipAlternateInstruction.FlipFirst)
                {
                    flip = true;
                }
            }
        }
        else if (flipYMode == FlipYMode.Random)
        {
            flip = MathHelper.randomBool();
        }

        if (flip)
        {
            spawnY *= -1f;
        }
        transform.position = new Vector3(transform.position.x, spawnY, transform.position.x);

        velocity = new Vector2(MathHelper.randomRangeFromVector(velXRange), MathHelper.randomRangeFromVector(velYRange));
        if (verticalSpeedMode == VerticalSpeedMode.OppositeOfY)
        {
            velocity.y = Mathf.Abs(velocity.y) * -Mathf.Sign(transform.position.y);
        }
    }
Beispiel #2
0
 private void Awake()
 {
     flipInstruction = FlipAlternateInstruction.Awaiting;
 }