コード例 #1
0
        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();
            }
        }
コード例 #2
0
        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();
        }