public void SentinelTriggered(SentinelBullet sentinel, Enemy enemy) { int index = sentinel.Index; int sentinelDamage = sentinel.Damage; var triggered = GetNextTriggeredSentinel(index).GetEnumerator(); // enemy.CurrentHealth is the health after hitting the first Sentinel. int theoreticalHealth = enemy.CurrentHealth; // - sentinel.Damage; Vector2 enemyPosition = enemy.transform.position; Vector2 enemyVelocity = enemy.Velocity; while (theoreticalHealth > 0 && triggered.MoveNext()) { SentinelBullet next = triggered.Current; SentinelProjectileBullet projectile = SentinelProjectileBullet.GetProjectile(next); Vector2 projPos = projectile.transform.position; projectile.Velocity = MathUtil.VelocityVector(projPos, enemyPosition, projectile.Speed) + enemyVelocity; projectile.OnSpawn(); theoreticalHealth -= sentinelDamage; next.DeactivateSelf(); } }
private void FireSentinelForward(PlayerBullet bullet) { SentinelBullet sentinel = (SentinelBullet)bullet; SentinelProjectileBullet projectile = SentinelProjectileBullet.GetProjectile(sentinel); projectile.Velocity = new Vector2(0, projectile.Speed); projectile.OnSpawn(); // Reset Sentinel entrance animation to finish the illusion that // the Sentinel was fired and immediately respawned. sentinel.ActivateSelf(); sentinel.OnSpawn(); }
public Vector2 CalculateRepresentedVelocity(SentinelBullet sentinel) { int index = sentinel.Index; float angleOffset = index * MathUtil.Pi2f / NumSentinel; // Apply 90 degree offset to calculate correct velocity const float HardOffset = MathUtil.PiHalf; float angle = Rotation + angleOffset + HardOffset; const float Magnitude = 11f; Vector2 velocity = MathUtil.VectorAtRadianAngle(angle, Magnitude); return(velocity); }
protected sealed override void OnInit() { Instance = this; SentinelPool = PoolManager.Instance.BulletPool.GetPool <SentinelBullet>(); SentinelProjectilePool = PoolManager.Instance.BulletPool.GetPool <SentinelProjectileBullet>(); var sentinels = SentinelPool.GetMany <SentinelBullet>(NumSentinel); for (int i = 0; i < sentinels.Length; i++) { SentinelBullet sentinel = sentinels[i]; sentinel.Index = i; sentinel.DeactivateSelf(); } }