public static SlashData CloneSlashData(SlashData original)
        {
            SlashData newData = new SlashData();

            newData.doVFX                = original.doVFX;
            newData.VFX                  = original.VFX;
            newData.doHitVFX             = original.doHitVFX;
            newData.hitVFX               = original.hitVFX;
            newData.projInteractMode     = original.projInteractMode;
            newData.playerKnockbackForce = original.playerKnockbackForce;
            newData.enemyKnockbackForce  = original.enemyKnockbackForce;
            newData.statusEffects        = original.statusEffects;
            newData.jammedDamageMult     = original.jammedDamageMult;
            newData.bossDamageMult       = original.bossDamageMult;
            newData.doOnSlash            = original.doOnSlash;
            newData.doPostProcessSlash   = original.doPostProcessSlash;
            newData.slashRange           = original.slashRange;
            newData.slashDegrees         = original.slashDegrees;
            newData.damage               = original.damage;
            newData.damagesBreakables    = original.damagesBreakables;
            newData.soundEvent           = original.soundEvent;
            newData.OnHitTarget          = original.OnHitTarget;
            newData.OnHitBullet          = original.OnHitBullet;
            newData.OnHitMinorBreakable  = original.OnHitMinorBreakable;
            newData.OnHitMajorBreakable  = original.OnHitMajorBreakable;
            return(newData);
        }
        private IEnumerator DoSlash(float angle, float delay)
        {
            yield return(new WaitForSeconds(delay));

            if (slashParameters == null)
            {
                slashParameters = new SlashData(); ETGModConsole.Log("Made a new slashparam");
            }


            Projectile             proj    = this.m_projectile;
            List <GameActorEffect> effects = new List <GameActorEffect>();

            effects.AddRange(proj.GetFullListOfStatusEffects(true));

            SlashData instSlash = SlashData.CloneSlashData(slashParameters);

            if (SlashDamageUsesBaseProjectileDamage)
            {
                instSlash.damage              = this.m_projectile.baseData.damage;
                instSlash.bossDamageMult      = this.m_projectile.BossDamageMultiplier;
                instSlash.jammedDamageMult    = this.m_projectile.BlackPhantomDamageMultiplier;
                instSlash.enemyKnockbackForce = this.m_projectile.baseData.force;
            }
            instSlash.OnHitTarget += SlashHitTarget;

            SlashDoer.DoSwordSlash(this.m_projectile.specRigidbody.UnitCenter, (this.m_projectile.Direction.ToAngle() + angle), owner, instSlash);

            if (DestroyBaseAfterFirstSlash)
            {
                StartCoroutine(Suicide());
            }
            yield break;
        }
Exemplo n.º 3
0
        private void Slash(PlayerController player)
        {
            Vector2 vector     = player.CenterPosition;
            Vector2 normalized = (player.unadjustedAimPoint.XY() - vector).normalized;

            Vector2 dir        = (player.CenterPosition + normalized);
            float   angleToUse = player.CurrentGun.CurrentAngle;

            SlashData slashParams = new SlashData();

            slashParams.damage = 20f * player.stats.GetStatValue(PlayerStats.StatType.Damage);
            slashParams.enemyKnockbackForce = 10f * player.stats.GetStatValue(PlayerStats.StatType.KnockbackMultiplier);

            SlashDoer.DoSwordSlash(dir, angleToUse, player, slashParams, null);
        }
 public static void DoSwordSlash(
     Vector2 position,
     float angle,
     GameActor owner,
     SlashData slashParameters,
     Transform parentTransform = null)
 {
     if (slashParameters.doVFX && slashParameters.VFX != null)
     {
         slashParameters.VFX.SpawnAtPosition(position, angle, parentTransform, null, null, -0.05f);
     }
     if (!string.IsNullOrEmpty(slashParameters.soundEvent) && owner != null && owner.gameObject != null)
     {
         AkSoundEngine.PostEvent(slashParameters.soundEvent, owner.gameObject);
     }
     GameManager.Instance.StartCoroutine(HandleSlash(position, angle, owner, slashParameters));
 }
        public void PostProcess(Projectile bullet, float chanceScaler)
        {
            if (bullet && bullet.Owner && bullet.Owner is PlayerController)
            {
                float procChance = 0.35f;
                procChance *= chanceScaler;
                if (UnityEngine.Random.value <= procChance)
                {
                    SlashData slashParams = new SlashData();


                    PlayerController player = bullet.Owner as PlayerController;
                    bullet.baseData.speed *= 0.5f;
                    bullet.UpdateSpeed();
                    PierceProjModifier piercing = bullet.gameObject.GetOrAddComponent <PierceProjModifier>();
                    piercing.penetratesBreakables = true;
                    piercing.penetration         += 2;
                    ProjectileSlashingBehaviour slashing = bullet.gameObject.GetOrAddComponent <ProjectileSlashingBehaviour>();
                    slashing.DestroyBaseAfterFirstSlash = false;
                    slashing.timeBetweenSlashes         = 0.30f;
                    if (player.PlayerHasActiveSynergy("Sword Mage"))
                    {
                        slashing.timeBetweenSlashes = 0.15f;
                    }

                    slashing.SlashDamageUsesBaseProjectileDamage = true;
                    if (player.PlayerHasActiveSynergy("Sabre Throw"))
                    {
                        slashParams.projInteractMode = SlashDoer.ProjInteractMode.REFLECT;
                    }
                    if (player.PlayerHasActiveSynergy("Whirling Blade"))
                    {
                        slashing.doSpinAttack = true;
                    }
                    if (player.PlayerHasActiveSynergy("Live By The Sword"))
                    {
                        bullet.OnDestruction += this.OnDestruction;
                    }

                    slashing.slashParameters = slashParams;
                }
            }
        }
        protected override void DoEffect(PlayerController user)
        {
            SlashData KnifeSlash = new SlashData();

            KnifeSlash.damage = 30 * user.stats.GetStatValue(PlayerStats.StatType.Damage);
            KnifeSlash.enemyKnockbackForce = 10 * user.stats.GetStatValue(PlayerStats.StatType.KnockbackMultiplier);
            KnifeSlash.projInteractMode    = SlashDoer.ProjInteractMode.IGNORE;

            List <GameActorEffect> effectlist = null;

            if (user.PlayerHasActiveSynergy("1000 Degree Knife"))
            {
                effectlist = new List <GameActorEffect>(); effectlist.Add(StaticStatusEffects.hotLeadEffect);
            }
            KnifeSlash.statusEffects = effectlist;

            if (user.PlayerHasActiveSynergy("Mirror Blade"))
            {
                KnifeSlash.projInteractMode = SlashDoer.ProjInteractMode.REFLECT;
            }

            if (user.PlayerHasActiveSynergy("Tri-Tip Dagger"))
            {
                KnifeSlash.enemyKnockbackForce /= 3f;
            }
            if (user.PlayerHasActiveSynergy("Whirling Blade"))
            {
                KnifeSlash.enemyKnockbackForce = 0;
            }

            user.StartCoroutine(DoSlash(user, 0, 0, KnifeSlash));
            if (user.PlayerHasActiveSynergy("Whirling Blade"))
            {
                user.StartCoroutine(DoSlash(user, 90, 0.25f, KnifeSlash));
                user.StartCoroutine(DoSlash(user, 180, 0.5f, KnifeSlash));
                user.StartCoroutine(DoSlash(user, 270, 0.75f, KnifeSlash));
            }
        }
        private IEnumerator DoSlash(PlayerController user, float angle, float delay, SlashData slashParameters)
        {
            yield return(new WaitForSeconds(delay));

            AkSoundEngine.PostEvent("Play_WPN_blasphemy_shot_01", user.gameObject);
            Vector2 vector     = user.CenterPosition;
            Vector2 normalized = (user.unadjustedAimPoint.XY() - vector).normalized;

            normalized = normalized.Rotate(angle);
            Vector2 dir        = (user.CenterPosition + normalized * 0.75f);
            float   angleToUse = user.CurrentGun.CurrentAngle + angle;

            SlashDoer.DoSwordSlash(dir, angleToUse, user, slashParameters, user.transform);
            if (user.PlayerHasActiveSynergy("Tri-Tip Dagger"))
            {
                Vector2 normalized2 = normalized.Rotate(45);
                Vector2 dir2        = (user.CenterPosition + normalized2 * 0.75f);
                SlashDoer.DoSwordSlash(dir2, angleToUse + 45, user, slashParameters, user.transform);
                Vector2 normalized3 = normalized.Rotate(-45);
                Vector2 dir3        = (user.CenterPosition + normalized3 * 0.75f);
                SlashDoer.DoSwordSlash(dir3, angleToUse + -45, user, slashParameters, user.transform);
            }
            yield break;
        }
        private static IEnumerator HandleSlash(Vector2 position, float angle, GameActor owner, SlashData slashParameters)
        {
            int slashId = Time.frameCount;
            List <SpeculativeRigidbody> alreadyHit = new List <SpeculativeRigidbody>();

            if (slashParameters.playerKnockbackForce != 0f && owner != null)
            {
                owner.knockbackDoer.ApplyKnockback(BraveMathCollege.DegreesToVector(angle, 1f), slashParameters.playerKnockbackForce, 0.25f, false);
            }
            float ela = 0f;

            while (ela < 0.2f)
            {
                ela += BraveTime.DeltaTime;
                HandleHeroSwordSlash(alreadyHit, position, angle, slashId, owner, slashParameters);
                yield return(null);
            }
            yield break;
        }
        private static float DealSwordDamageToEnemy(GameActor owner, GameActor targetEnemy, Vector2 arcOrigin, Vector2 contact, float angle, SlashData slashParameters)
        {
            if (targetEnemy.healthHaver)
            {
                float damageToDeal = slashParameters.damage;
                if (targetEnemy.healthHaver && targetEnemy.healthHaver.IsBoss)
                {
                    damageToDeal *= slashParameters.bossDamageMult;
                }
                if ((targetEnemy is AIActor) && (targetEnemy as AIActor).IsBlackPhantom)
                {
                    damageToDeal *= slashParameters.jammedDamageMult;
                }
                DamageCategory category = DamageCategory.Normal;
                if ((owner is AIActor) && (owner as AIActor).IsBlackPhantom)
                {
                    category = DamageCategory.BlackBullet;
                }

                bool wasAlivePreviously = targetEnemy.healthHaver.IsAlive;
                //VFX
                if (slashParameters.doHitVFX && slashParameters.hitVFX != null)
                {
                    slashParameters.hitVFX.SpawnAtPosition(new Vector3(contact.x, contact.y), 0, targetEnemy.transform);
                }
                targetEnemy.healthHaver.ApplyDamage(damageToDeal, contact - arcOrigin, owner.ActorName, CoreDamageTypes.None, category, false, null, false);

                bool fatal = false;
                if (wasAlivePreviously && targetEnemy.healthHaver.IsDead)
                {
                    fatal = true;
                }

                if (slashParameters.OnHitTarget != null)
                {
                    slashParameters.OnHitTarget(targetEnemy, fatal);
                }
            }
            if (targetEnemy.knockbackDoer)
            {
                targetEnemy.knockbackDoer.ApplyKnockback(contact - arcOrigin, slashParameters.enemyKnockbackForce, false);
            }
            if (slashParameters.statusEffects != null && slashParameters.statusEffects.Count > 0)
            {
                foreach (GameActorEffect effect in slashParameters.statusEffects)
                {
                    targetEnemy.ApplyEffect(effect);
                }
            }
            return(slashParameters.damage);
        }
Exemplo n.º 10
0
        private static void DealDamageToEnemiesInArc(GameActor owner, Vector2 arcOrigin, float arcAngle, float arcRadius, SlashData slashParameters, List <SpeculativeRigidbody> alreadyHit = null)
        {
            RoomHandler roomHandler = arcOrigin.GetAbsoluteRoom();

            if (roomHandler == null)
            {
                return;
            }
            if (SlasherIsPlayerOrFriendly(owner))
            {
                List <AIActor> activeEnemies = roomHandler.GetActiveEnemies(RoomHandler.ActiveEnemyType.All);
                if (activeEnemies == null)
                {
                    return;
                }

                for (int i = 0; i < activeEnemies.Count; i++)
                {
                    AIActor aiactor = activeEnemies[i];
                    if (aiactor && aiactor.specRigidbody && aiactor.IsNormalEnemy && !aiactor.IsGone && aiactor.healthHaver)
                    {
                        if (alreadyHit == null || !alreadyHit.Contains(aiactor.specRigidbody))
                        {
                            for (int j = 0; j < aiactor.healthHaver.NumBodyRigidbodies; j++)
                            {
                                SpeculativeRigidbody bodyRigidbody       = aiactor.healthHaver.GetBodyRigidbody(j);
                                PixelCollider        hitboxPixelCollider = bodyRigidbody.HitboxPixelCollider;
                                if (hitboxPixelCollider != null)
                                {
                                    Vector2 vector = BraveMathCollege.ClosestPointOnRectangle(arcOrigin, hitboxPixelCollider.UnitBottomLeft, hitboxPixelCollider.UnitDimensions);
                                    if (ObjectWasHitBySlash(vector, arcOrigin, arcAngle, arcRadius, 90))
                                    {
                                        bool          attackIsNotBlocked = true;
                                        int           rayMask            = CollisionMask.LayerToMask(CollisionLayer.HighObstacle, CollisionLayer.BulletBlocker, CollisionLayer.BulletBreakable);
                                        RaycastResult raycastResult;
                                        if (PhysicsEngine.Instance.Raycast(arcOrigin, vector - arcOrigin, Vector2.Distance(vector, arcOrigin), out raycastResult, true, true, rayMask, null, false, null, null) && raycastResult.SpeculativeRigidbody != bodyRigidbody)
                                        {
                                            attackIsNotBlocked = false;
                                        }
                                        RaycastResult.Pool.Free(ref raycastResult);
                                        if (attackIsNotBlocked)
                                        {
                                            float damage = DealSwordDamageToEnemy(owner, aiactor, arcOrigin, vector, arcAngle, slashParameters);
                                            if (alreadyHit != null)
                                            {
                                                if (alreadyHit.Count == 0)
                                                {
                                                    StickyFrictionManager.Instance.RegisterSwordDamageStickyFriction(damage);
                                                }
                                                alreadyHit.Add(aiactor.specRigidbody);
                                            }
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                List <PlayerController> AllPlayers = new List <PlayerController>();
                if (GameManager.Instance.PrimaryPlayer)
                {
                    AllPlayers.Add(GameManager.Instance.PrimaryPlayer);
                }
                if (GameManager.Instance.SecondaryPlayer)
                {
                    AllPlayers.Add(GameManager.Instance.SecondaryPlayer);
                }
                for (int i = 0; i < AllPlayers.Count; i++)
                {
                    PlayerController player = AllPlayers[i];
                    if (player && player.specRigidbody && player.healthHaver && !player.IsGhost)
                    {
                        if (alreadyHit == null || !alreadyHit.Contains(player.specRigidbody))
                        {
                            SpeculativeRigidbody bodyRigidbody       = player.specRigidbody;
                            PixelCollider        hitboxPixelCollider = bodyRigidbody.HitboxPixelCollider;
                            if (hitboxPixelCollider != null)
                            {
                                Vector2 vector = BraveMathCollege.ClosestPointOnRectangle(arcOrigin, hitboxPixelCollider.UnitBottomLeft, hitboxPixelCollider.UnitDimensions);
                                if (ObjectWasHitBySlash(vector, arcOrigin, arcAngle, arcRadius, 90))
                                {
                                    bool          attackIsNotBlocked = true;
                                    int           rayMask            = CollisionMask.LayerToMask(CollisionLayer.HighObstacle, CollisionLayer.BulletBlocker, CollisionLayer.BulletBreakable);
                                    RaycastResult raycastResult;
                                    if (PhysicsEngine.Instance.Raycast(arcOrigin, vector - arcOrigin, Vector2.Distance(vector, arcOrigin), out raycastResult, true, true, rayMask, null, false, null, null) && raycastResult.SpeculativeRigidbody != bodyRigidbody)
                                    {
                                        attackIsNotBlocked = false;
                                    }
                                    RaycastResult.Pool.Free(ref raycastResult);
                                    if (attackIsNotBlocked)
                                    {
                                        float damage = DealSwordDamageToEnemy(owner, player, arcOrigin, vector, arcAngle, slashParameters);
                                        if (alreadyHit != null)
                                        {
                                            if (alreadyHit.Count == 0)
                                            {
                                                StickyFrictionManager.Instance.RegisterSwordDamageStickyFriction(damage);
                                            }
                                            alreadyHit.Add(player.specRigidbody);
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 11
0
        private static void HandleHeroSwordSlash(List <SpeculativeRigidbody> alreadyHit, Vector2 arcOrigin, float slashAngle, int slashId, GameActor owner, SlashData slashParameters)
        {
            float degreesOfSlash = slashParameters.slashDegrees;
            float slashRange     = slashParameters.slashRange;



            ReadOnlyCollection <Projectile> allProjectiles2 = StaticReferenceManager.AllProjectiles;

            for (int j = allProjectiles2.Count - 1; j >= 0; j--)
            {
                Projectile projectile2 = allProjectiles2[j];
                if (ProjectileIsValid(projectile2, owner))
                {
                    Vector2 projectileCenter = projectile2.sprite.WorldCenter;
                    if (ObjectWasHitBySlash(projectileCenter, arcOrigin, slashAngle, slashRange, degreesOfSlash))
                    {
                        if (slashParameters.OnHitBullet != null)
                        {
                            slashParameters.OnHitBullet(projectile2);
                        }
                        if (slashParameters.projInteractMode != ProjInteractMode.IGNORE || projectile2.collidesWithProjectiles)
                        {
                            if (slashParameters.projInteractMode == ProjInteractMode.DESTROY || slashParameters.projInteractMode == ProjInteractMode.IGNORE)
                            {
                                projectile2.DieInAir(false, true, true, true);
                            }
                            else if (slashParameters.projInteractMode == ProjInteractMode.REFLECT || slashParameters.projInteractMode == ProjInteractMode.REFLECTANDPOSTPROCESS)
                            {
                                if (projectile2.Owner != null && projectile2.LastReflectedSlashId != slashId)
                                {
                                    projectile2.ReflectBullet(true, owner, 5, (slashParameters.projInteractMode == ProjInteractMode.REFLECTANDPOSTPROCESS), 1, 5, 0, null);
                                    projectile2.LastReflectedSlashId = slashId;
                                }
                            }
                        }
                    }
                }
            }
            DealDamageToEnemiesInArc(owner, arcOrigin, slashAngle, slashRange, slashParameters, alreadyHit);

            if (slashParameters.damagesBreakables)
            {
                List <MinorBreakable> allMinorBreakables = StaticReferenceManager.AllMinorBreakables;
                for (int k = allMinorBreakables.Count - 1; k >= 0; k--)
                {
                    MinorBreakable minorBreakable = allMinorBreakables[k];
                    if (minorBreakable && minorBreakable.specRigidbody)
                    {
                        if (!minorBreakable.IsBroken && minorBreakable.sprite)
                        {
                            if (ObjectWasHitBySlash(minorBreakable.sprite.WorldCenter, arcOrigin, slashAngle, slashRange, degreesOfSlash))
                            {
                                if (slashParameters.OnHitMinorBreakable != null)
                                {
                                    slashParameters.OnHitMinorBreakable(minorBreakable);
                                }
                                minorBreakable.Break();
                            }
                        }
                    }
                }
                List <MajorBreakable> allMajorBreakables = StaticReferenceManager.AllMajorBreakables;
                for (int l = allMajorBreakables.Count - 1; l >= 0; l--)
                {
                    MajorBreakable majorBreakable = allMajorBreakables[l];
                    if (majorBreakable && majorBreakable.specRigidbody)
                    {
                        if (!alreadyHit.Contains(majorBreakable.specRigidbody))
                        {
                            if (!majorBreakable.IsSecretDoor && !majorBreakable.IsDestroyed)
                            {
                                if (ObjectWasHitBySlash(majorBreakable.specRigidbody.UnitCenter, arcOrigin, slashAngle, slashRange, degreesOfSlash))
                                {
                                    float num9 = slashParameters.damage;
                                    if (majorBreakable.healthHaver)
                                    {
                                        num9 *= 0.2f;
                                    }
                                    if (slashParameters.OnHitMajorBreakable != null)
                                    {
                                        slashParameters.OnHitMajorBreakable(majorBreakable);
                                    }
                                    majorBreakable.ApplyDamage(num9, majorBreakable.specRigidbody.UnitCenter - arcOrigin, false, false, false);
                                    alreadyHit.Add(majorBreakable.specRigidbody);
                                }
                            }
                        }
                    }
                }
            }
        }