예제 #1
0
 private void OnPreRigidbodyCollision(SpeculativeRigidbody myRigidbody, PixelCollider myPixelCollider, SpeculativeRigidbody otherRigidbody, PixelCollider otherPixelCollider)
 {
     if (otherRigidbody.aiActor != null)
     {
         otherRigidbody.StartCoroutine(this.RigidbodyCollision(otherRigidbody));
     }
 }
 private void HandlePreCollision(SpeculativeRigidbody myRigidbody, PixelCollider myPixelCollider, SpeculativeRigidbody otherRigidbody, PixelCollider otherPixelCollider)
 {
     if (otherRigidbody && otherRigidbody.healthHaver && otherRigidbody.aiActor)
     {
         if (otherRigidbody.aiActor.IsFlying)
         {
             float originalDamage = myRigidbody.projectile.baseData.damage;
             myRigidbody.projectile.baseData.damage *= 1.4f;
             myRigidbody.StartCoroutine(this.ChangeProjectileDamage(myRigidbody.projectile, originalDamage));
         }
     }
 }
예제 #3
0
            protected override HandleDamageResult HandleDamage(SpeculativeRigidbody rigidbody, PixelCollider hitPixelCollider, out bool killedTarget, PlayerController player, bool alreadyPlayerDelayed = false)
            {
                killedTarget = false;
                if (rigidbody.ReflectProjectiles)
                {
                    return(Projectile.HandleDamageResult.NO_HEALTH);
                }
                if (!rigidbody.healthHaver)
                {
                    return(Projectile.HandleDamageResult.NO_HEALTH);
                }
                if (!alreadyPlayerDelayed && Projectile.s_delayPlayerDamage && player)
                {
                    return(Projectile.HandleDamageResult.HEALTH);
                }
                if (rigidbody.spriteAnimator != null && rigidbody.spriteAnimator.QueryInvulnerabilityFrame())
                {
                    return(Projectile.HandleDamageResult.HEALTH);
                }
                bool  flag = !rigidbody.healthHaver.IsDead;
                float num  = this.ModifiedDamage;

                if (this.Owner is AIActor && rigidbody && rigidbody.aiActor && (this.Owner as AIActor).IsNormalEnemy)
                {
                    num = ProjectileData.FixedFallbackDamageToEnemies;
                    if (rigidbody.aiActor.HitByEnemyBullets)
                    {
                        num /= 4f;
                    }
                }
                FieldInfo info = typeof(Projectile).GetField("m_healthHaverHitCount", BindingFlags.NonPublic | BindingFlags.Instance);
                int       m_healthHaverHitCount = (int)info.GetValue(this as Projectile);

                if (this.Owner is PlayerController && this.m_hasPierced && m_healthHaverHitCount >= 1)
                {
                    int num2 = Mathf.Clamp(m_healthHaverHitCount - 1, 0, GameManager.Instance.PierceDamageScaling.Length - 1);
                    num *= GameManager.Instance.PierceDamageScaling[num2];
                }
                if (this.OnWillKillEnemy != null && num >= rigidbody.healthHaver.GetCurrentHealth())
                {
                    this.OnWillKillEnemy(this, rigidbody);
                }
                if (rigidbody.healthHaver.IsBoss)
                {
                    num *= this.BossDamageMultiplier;
                }
                if (this.BlackPhantomDamageMultiplier != 1f && rigidbody.aiActor && rigidbody.aiActor.IsBlackPhantom)
                {
                    num *= this.BlackPhantomDamageMultiplier;
                }
                bool flag2 = false;

                if (this.DelayedDamageToExploders)
                {
                    flag2 = (rigidbody.GetComponent <ExplodeOnDeath>() && rigidbody.healthHaver.GetCurrentHealth() <= num);
                }
                if (!flag2)
                {
                    HealthHaver     healthHaver     = rigidbody.healthHaver;
                    float           damage          = num;
                    Vector2         velocity        = base.specRigidbody.Velocity;
                    CoreDamageTypes coreDamageTypes = this.damageTypes;
                    DamageCategory  damageCategory  = (!this.IsBlackBullet) ? DamageCategory.Normal : DamageCategory.BlackBullet;
                    if (healthHaver.IsBoss)
                    {
                        damage *= (base.Owner as PlayerController).stats.GetStatValue(PlayerStats.StatType.DamageToBosses);
                    }
                    healthHaver.ApplyDamage(damage, velocity, "Soul Orb Projectile", coreDamageTypes, damageCategory, false, hitPixelCollider, this.ignoreDamageCaps);
                    if (player && player.OnHitByProjectile != null)
                    {
                        player.OnHitByProjectile(this, player);
                    }
                }
                else
                {
                    rigidbody.StartCoroutine(this.HandleDelayedDamage(rigidbody, num, base.specRigidbody.Velocity, hitPixelCollider));
                }
                if (this.Owner && this.Owner is AIActor && player)
                {
                    (this.Owner as AIActor).HasDamagedPlayer = true;
                }
                killedTarget = (flag && rigidbody.healthHaver.IsDead);
                if (!killedTarget && rigidbody.gameActor != null)
                {
                    if (this.AppliesPoison && UnityEngine.Random.value < this.PoisonApplyChance)
                    {
                        rigidbody.gameActor.ApplyEffect(this.healthEffect, 1f, null);
                    }
                    if (this.AppliesSpeedModifier && UnityEngine.Random.value < this.SpeedApplyChance)
                    {
                        rigidbody.gameActor.ApplyEffect(this.speedEffect, 1f, null);
                    }
                    if (this.AppliesCharm && UnityEngine.Random.value < this.CharmApplyChance)
                    {
                        rigidbody.gameActor.ApplyEffect(this.charmEffect, 1f, null);
                    }
                    if (this.AppliesFreeze && UnityEngine.Random.value < this.FreezeApplyChance)
                    {
                        rigidbody.gameActor.ApplyEffect(this.freezeEffect, 1f, null);
                    }
                    if (this.AppliesCheese && UnityEngine.Random.value < this.CheeseApplyChance)
                    {
                        rigidbody.gameActor.ApplyEffect(this.cheeseEffect, 1f, null);
                    }
                    if (this.AppliesBleed && UnityEngine.Random.value < this.BleedApplyChance)
                    {
                        rigidbody.gameActor.ApplyEffect(this.bleedEffect, -1f, this);
                    }
                    if (this.AppliesFire && UnityEngine.Random.value < this.FireApplyChance)
                    {
                        rigidbody.gameActor.ApplyEffect(this.fireEffect, 1f, null);
                    }
                    if (this.AppliesStun && UnityEngine.Random.value < this.StunApplyChance && rigidbody.gameActor.behaviorSpeculator)
                    {
                        rigidbody.gameActor.behaviorSpeculator.Stun(this.AppliedStunDuration, true);
                    }
                    for (int i = 0; i < this.statusEffectsToApply.Count; i++)
                    {
                        rigidbody.gameActor.ApplyEffect(this.statusEffectsToApply[i], 1f, null);
                    }
                }
                m_healthHaverHitCount++;
                info.SetValue(this as Projectile, m_healthHaverHitCount);
                return((!killedTarget) ? Projectile.HandleDamageResult.HEALTH : Projectile.HandleDamageResult.HEALTH_AND_KILLED);
            }
        protected override HandleDamageResult HandleDamage(SpeculativeRigidbody rigidbody, PixelCollider hitPixelCollider, out bool killedTarget, PlayerController player, bool alreadyPlayerDelayed = false)
        {
            killedTarget = false;
            if (rigidbody.ReflectProjectiles)
            {
                return(HandleDamageResult.NO_HEALTH);
            }
            if (!rigidbody.healthHaver)
            {
                return(HandleDamageResult.NO_HEALTH);
            }
            if (!alreadyPlayerDelayed && s_delayPlayerDamage && player)
            {
                return(HandleDamageResult.HEALTH);
            }
            bool  flag = !rigidbody.healthHaver.IsDead;
            float num  = ModifiedDamage;

            if (Owner is AIActor && rigidbody && rigidbody.aiActor && (Owner as AIActor).IsNormalEnemy)
            {
                num = ProjectileData.FixedFallbackDamageToEnemies;
                if (rigidbody.aiActor.HitByEnemyBullets)
                {
                    num /= 4f;
                }
            }
            int healthHaverHitCount = (int)ProjectileHealthHaverHitCountInfo.GetValue(this);

            if (Owner is PlayerController && m_hasPierced && healthHaverHitCount >= 1)
            {
                int num2 = Mathf.Clamp(healthHaverHitCount - 1, 0, GameManager.Instance.PierceDamageScaling.Length - 1);
                num *= GameManager.Instance.PierceDamageScaling[num2];
            }
            if (OnWillKillEnemy != null && num >= rigidbody.healthHaver.GetCurrentHealth())
            {
                OnWillKillEnemy(this, rigidbody);
            }
            if (rigidbody.healthHaver.IsBoss)
            {
                num *= BossDamageMultiplier;
            }
            if (BlackPhantomDamageMultiplier != 1f && rigidbody.aiActor && rigidbody.aiActor.IsBlackPhantom)
            {
                num *= BlackPhantomDamageMultiplier;
            }
            bool flag2 = false;

            if (DelayedDamageToExploders)
            {
                flag2 = (rigidbody.GetComponent <ExplodeOnDeath>() && rigidbody.healthHaver.GetCurrentHealth() <= num);
            }
            if (!flag2)
            {
                HealthHaver     healthHaver     = rigidbody.healthHaver;
                float           damage          = num;
                Vector2         velocity        = specRigidbody.Velocity;
                string          ownerName       = OwnerName;
                CoreDamageTypes coreDamageTypes = damageTypes;
                DamageCategory  damageCategory  = (!IsBlackBullet) ? DamageCategory.Normal : DamageCategory.BlackBullet;
                healthHaver.ApplyDamage(damage, velocity, ownerName, coreDamageTypes, damageCategory, true, hitPixelCollider, ignoreDamageCaps);
                if (player && player.OnHitByProjectile != null)
                {
                    player.OnHitByProjectile(this, player);
                }
            }
            else
            {
                rigidbody.StartCoroutine((IEnumerator)ProjectileHandleDelayedDamageInfo.Invoke(this, new object[] { rigidbody, num, specRigidbody.Velocity, hitPixelCollider }));
            }
            if (Owner && Owner is AIActor && player)
            {
                (Owner as AIActor).HasDamagedPlayer = true;
            }
            killedTarget = (flag && rigidbody.healthHaver.IsDead);
            if (!killedTarget && rigidbody.gameActor != null)
            {
                if (AppliesPoison && UnityEngine.Random.value < PoisonApplyChance)
                {
                    rigidbody.gameActor.ApplyEffect(healthEffect, 1f, null);
                }
                if (AppliesSpeedModifier && UnityEngine.Random.value < SpeedApplyChance)
                {
                    rigidbody.gameActor.ApplyEffect(speedEffect, 1f, null);
                }
                if (AppliesCharm && UnityEngine.Random.value < CharmApplyChance)
                {
                    rigidbody.gameActor.ApplyEffect(charmEffect, 1f, null);
                }
                if (AppliesFreeze && UnityEngine.Random.value < FreezeApplyChance)
                {
                    rigidbody.gameActor.ApplyEffect(freezeEffect, 1f, null);
                }
                if (AppliesCheese && UnityEngine.Random.value < CheeseApplyChance)
                {
                    rigidbody.gameActor.ApplyEffect(cheeseEffect, 1f, null);
                }
                if (AppliesBleed && UnityEngine.Random.value < BleedApplyChance)
                {
                    rigidbody.gameActor.ApplyEffect(bleedEffect, -1f, this);
                }
                if (AppliesFire && UnityEngine.Random.value < FireApplyChance)
                {
                    rigidbody.gameActor.ApplyEffect(fireEffect, 1f, null);
                }
                if (AppliesStun && UnityEngine.Random.value < StunApplyChance && rigidbody.gameActor.behaviorSpeculator)
                {
                    rigidbody.gameActor.behaviorSpeculator.Stun(AppliedStunDuration, true);
                }
                for (int i = 0; i < statusEffectsToApply.Count; i++)
                {
                    rigidbody.gameActor.ApplyEffect(statusEffectsToApply[i], 1f, null);
                }
            }
            ProjectileHealthHaverHitCountInfo.SetValue(this, healthHaverHitCount + 1);
            return((!killedTarget) ? HandleDamageResult.HEALTH : HandleDamageResult.HEALTH_AND_KILLED);
        }