private IEnumerator LeafFallSubPattern() { IUDERandom rand = new UDEXORRandom(); UDECartesianMovementBuilder builder = UDECartesianMovementBuilder.Create(); builder.Velocity(Vector2.zero) .Accel(t => new UDEMath.CartesianCoord( 6f * Mathf.Log10(t + 1f) * Mathf.Cos(2 * Mathf.PI * t / 2.0f), -2.0f )) .MinVelocity(new Vector2(float.MinValue, -6.0f)) .DoNotFaceToMovingDirection(); UDEBulletMovement leafFall = builder.Build(); while (true) { UDEAbstractBullet bullet = UDEBulletPool.Instance.GetBullet(patternBullets[GreenLuminusBullet]); bullet.transform.localScale = new Vector3(0.82f, 0.82f); bullet.SummonTime = 0f; Vector2 initPos = (Vector2)Camera.main.ViewportToWorldPoint(new Vector3(rand.NextFloat(0.01f, 0.99f), 1.05f, 0)); bullet.Initialize(initPos, initPos, 0, originEnemy, this, leafFall); yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(0.25f, UDETime.TimeScale.ENEMY))); } }
private IEnumerator GravityBullets() { while (true) { UDEMath.CartesianCoord accelDown = new UDEMath.CartesianCoord(0, -3); UDEMath.CartesianCoord accelUp = new UDEMath.CartesianCoord(0, 3); UDECartesianMovementBuilder builder = UDECartesianMovementBuilder.Create().MaxMagnitude(6f); for (int i = 0; i < 23; i++) { float angle = 90f + Random.Range(-55f, 55f); var velTuple = UDEMath.Polar2Cartesian(3f, angle); Vector2 velocity = new Vector2(velTuple.x, velTuple.y); Vector2 origin = originEnemy.transform.position; Vector2 player = GameObject.FindGameObjectWithTag("Player").transform.position; if (player.y > origin.y) { builder.Velocity(-velocity).Accel(accelUp); } else { builder.Velocity(velocity).Accel(accelDown); } UDEBulletMovement movement = builder.Build(); UDEAbstractBullet bullet = UDEBulletPool.Instance.GetBullet(patternBullets[0]); bullet.Initialize(origin, origin, 0, originEnemy, this, movement); } yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(0.75f, UDETime.TimeScale.ENEMY))); } }
public static void MoveBulletToDirection( this UDEAbstractBullet bullet, UDEBaseCharacter shooter, UDEBaseShotPattern originShotPattern, Vector2 initialPos, float initialRotation, Vector2 velocity, bool faceToMovingDirection = true) { if (!bullet.gameObject.activeSelf) { return; } UDECartesianMovementBuilder builder = UDECartesianMovementBuilder.Create().Velocity(velocity); if (!faceToMovingDirection) { builder = builder.DoNotFaceToMovingDirection(); } bullet.Initialize(initialPos, initialPos, initialRotation, shooter, originShotPattern, builder.Build()); }