protected override void Awake() { base.Awake(); subWeapons[0].gameObject.SetActive(false); subWeapons[1].gameObject.SetActive(false); subWeapons[2].gameObject.SetActive(false); subWeapons[3].gameObject.SetActive(false); float innerAngle = subWeaponAngle * 0.5f; float outerAngle = subWeaponAngle * 1.5f; var sb1 = UDEMath.Polar2Cartesian(subWeaponsDistance, innerAngle); var sb3 = UDEMath.Polar2Cartesian(subWeaponsDistance, outerAngle); subWeapons[0].localPosition = new Vector3(-sb1.x, sb1.y, 0); subWeapons[1].localPosition = new Vector3(-sb1.x, -sb1.y, 0); subWeapons[2].localPosition = new Vector3(-sb3.x, sb3.y, 0); subWeapons[3].localPosition = new Vector3(-sb3.x, -sb3.y, 0); UDECartesianPolarMovementBuilder builder = UDECartesianPolarMovementBuilder.Create(); builder.Speed(arrowBulletSpeed * subHomingBulletSpeedSlowMultiplier).Angle(subWeaponShotAngle * 2); homingMove1 = builder.Build(); homingMoveSlow1 = builder.Angle(subWeaponShotAngle * 2 * subWeaponShotAngleSlowMultiplier).Build(); homingMove2 = builder.Angle(-subWeaponShotAngle * 2).Build(); homingMoveSlow2 = builder.Angle(-subWeaponShotAngle * 2 * subWeaponShotAngleSlowMultiplier).Build(); }
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))); } }
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.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++; } }
// Update is called once per frame void Update() { accTime += Time.deltaTime * UDETime.Instance.GetTimeScale(timeScale); float theta = 2 * Mathf.PI * (accTime / period) + Mathf.PI / 4; float r = Mathf.Sin(theta); r = r * r; (float x, float y) = UDEMath.Polar2Cartesian(r, theta * Mathf.Rad2Deg); Vector3 rot = tr.rotation.eulerAngles; rot.x = x * maxAngle; rot.y = y * maxAngle; tr.rotation = Quaternion.Euler(rot); }
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))); } }
private IEnumerator RotateCircle(RectTransform circle, float period, float waitTime, float radius) { UDEMath.TimeFunction func = UDETransitionHelper.easeInOutCubic.Composite(t => t / period); float accTime = 0; while (true) { float angle = -90 + 360 * func(accTime); if (accTime > period) angle = 270; (float x, float y) = UDEMath.Polar2Cartesian(radius, angle); circle.anchoredPosition = new Vector2(x, y); accTime += Time.deltaTime; if (accTime > period + waitTime) accTime = 0; 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; 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))); } }
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))); } }
private IEnumerator SubWeaponTransit() { if (isSlowMode) { float dstAngleInner = subWeaponAngle * subWeaponAngleSlowMultiplier * 0.5f; float dstAngleOuter = subWeaponAngle * subWeaponAngleSlowMultiplier * 1.5f; bool sub1Fin = false, sub2Fin = false, sub3Fin = false, sub4Fin = false; while (true) { Vector2 sub1 = subWeapons[0].localPosition; Vector2 sub2 = subWeapons[1].localPosition; Vector2 sub3 = subWeapons[2].localPosition; Vector2 sub4 = subWeapons[3].localPosition; float sub1Angle = UDEMath.Deg(-sub1.x, sub1.y); float sub2Angle = UDEMath.Deg(-sub2.x, -sub2.y); float sub3Angle = UDEMath.Deg(-sub3.x, sub3.y); float sub4Angle = UDEMath.Deg(-sub4.x, -sub4.y); float timeScale = UDETime.Instance.PlayerTimeScale; float deltaTime = Time.deltaTime; sub1Angle -= subWeaponAngle * 4 * deltaTime * timeScale; sub2Angle -= subWeaponAngle * 4 * deltaTime * timeScale; sub3Angle -= subWeaponAngle * 8 * deltaTime * timeScale; sub4Angle -= subWeaponAngle * 8 * deltaTime * timeScale; if (sub1Angle <= dstAngleInner) { sub1Angle = dstAngleInner; sub1Fin = true; } if (sub2Angle <= dstAngleInner) { sub2Angle = dstAngleInner; sub2Fin = true; } if (sub3Angle <= dstAngleOuter) { sub3Angle = dstAngleOuter; sub3Fin = true; } if (sub4Angle <= dstAngleOuter) { sub4Angle = dstAngleOuter; sub4Fin = true; } var sb1 = UDEMath.Polar2Cartesian(subWeaponsDistance, sub1Angle); var sb2 = UDEMath.Polar2Cartesian(subWeaponsDistance, sub2Angle); var sb3 = UDEMath.Polar2Cartesian(subWeaponsDistance, sub3Angle); var sb4 = UDEMath.Polar2Cartesian(subWeaponsDistance, sub4Angle); subWeapons[0].localPosition = new Vector3(-sb1.x, sb1.y, 0); subWeapons[1].localPosition = new Vector3(-sb2.x, -sb2.y, 0); subWeapons[2].localPosition = new Vector3(-sb3.x, sb3.y, 0); subWeapons[3].localPosition = new Vector3(-sb4.x, -sb4.y, 0); if (sub1Fin && sub2Fin && sub3Fin && sub4Fin) { break; } yield return(null); } yield return(null); } else { float dstAngleInner = subWeaponAngle * 0.5f; float dstAngleOuter = subWeaponAngle * 1.5f; bool sub1Fin = false, sub2Fin = false, sub3Fin = false, sub4Fin = false; while (true) { Vector2 sub1 = subWeapons[0].localPosition; Vector2 sub2 = subWeapons[1].localPosition; Vector2 sub3 = subWeapons[2].localPosition; Vector2 sub4 = subWeapons[3].localPosition; float sub1Angle = UDEMath.Deg(-sub1.x, sub1.y); float sub2Angle = UDEMath.Deg(-sub2.x, -sub2.y); float sub3Angle = UDEMath.Deg(-sub3.x, sub3.y); float sub4Angle = UDEMath.Deg(-sub4.x, -sub4.y); float timeScale = UDETime.Instance.PlayerTimeScale; float deltaTime = Time.deltaTime; sub1Angle += subWeaponAngle * 4 * deltaTime * timeScale; sub2Angle += subWeaponAngle * 4 * deltaTime * timeScale; sub3Angle += subWeaponAngle * 8 * deltaTime * timeScale; sub4Angle += subWeaponAngle * 8 * deltaTime * timeScale; if (sub1Angle >= dstAngleInner) { sub1Angle = dstAngleInner; sub1Fin = true; } if (sub2Angle >= dstAngleInner) { sub2Angle = dstAngleInner; sub2Fin = true; } if (sub3Angle >= dstAngleOuter) { sub3Angle = dstAngleOuter; sub3Fin = true; } if (sub4Angle >= dstAngleOuter) { sub4Angle = dstAngleOuter; sub4Fin = true; } var sb1 = UDEMath.Polar2Cartesian(subWeaponsDistance, sub1Angle); var sb2 = UDEMath.Polar2Cartesian(subWeaponsDistance, sub2Angle); var sb3 = UDEMath.Polar2Cartesian(subWeaponsDistance, sub3Angle); var sb4 = UDEMath.Polar2Cartesian(subWeaponsDistance, sub4Angle); subWeapons[0].localPosition = new Vector3(-sb1.x, sb1.y, 0); subWeapons[1].localPosition = new Vector3(-sb2.x, -sb2.y, 0); subWeapons[2].localPosition = new Vector3(-sb3.x, sb3.y, 0); subWeapons[3].localPosition = new Vector3(-sb4.x, -sb4.y, 0); if (sub1Fin && sub2Fin && sub3Fin && sub4Fin) { break; } yield return(null); } yield return(null); } }
private void ShotBullet() { UDEAbstractBullet bullet = UDEBulletPool.Instance.GetBullet(mainBullet); bullet.Damage = mainCenterBulletDamage; bullet.MoveBulletToDirection(this, null, mainShotPoint.position, 0, new Vector2(arrowBulletSpeed, 0)); if (powerLevel >= 1) { bullet = UDEBulletPool.Instance.GetBullet(mainBullet); bullet.Damage = mainSubBulletDamage; var vel = UDEMath.Polar2Cartesian(arrowBulletSpeed, mainShotAngle * (isSlowMode ? mainShotAngleMultiplier : 1.0f)); bullet.MoveBulletToDirection(this, null, mainShotPoint.position, 0, new Vector2(vel.x, vel.y)); bullet = UDEBulletPool.Instance.GetBullet(mainBullet); bullet.Damage = mainSubBulletDamage; vel = UDEMath.Polar2Cartesian(arrowBulletSpeed, -mainShotAngle * (isSlowMode ? mainShotAngleMultiplier : 1.0f)); bullet.MoveBulletToDirection(this, null, mainShotPoint.position, 0, new Vector2(vel.x, vel.y)); } if (powerLevel >= 2) { bullet = UDEBulletPool.Instance.GetBullet(subBullet); bullet.Damage = subBulletDamage; var vel = UDEMath.Polar2Cartesian(arrowBulletSpeed, subWeaponShotAngle * (isSlowMode ? subWeaponShotAngleSlowMultiplier : 1.0f)); bullet.MoveBulletToDirection(this, null, subWeapons[0].position, 0, new Vector2(vel.x, vel.y)); bullet = UDEBulletPool.Instance.GetBullet(subBullet); bullet.Damage = subBulletDamage; vel = UDEMath.Polar2Cartesian(arrowBulletSpeed, subWeaponShotAngle * (isSlowMode ? subWeaponShotAngleSlowMultiplier : 1.0f) + subArrowAngle * (isSlowMode ? subArrowAngleSlowMultiplier : 1.0f)); bullet.MoveBulletToDirection(this, null, subWeapons[0].position, 0, new Vector2(vel.x, vel.y)); bullet = UDEBulletPool.Instance.GetBullet(subBullet); bullet.Damage = subBulletDamage; vel = UDEMath.Polar2Cartesian(arrowBulletSpeed, subWeaponShotAngle * (isSlowMode ? subWeaponShotAngleSlowMultiplier : 1.0f) - subArrowAngle * (isSlowMode ? subArrowAngleSlowMultiplier : 1.0f)); bullet.MoveBulletToDirection(this, null, subWeapons[0].position, 0, new Vector2(vel.x, vel.y)); bullet = UDEBulletPool.Instance.GetBullet(subBullet); bullet.Damage = subBulletDamage; vel = UDEMath.Polar2Cartesian(arrowBulletSpeed, -subWeaponShotAngle * (isSlowMode ? subWeaponShotAngleSlowMultiplier : 1.0f)); bullet.MoveBulletToDirection(this, null, subWeapons[1].position, 0, new Vector2(vel.x, vel.y)); bullet = UDEBulletPool.Instance.GetBullet(subBullet); bullet.Damage = subBulletDamage; vel = UDEMath.Polar2Cartesian(arrowBulletSpeed, -subWeaponShotAngle * (isSlowMode ? subWeaponShotAngleSlowMultiplier : 1.0f) + subArrowAngle * (isSlowMode ? subArrowAngleSlowMultiplier : 1.0f)); bullet.MoveBulletToDirection(this, null, subWeapons[1].position, 0, new Vector2(vel.x, vel.y)); bullet = UDEBulletPool.Instance.GetBullet(subBullet); bullet.Damage = subBulletDamage; vel = UDEMath.Polar2Cartesian(arrowBulletSpeed, -subWeaponShotAngle * (isSlowMode ? subWeaponShotAngleSlowMultiplier : 1.0f) - subArrowAngle * (isSlowMode ? subArrowAngleSlowMultiplier : 1.0f)); bullet.MoveBulletToDirection(this, null, subWeapons[1].position, 0, new Vector2(vel.x, vel.y)); } if (powerLevel >= 3 && shotCnt == 0) { UDEHomingBullet homingBullet = UDEBulletPool.Instance.GetBullet(subHomingBullet) as UDEHomingBullet; homingBullet.Damage = subHomingBulletDamage; homingBullet.Initialize(subWeapons[2].position, this, isSlowMode ? homingMoveSlow1 : homingMove1); homingBullet = UDEBulletPool.Instance.GetBullet(subHomingBullet) as UDEHomingBullet; homingBullet.Damage = subHomingBulletDamage; homingBullet.Initialize(subWeapons[3].position, this, isSlowMode ? homingMoveSlow2 : homingMove2); } }
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))); } }