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))); } }
private IEnumerator Wave1FairyPattern(LambdaShotPattern pattern, List <UDEAbstractBullet> bullets, UDEEnemy enemy) { var trResult = UDETransitionHelper.MoveAmount(enemy.gameObject, new Vector2(-3, 0), 0.3f, UDETransitionHelper.easeOutQuad, UDETime.TimeScale.ENEMY, true); yield return(new WaitUntil(() => trResult.EndTransition)); Transform enemyTr = enemy.transform; Transform player = GameManager.player.transform; Vector2 direction = player.position - enemyTr.position; direction /= direction.magnitude; (_, float angle) = UDEMath.Cartesian2Polar(direction); UDECartesianPolarMovementBuilder builder = UDECartesianPolarMovementBuilder.Create().Speed(9.0f).MinSpeed(3.0f).TangentialAccel(-17.0f); int bulletCnt = 25; float delta = 360f / bulletCnt; for (int i = 0; i < bulletCnt; i++) { float moveAngle = angle + delta * i; (float x, float y) = UDEMath.Polar2Cartesian(0.4f, moveAngle); UDEAbstractBullet bullet = UDEBulletPool.Instance.GetBullet(bullets[0]); bullet.SummonTime = 0.12f; bullet.Initialize(enemyTr.position + new Vector3(x, y), enemyTr.position, 0, enemy, pattern, builder.Angle(moveAngle).Build()); } builder.Angle(angle); for (int i = 1; i < 6; i++) { (float x, float y) = UDEMath.Polar2Cartesian(0.4f, angle); UDEAbstractBullet bullet = UDEBulletPool.Instance.GetBullet(bullets[0]); bullet.SummonTime = 0.12f; bullet.Initialize(enemyTr.position + new Vector3(x, y), enemyTr.position, 0, enemy, pattern, builder.MinSpeed(3.0f + 0.6f * i).Build()); } yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(0.5f, UDETime.TimeScale.ENEMY))); Vector2 movePoint = Camera.main.ViewportToWorldPoint(new Vector3(-0.1f, 0)); movePoint.y = enemyTr.position.y; trResult = UDETransitionHelper.MoveTo(enemy.gameObject, movePoint, 10f, UDETransitionHelper.easeInCubic, UDETime.TimeScale.ENEMY, true); yield return(new WaitUntil(() => trResult.EndTransition)); ((EnemyBase)enemy).OnDestroy(); Destroy(enemy); yield return(null); }
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))); } }
private IEnumerator Wave2FairyPattern(LambdaShotPattern pattern, List <UDEAbstractBullet> bullets, UDEEnemy enemy) { UDETransitionHelper.MoveAmount(enemy.gameObject, new Vector2(-3, 0), 1f, UDETransitionHelper.easeOutQuad, UDETime.TimeScale.ENEMY, true); yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(0.3f, UDETime.TimeScale.ENEMY))); Transform enemyTr = enemy.transform; float angle = 25; var easeInOut = UDETransitionHelper.easeInOutQuad.Composite(t => t / 4); float dt = 0.4f; UDECartesianPolarMovementBuilder builder = UDECartesianPolarMovementBuilder.Create().Speed(4.5f).Angle(180); UDEBulletMovement central = builder.Build(); float accTime = 0; for (int i = 0; i < (int)(8 / dt); i++) { if (accTime <= 4) { angle = 25 - 50 * easeInOut(accTime); } else { angle = -25 + 50 * easeInOut(accTime - 4); } UDEBulletMovement upper = builder.Angle(180 - angle).Build(); UDEBulletMovement lower = builder.Angle(180 + angle).Build(); UDEAbstractBullet bullet = UDEBulletPool.Instance.GetBullet(bullets[0]); // Upper bullet.SummonTime = 0.05f; bullet.transform.localScale = new Vector3(0.85f, 0.85f); bullet.Initialize(enemyTr.position, enemyTr.position, 0, enemy, pattern, upper); bullet = UDEBulletPool.Instance.GetBullet(bullets[1]); // Lower bullet.SummonTime = 0.05f; bullet.transform.localScale = new Vector3(0.85f, 0.85f); bullet.Initialize(enemyTr.position, enemyTr.position, 0, enemy, pattern, lower); float accTimeD = accTime + 1f; if (accTimeD >= 8) { accTimeD -= 8; } if (accTimeD <= 4) { angle = 25 - 50 * easeInOut(accTimeD); } else { angle = -25 + 50 * easeInOut(accTimeD - 4); } upper.angle = 180 - angle * 2f; bullet = UDEBulletPool.Instance.GetBullet(bullets[2]); bullet.SummonTime = 0.05f; bullet.transform.localScale = new Vector3(0.85f, 0.85f); bullet.Initialize(enemyTr.position, enemyTr.position, 0, enemy, pattern, upper); lower.angle = 180 + angle * 2f; bullet = UDEBulletPool.Instance.GetBullet(bullets[2]); bullet.SummonTime = 0.05f; bullet.transform.localScale = new Vector3(0.85f, 0.85f); bullet.Initialize(enemyTr.position, enemyTr.position, 0, enemy, pattern, lower); accTime += dt; yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(dt, UDETime.TimeScale.ENEMY))); } Vector2 movePoint = Camera.main.ViewportToWorldPoint(new Vector3(-0.1f, 0)); movePoint.y = enemyTr.position.y; var trResult = UDETransitionHelper.MoveTo(enemy.gameObject, movePoint, 6f, UDETransitionHelper.easeInQuad, UDETime.TimeScale.ENEMY, true); yield return(new WaitUntil(() => trResult.EndTransition)); ((EnemyBase)enemy).OnDestroy(); Destroy(enemy); yield return(null); }
protected override IEnumerator ShotPattern() { originEnemy.transform.SetPositionAndRotation(Camera.main.ViewportToWorldPoint(new Vector3(1.1f, 0.5f, 0)), Quaternion.Euler(0, 0, 0)); var trResult = UDETransitionHelper.MoveTo(originEnemy.gameObject, Camera.main.ViewportToWorldPoint(new Vector3(0.8f, 0.5f, 0)), 0.5f, UDETransitionHelper.easeOutCubic, UDETime.TimeScale.ENEMY, true); originEnemy.CanBeDamaged = false; yield return(new WaitUntil(() => trResult.EndTransition)); originEnemy.CanBeDamaged = true; IUDERandom random = new UDEXORRandom(); Vector2 moveVector = Camera.main.ViewportToWorldPoint(new Vector3(0.5f, 0.65f, 0)); moveVector = new Vector2(0, moveVector.y); while (true) { float dtheta = 360f / numberOfGreenBullets; for (int i = 0; i < numberOfGreenBullets; i++) { UDEAbstractBullet bullet = UDEBulletPool.Instance.GetBullet(patternBullets[GreenLuminusBullet]); bullet.transform.localScale = new Vector3(0.7f, 0.7f); bullet.SummonTime = 0.08f; (float x, float y) = UDEMath.Polar2Cartesian(greenBulletSpeed, i * dtheta); bullet.MoveBulletToDirection(originEnemy, this, originEnemy.transform.position, 0, new Vector2(x, y)); } yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(0.35f, UDETime.TimeScale.ENEMY))); Vector2 playerPos = GameManager.player.transform.position; Vector2 direction = playerPos - (Vector2)originEnemy.transform.position; (_, float angle) = UDEMath.Cartesian2Polar(direction); Vector2 vel1 = UDEMath.Polar2Cartesian(blueBulletSpeed, angle).ToVector2(); Vector2 vel2 = UDEMath.Polar2Cartesian(blueBulletSpeed, angle + blueBulletAngle).ToVector2(); Vector2 vel3 = UDEMath.Polar2Cartesian(blueBulletSpeed, angle - blueBulletAngle).ToVector2(); for (int i = 0; i < 5; i++) { UDEAbstractBullet bullet = UDEBulletPool.Instance.GetBullet(patternBullets[LightBlueLuminusBullet]); bullet.transform.localScale = new Vector3(0.7f, 0.7f); bullet.SummonTime = 0.08f; bullet.MoveBulletToDirection(originEnemy, this, originEnemy.transform.position, 0, vel1); bullet = UDEBulletPool.Instance.GetBullet(patternBullets[LightBlueLuminusBullet]); bullet.transform.localScale = new Vector3(0.7f, 0.7f); bullet.SummonTime = 0.08f; bullet.MoveBulletToDirection(originEnemy, this, originEnemy.transform.position, 0, vel2); bullet = UDEBulletPool.Instance.GetBullet(patternBullets[LightBlueLuminusBullet]); bullet.transform.localScale = new Vector3(0.7f, 0.7f); bullet.SummonTime = 0.08f; bullet.MoveBulletToDirection(originEnemy, this, originEnemy.transform.position, 0, vel3); yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(0.15f, UDETime.TimeScale.ENEMY))); } int flag = random.NextInt(0, 100); Vector2 curPos = Camera.main.WorldToViewportPoint(originEnemy.transform.position); if (flag < 50) // Move up { if (curPos.y >= 0.79f) // Move down { UDETransitionHelper.MoveAmount(originEnemy.gameObject, -moveVector, 1f, UDETransitionHelper.easeOutCubic, UDETime.TimeScale.ENEMY, true); } else { UDETransitionHelper.MoveAmount(originEnemy.gameObject, moveVector, 1f, UDETransitionHelper.easeOutCubic, UDETime.TimeScale.ENEMY, true); } } else // Move down { if (curPos.y <= 0.21f) // Move up { UDETransitionHelper.MoveAmount(originEnemy.gameObject, moveVector, 1f, UDETransitionHelper.easeOutCubic, UDETime.TimeScale.ENEMY, true); } else { UDETransitionHelper.MoveAmount(originEnemy.gameObject, -moveVector, 1f, UDETransitionHelper.easeOutCubic, UDETime.TimeScale.ENEMY, true); } } yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(0.3f, UDETime.TimeScale.ENEMY))); for (int i = 0; i < numberOfGreenBullets; i++) { UDEAbstractBullet bullet = UDEBulletPool.Instance.GetBullet(patternBullets[GreenLuminusBullet]); bullet.transform.localScale = new Vector3(0.7f, 0.7f); bullet.SummonTime = 0.08f; (float x, float y) = UDEMath.Polar2Cartesian(greenBulletSpeed, i * dtheta); bullet.MoveBulletToDirection(originEnemy, this, originEnemy.transform.position, 0, new Vector2(x, y)); } yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(0.7f, UDETime.TimeScale.ENEMY))); } }
protected override IEnumerator ShotPattern() { /* * float AngleDeg = (360f / NumberOfBullets); * float AngleRef = 0f; * float RefOmega = 0f; * while (true) * { * for (int i = 0; i < NumberOfBullets; i++) * { * UDEBaseBullet bullet = UDEBulletPool.Instance.GetBullet(baseBullets[0]); * UDEBulletMovement movement = UDEPolarMovementBuilder.Create().RadialSpeed(BulletSpeed).InitialAngle(i * AngleDeg + AngleRef).Build(); * Vector2 origin = originEnemy.transform.position; * var formLocTuple = UDEMath.Polar2Cartesian(0.7f, movement.angle); * Vector2 formLocation = new Vector2(formLocTuple.x, formLocTuple.y) + origin; * bullet.Initialize(formLocation, origin, 0, originEnemy, this, true, movement); * } * AngleRef += RefOmega; * RefOmega += 0.2f; * if (RefOmega >= 360) * RefOmega -= 360; * if (AngleRef >= 360) * AngleRef -= 360; * yield return StartCoroutine(UDETime.Instance.WaitForScaledSeconds(0.07f, UDETime.TimeScale.ENEMY)); * } */ float angle = 360f / NumberOfBullets; var result = UDETransitionHelper.MoveTo(originEnemy.gameObject, (Vector2)Camera.main.ViewportToWorldPoint(new Vector3(0.5f, 0.85f)), 1.5f, UDETransitionHelper.easeOutCubic, UDETime.TimeScale.ENEMY, true); yield return(new WaitUntil(() => result.EndTransition)); yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(0.5f, UDETime.TimeScale.ENEMY))); for (int i = 0; true; i++) { float extraAngle = Random.Range(-3f, 3f); UDECartesianPolarMovementBuilder builder = UDECartesianPolarMovementBuilder.Create().Speed(BulletSpeed); UDECartesianPolarMovementBuilder builderSlower = UDECartesianPolarMovementBuilder.Create(true).TangentialAccel(-8).MinSpeed(BulletSpeed * 0.6f).StartTime(0.3f); for (int j = 0; j < NumberOfBullets; j++) { UDEAbstractBullet bullet = UDEBulletPool.Instance.GetBullet(patternBullets[0]); UDEBulletMovement movement = builder.Angle(extraAngle + angle * j).Build(); UDEBulletMovement movementSlow = builderSlower.Angle(extraAngle + angle * j).Build(); Vector2 origin = originEnemy.transform.position; Vector2 formLocation = UDEMath.Polar2Cartesian(0.7f, movement.angle).ToVector2() + origin; bullet.Initialize(formLocation, origin, 0, originEnemy, this, new UDEBulletMovement[] { movement, movementSlow }); if (i % 4 == 0) { UDEAbstractBullet extraBullet = UDEBulletPool.Instance.GetBullet(patternBullets[1]); UDEBulletMovement movement2 = builder.Speed(BulletSpeed * 0.35f).Angle(extraAngle + angle * j).Build(); builder.Speed(BulletSpeed); extraBullet.Initialize(formLocation, origin, 0, originEnemy, this, movement2); } } if (i % 4 == 0) { switch ((i % 16) / 4) { case 0: case 3: UDETransitionHelper.MoveAmount(originEnemy.gameObject, new Vector2(2, 0), 0.95f, UDETransitionHelper.easeOutQuad, UDETime.TimeScale.ENEMY, true); break; case 1: case 2: UDETransitionHelper.MoveAmount(originEnemy.gameObject, new Vector2(-2, 0), 0.95f, UDETransitionHelper.easeOutQuad, UDETime.TimeScale.ENEMY, true); break; } } yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(0.25f, UDETime.TimeScale.ENEMY))); } }
// TODO: Reduce player's power and drop some power. private IEnumerator DamageSelf(float damage) { animator.SetFloat("Direction", 0); health -= damage; healthBar.fillAmount = health / MaxHealth; healthText.text = $"x{health:0.0}"; invincible = true; controllable = false; SpriteRenderer renderer = self.GetComponent <SpriteRenderer>(); Color col = renderer.color; col.a = 0.5f; renderer.color = col; // TODO: Convert enemy bullets into items within a circle. UDEObjectManager.Instance.DestroyAllBullets(); Vector3 pos = characterTr.position; ColorInvert inv1 = Instantiate <ColorInvert>(circleColorInvert, pos + new Vector3(1.0f, 1.0f, 0), Quaternion.identity); ColorInvert inv2 = Instantiate <ColorInvert>(circleColorInvert, pos + new Vector3(-1.0f, 1.0f, 0), Quaternion.identity); ColorInvert inv3 = Instantiate <ColorInvert>(circleColorInvert, pos + new Vector3(-1.0f, -1.0f, 0), Quaternion.identity); ColorInvert inv4 = Instantiate <ColorInvert>(circleColorInvert, pos + new Vector3(1.0f, -1.0f, 0), Quaternion.identity); inv1.transform.localScale = new Vector3(0.1f, 0.1f, 1); inv2.transform.localScale = new Vector3(0.1f, 0.1f, 1); inv3.transform.localScale = new Vector3(0.1f, 0.1f, 1); inv4.transform.localScale = new Vector3(0.1f, 0.1f, 1); CircleWaveDistortion dist = Instantiate <CircleWaveDistortion>(distortion, pos, Quaternion.identity); dist.Scale = 0.1f; dist.DistortionAlgorithm = CircleWaveDistortion.Algorithm.Polynomial; dist.Distortion = 3; dist.Distortion2 = 2.5f; dist.InnerRadiusRatio = 0.75f; AudioSource dieFX = gameObject.AddComponent <AudioSource>(); dieFX.clip = dieSound; dieFX.volume = 0.7f; dieFX.Play(); float scaleSpeed = 3f; characterTr.position = Camera.main.ViewportToWorldPoint(new Vector3(-0.1f, 0.5f)); UDETransitionHelper.MoveTo( this.gameObject, Camera.main.ViewportToWorldPoint(new Vector3(0.15f, 0.5f)), 1f, UDETransitionHelper.easeLinear, UDETime.TimeScale.PLAYER, false ); yield return(null); float accTime = 0f; while (true) { accTime += Time.deltaTime * UDETime.Instance.PlayerTimeScale; float scale = scaleSpeed * accTime; inv1.transform.localScale = new Vector3(scale, scale, 1); inv2.transform.localScale = new Vector3(scale, scale, 1); inv3.transform.localScale = new Vector3(scale, scale, 1); inv4.transform.localScale = new Vector3(scale, scale, 1); dist.Scale = scale; yield return(null); if (accTime >= 1.5f) { break; } } controllable = true; Destroy(inv1.gameObject); Destroy(inv2.gameObject); Destroy(inv3.gameObject); Destroy(inv4.gameObject); Destroy(dist.gameObject); yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(3f, UDETime.TimeScale.PLAYER))); col.a = 1f; renderer.color = col; Destroy(dieFX); invincible = false; }
protected override IEnumerator ShotPattern() { var result = UDETransitionHelper.MoveTo(originEnemy.gameObject, Camera.main.ViewportToWorldPoint(new Vector3(0.5f, 0.5f)), 2, UDETransitionHelper.easeOutCubic, UDETime.TimeScale.ENEMY, true); originEnemy.CanBeDamaged = false; yield return(new WaitUntil(() => result.EndTransition)); originEnemy.CanBeDamaged = true; StartCoroutine(GravityBullets()); UDECartesianPolarMovementBuilder builder = UDECartesianPolarMovementBuilder.Create().Speed(4f); while (true) { for (int i = 0; i < 3; i++) { Vector2 playerPosition = GameObject.FindGameObjectWithTag("Player").transform.position; Vector2 enemyPosition = originEnemy.transform.position; float angle = UDEMath.Deg(playerPosition - enemyPosition); Vector2 origin = enemyPosition; Vector2 formOriginDispl = UDEMath.Polar2Cartesian(0.3f, angle).ToVector2(); Vector2 formOrigin = origin + formOriginDispl; builder.Angle(angle); UDEBulletMovement movement = builder.Build(); Vector2 formHalfDispl = UDEMath.Polar2Cartesian(0.105f, angle + 90).ToVector2(); for (int n = 1; n <= 6; n++) { if (n % 2 == 0) { for (int j = 0; j < n / 2; j++) { UDEAbstractBullet negBullet = UDEBulletPool.Instance.GetBullet(patternBullets[1]); UDEAbstractBullet posBullet = UDEBulletPool.Instance.GetBullet(patternBullets[1]); negBullet.Initialize(formOrigin - (formHalfDispl * (j * 2 + 1)), origin, 0, originEnemy, this, movement); posBullet.Initialize(formOrigin + (formHalfDispl * (j * 2 + 1)), origin, 0, originEnemy, this, movement); } } else { UDEAbstractBullet middleBullet = UDEBulletPool.Instance.GetBullet(patternBullets[1]); middleBullet.Initialize(formOrigin, origin, 0, originEnemy, this, movement); for (int j = 0; j < n / 2; j++) { UDEAbstractBullet negBullet = UDEBulletPool.Instance.GetBullet(patternBullets[1]); UDEAbstractBullet posBullet = UDEBulletPool.Instance.GetBullet(patternBullets[1]); negBullet.Initialize(formOrigin - (formHalfDispl * (j + 1) * 2), origin, 0, originEnemy, this, movement); posBullet.Initialize(formOrigin + (formHalfDispl * (j + 1) * 2), origin, 0, originEnemy, this, movement); } } yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(0.11f, UDETime.TimeScale.ENEMY))); } yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(0.24f, UDETime.TimeScale.ENEMY))); } yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(2f, UDETime.TimeScale.ENEMY))); } }