public static void RotateBulletAroundCharacter( this UDEAbstractBullet bullet, UDEBaseCharacter character, UDEBaseShotPattern originShotPattern, UDEMath.PolarCoord initialPolarCoord, float initialRotation, float angularSpeed, float radialSpeed = 0.0f, bool faceToMovingDirection = true) { if (!bullet.gameObject.activeSelf) { return; } UDEPolarMovementBuilder builder = UDEPolarMovementBuilder.Create().AngularSpeed(angularSpeed).RadialSpeed(radialSpeed); if (!faceToMovingDirection) { builder = builder.DoNotFaceToMovingDirection(); } Vector2 origin = character.transform.position; bullet.Initialize(origin + (Vector2)initialPolarCoord, origin, initialRotation, character, originShotPattern, builder.Build(), true); }
protected override IEnumerator ShotPattern() { originEnemy.CanBeDamaged = false; var result = UDETransitionHelper.MoveTo(originEnemy.gameObject, Camera.main.ViewportToWorldPoint(new Vector3(0.5f, 0.5f)), 2f, UDETransitionHelper.easeOutCubic, UDETime.TimeScale.ENEMY, true); yield return(new WaitUntil(() => result.EndTransition)); originEnemy.CanBeDamaged = true; UDEPolarMovementBuilder builder = UDEPolarMovementBuilder.Create().DoNotFaceToMovingDirection(); float angleDiff = 360f / numberOfBullets; bool lowHealth = false; float summonInterval = 2f; while (true) { if (!lowHealth && originEnemy.Health < 200f) { lowHealth = true; summonInterval = 1.4f; moveIn.RemoveAll(tr => !tr.gameObject.activeSelf); UDEBulletPool.Instance.ReleaseBullets(shottedBullets.ToArray()); moveIn.Clear(); } for (int i = 0; i < numberOfBullets; i++) { float angle = angleDiff * i; UDEAbstractBullet moveOut = UDEBulletPool.Instance.GetBullet(patternBullets[0]); UDEBulletMovement movementOut = builder.RadialSpeed(radialSpeed).AngularSpeed(angularSpeed).RotationAngularSpeed(angularSpeed).Build(); Vector2 origin = enemyTr.position; Vector2 formLoc = origin + UDEMath.Polar2Cartesian(0.3f, angle).ToVector2(); moveOut.Initialize(formLoc, origin, angle, originEnemy, this, movementOut, setOriginToCharacter: true); UDEAbstractBullet moveIn = UDEBulletPool.Instance.GetBullet(patternBullets[0]); UDEBulletMovement movementIn = builder.RadialSpeed(-radialSpeed).AngularSpeed(-angularSpeed).RotationAngularSpeed(-angularSpeed).Build(); formLoc = origin + UDEMath.Polar2Cartesian(8.3f, angle).ToVector2(); moveIn.Initialize(formLoc, origin, angle, originEnemy, this, movementIn, setOriginToCharacter: true); this.moveIn.Add(moveIn.transform); Vector3 moveOutScale = moveOut.transform.localScale; Vector3 moveInScale = moveIn.transform.localScale; moveOutScale *= 2.5f; moveInScale *= 2.5f; moveOut.transform.localScale = moveOutScale; moveIn.transform.localScale = moveInScale; } yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(summonInterval, UDETime.TimeScale.ENEMY))); } }
protected override IEnumerator ShotPattern() { originEnemy.CanBeDamaged = false; var result = UDETransitionHelper.MoveTo(originEnemy.gameObject, Camera.main.ViewportToWorldPoint(new Vector3(0.5f, 0.85f)), 2f, UDETransitionHelper.easeOutCubic, UDETime.TimeScale.ENEMY, true); yield return(new WaitUntil(() => result.EndTransition)); originEnemy.CanBeDamaged = true; float angleDiff = 360f / (float)bulletNumber; float angleClockwise = 0; float angleAntiClockwise = 0; UDEPolarMovementBuilder builder = UDEPolarMovementBuilder.Create().RadialSpeed(bulletSpeed); while (true) { for (int i = 0; i < bulletNumber; i++) { float angle = angleDiff * i + angleClockwise; builder.InitialAngle(angle); UDEAbstractBullet bullet = UDEBulletPool.Instance.GetBullet(patternBullets[0]); Vector2 origin = originEnemy.transform.position; Vector2 formLoc = origin + (UDEMath.CartesianCoord) new UDEMath.PolarCoord(0.35f, angle); bullet.Initialize(formLoc, origin, 0, originEnemy, this, builder.Build()); angle = angleDiff * i + angleAntiClockwise; builder.InitialAngle(angle); UDEAbstractBullet bullet2 = UDEBulletPool.Instance.GetBullet(patternBullets[0]); formLoc = origin + (UDEMath.CartesianCoord) new UDEMath.PolarCoord(0.35f, angle); bullet2.Initialize(formLoc, origin, 0, originEnemy, this, builder.Build()); } angleClockwise -= angularSpeed; angleAntiClockwise += angularSpeed; while (angleClockwise < 0) { angleClockwise += 360f; } while (angleAntiClockwise > 360) { angleAntiClockwise -= 360f; } yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(0.12f, UDETime.TimeScale.ENEMY))); } }
protected override IEnumerator ShotPattern() { originEnemy.CanBeDamaged = false; var result = UDETransitionHelper.MoveTo(originEnemy.gameObject, Camera.main.ViewportToWorldPoint(new Vector3(0.5f, 0.5f)), 2f, UDETransitionHelper.easeInOutCubic, UDETime.TimeScale.ENEMY, true); yield return(new WaitUntil(() => result.EndTransition)); originEnemy.CanBeDamaged = true; UDEMath.PolarFunction bulletPosition = (deg, err) => 0.3f + 2.5f * (deg - err) / 360f; UDEMath.PolarFunction bulletPositionInverse = (deg, err) => 0.3f + 2.5f * (err - deg) / 360f; UDEPolarMovementBuilder first = UDEPolarMovementBuilder.Create().DoNotFaceToMovingDirection(); UDEPolarMovementBuilder second = UDEPolarMovementBuilder.Create(true).MinAngularSpeed(-30f).MinRadialSpeed(-2.2f).AngularAccel(-25f).RadialAccel(-1.8f).StartTime(1000); Vector2 origin = originEnemy.transform.position; int cnt = 0; while (true) { float error = Random.Range(-10f, 10f); UDEMath.PolarCoord[] coords = cnt % 2 == 0 ? UDEMath.GetPolarCoordStructs(bulletPosition, error, 3 * 360 + error, error, 500) : UDEMath.GetPolarCoordStructs(bulletPositionInverse, -error, -error - 3 * 360, -error, 500); for (int i = 0; i < coords.Length; i++) { UDEAbstractBullet bullet = UDEBulletPool.Instance.GetBullet(patternBullets[0]); Vector2 formLoc = origin + (UDEMath.CartesianCoord)coords[i]; float angle = coords[i].degree - 90f; UDEBulletMovement[] movements = new UDEBulletMovement[] { first.Build(), second.Build() }; bullet.Initialize(formLoc, origin, angle, originEnemy, this, movements); bullets.Add(bullet); yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(0.012f, UDETime.TimeScale.ENEMY))); } yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(1f, UDETime.TimeScale.ENEMY))); for (int i = bullets.Count - 1; i > -1; i--) { ((dynamic)bullets[i]).ForceMoveToPhase(1); bullets.RemoveAt(i); } yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(7f, UDETime.TimeScale.ENEMY))); cnt++; } }
protected override IEnumerator ShotPattern() { UDETransitionHelper.StopAllTransitions(originEnemy.gameObject); originalBackgroundColor = background.GetComponent <SpriteRenderer>().color; originEnemy.CanBeDamaged = false; UDETransitionHelper.MoveTo(originEnemy.gameObject, Camera.main.ViewportToWorldPoint(new Vector3(0.77f, 0.5f, 0)), 0.75f, UDETransitionHelper.easeOutCubic, UDE.Management.UDETime.TimeScale.ENEMY, true); UDETransitionHelper.ChangeScaleTo(background, new Vector3(1.2f, 1.2f, 1f), 1f, UDETransitionHelper.easeLinear, UDETime.TimeScale.ENEMY, false); UDETransitionHelper.ChangeColorTo(background, changeBackgroundColorTo, 1f, UDETransitionHelper.easeLinear, UDETime.TimeScale.ENEMY, false); yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(2f, UDETime.TimeScale.ENEMY))); originEnemy.CanBeDamaged = true; IEnumerator leafFallPattern = LeafFallSubPattern(); StartSubpattern(leafFallPattern); UDEPolarMovementBuilder builder = UDEPolarMovementBuilder.Create().RadialSpeed(radialSpeed); UDEBulletMovement movement = builder.Build(); float currAngle = 0f; float dtheta = 360f / numberOfBullets; while (true) { for (int i = 0; i < numberOfBullets; i++) { UDEAbstractBullet bullet = UDEBulletPool.Instance.GetBullet(patternBullets[LightBlueCircleBullet]); bullet.SummonTime = 0.1f; Vector2 origin = originEnemy.transform.position; Vector2 initPos = UDEMath.Polar2Cartesian(0.1f, currAngle + dtheta * i).ToVector2() + origin; bullet.Initialize(initPos, origin, 0, originEnemy, this, movement); } currAngle += angleDifference; yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(1.5f, UDETime.TimeScale.ENEMY))); } }
protected override IEnumerator ShotPattern() { originEnemy.CanBeDamaged = false; var result = UDETransitionHelper.MoveTo(originEnemy.gameObject, Camera.main.ViewportToWorldPoint(new Vector3(0.5f, 0.85f)), 2f, UDETransitionHelper.easeOutCubic, UDETime.TimeScale.ENEMY, true); yield return(new WaitUntil(() => result.EndTransition)); originEnemy.CanBeDamaged = true; UDEPolarMovementBuilder[] builders = new UDEPolarMovementBuilder[3]; builders[0] = UDEPolarMovementBuilder.Create().RadialSpeed(4.5f); builders[1] = UDEPolarMovementBuilder.Create(true).RadialAccel(25f).MaxRadialSpeed(10f).StartTime(0.3f); builders[2] = UDEPolarMovementBuilder.Create(true).RadialAccel(-22f).MinRadialSpeed(0.6f).StartTime(0.65f); float angleInterval = 360f / groupCount; float smallAngleInterval = angleInterval / bulletsPerGroup * 1.25f; int flag = 0; while (true) { float deviation = Random.Range(-15f, 15f); for (int i = 0; i < bulletsPerGroup; i++) { UDEAbstractBullet[] bullets = new UDEAbstractBullet[groupCount]; for (int n = 0; n < bullets.Length; n++) { bullets[n] = UDEBulletPool.Instance.GetBullet(patternBullets[0]); } for (int j = 0; j < groupCount; j++) { float angle; if (flag % 2 == 0) { angle = deviation + angleInterval * j + smallAngleInterval * i; } else { angle = deviation + angleInterval * j + smallAngleInterval * (bulletsPerGroup - 1 - i); } UDEBulletMovement[] movements = new UDEBulletMovement[builders.Length]; for (int k = 0; k < builders.Length; k++) { builders[k].InitialAngle(angle); movements[k] = builders[k].Build(); } Vector2 origin = originEnemy.transform.position; Vector2 formLoc = origin + UDEMath.Polar2Cartesian(0.45f, angle).ToVector2(); bullets[j].Initialize(formLoc, origin, 0, originEnemy, this, movements); } yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(0.18f, UDETime.TimeScale.ENEMY))); } flag++; yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(0.7f, UDETime.TimeScale.ENEMY))); } }