public void EnemyScale(AIActor aiActor, Vector2 ScaleVector)
        {
            aiActor.transform.localScale = ScaleVector.ToVector3ZUp(1f);
            aiActor.HasShadow            = false;
            // aiActor.CorpseObject.transform.localScale = actorSize.ToVector3ZUp(1f);
            int cachedLayer        = aiActor.gameObject.layer;
            int cachedOutlineLayer = cachedLayer;

            aiActor.gameObject.layer = LayerMask.NameToLayer("Unpixelated");
            cachedOutlineLayer       = SpriteOutlineManager.ChangeOutlineLayer(aiActor.sprite, LayerMask.NameToLayer("Unpixelated"));

            if (aiActor.specRigidbody)
            {
                SpeculativeRigidbody specRigidbody = aiActor.GetComponent <SpeculativeRigidbody>();
                // if (specRigidbody == null) { return; }
                specRigidbody.transform.localScale = ScaleVector.ToVector3ZUp(1f);
                for (int i = 0; i < specRigidbody.PixelColliders.Count; i++)
                {
                    specRigidbody.PixelColliders[i].Regenerate(specRigidbody.transform, true, true);
                }
                specRigidbody.UpdateCollidersOnScale = true;
                specRigidbody.RegenerateColliders    = true;
                specRigidbody.ForceRegenerate(true, true);
                specRigidbody.RegenerateCache();
            }
            ChaosUtility.CorrectForWalls(aiActor);
            // aiActor.procedurallyOutlined = true;
            // aiActor.SetOutlines(true);
        }
예제 #2
0
        private static IEnumerator Shrimk(AIActor actor)
        {
            while (!actor.HasBeenEngaged || !actor.HasBeenAwoken)
            {
                yield return(null);
            }
            int cachedLayer = actor.gameObject.layer;

            actor.gameObject.layer = LayerMask.NameToLayer("Unpixelated");
            int cachedOutlineLayer = SpriteOutlineManager.ChangeOutlineLayer(actor.sprite, LayerMask.NameToLayer("Unpixelated"));

            actor.EnemyScale       = TargetScale;
            actor.gameObject.layer = cachedLayer;
            SpriteOutlineManager.ChangeOutlineLayer(actor.sprite, cachedOutlineLayer);
            yield break;
        }
        private IEnumerator LerpToSize(AIActor target, Vector2 targetScale)
        {
            float   elapsed            = 0f;
            Vector2 startScale         = target.EnemyScale;
            int     cachedLayer        = target.gameObject.layer;
            int     cachedOutlineLayer = cachedLayer;

            target.gameObject.layer = LayerMask.NameToLayer("Unpixelated");
            cachedOutlineLayer      = SpriteOutlineManager.ChangeOutlineLayer(target.sprite, LayerMask.NameToLayer("Unpixelated"));


            while (elapsed < 1)
            {
                elapsed          += target.LocalDeltaTime;
                target.EnemyScale = Vector2.Lerp(startScale, targetScale, elapsed / 1);
                yield return(null);
            }
        }
        private void Update()
        {
            if (!m_AIActor)
            {
                Destroy(this); return;
            }

            if (Rescale && !m_WasRescaled)
            {
                m_WasRescaled    = true;
                gameObject.layer = LayerMask.NameToLayer("Unpixelated");
                SpriteOutlineManager.ChangeOutlineLayer(sprite, gameObject.layer);
                m_AIActor.EnemyScale = new Vector2(Scale, Scale);
                sprite.UpdateZDepth();
            }

            if (HideGunsWhenNoTarget && m_AIShooter && m_AIShooter.CurrentGun)
            {
                if (!m_AIActor.TargetRigidbody && m_AIShooter.CurrentGun.renderer.enabled)
                {
                    m_AIShooter.ToggleGunAndHandRenderers(false, "Companion gun toggle for target change");
                }
                else if (m_AIActor.TargetRigidbody && !m_AIShooter.CurrentGun.renderer.enabled)
                {
                    m_AIShooter.ToggleGunAndHandRenderers(true, "Companion gun toggle for target change");
                }
            }

            if (SwapFaceTypesOnTarget && !m_AIActor.aiAnimator)
            {
                Destroy(this); return;
            }

            if (SwapFaceTypesOnTarget && m_AIActor.aiAnimator.facingType != NoTargetFaceType && !m_AIActor.TargetRigidbody)
            {
                m_AIActor.aiAnimator.facingType = NoTargetFaceType;
            }
            else if (SwapFaceTypesOnTarget && m_AIActor.aiAnimator.facingType != WithTargetFaceType && m_AIActor.TargetRigidbody)
            {
                m_AIActor.aiAnimator.facingType = WithTargetFaceType;
            }
        }
예제 #5
0
        private IEnumerator HandlePopup()
        {
            float   elapsed     = 0f;
            Vector2 startOffset = Vector2.zero;

            if (specRigidbody)
            {
                startOffset = (m_cachedPosition + m_CachedPositionOffset + new Vector2(m_ParachuteSprite.GetBounds().size.x / 2, 0));
            }
            else if (UseObjectSizeOverride)
            {
                startOffset = (m_cachedPosition + m_CachedPositionOffset + new Vector2(OverrideObjectSize.x, 0));
            }
            else
            {
                startOffset = (m_cachedPosition + m_CachedPositionOffset + new Vector2(sprite.GetBounds().size.x / 2, 0));
            }
            Vector2 HeighestPointPosition = (startOffset + new Vector2(DropHeightHorizontalOffset, PopUpHeight));
            int     cachedLayer           = gameObject.layer;
            int     cachedOutlineLayer    = cachedLayer;

            while (elapsed < PopupSpeed)
            {
                elapsed += BraveTime.DeltaTime;
                if (!StartsIntheAir)
                {
                    m_Anchor.position = Vector2.Lerp(startOffset, HeighestPointPosition, (elapsed / PopupSpeed));
                }
                SetObjectScale(Vector2.Lerp(new Vector2(m_startScale, m_startScale), m_cachedScale, (elapsed / PopupSpeed)));
                yield return(null);
            }
            gameObject.layer = cachedLayer;
            SpriteOutlineManager.ChangeOutlineLayer(sprite, cachedOutlineLayer);
            switchState = State.ParaDrop;
            yield break;
        }
예제 #6
0
        public void EXPostProcessProjectile(Projectile projectile)
        {
            if (EnemyGUIDs == null | EnemyGUIDs.Count <= 0)
            {
                return;
            }

            AIActor sourceActor = EnemyDatabase.GetOrLoadByGuid(BraveUtility.RandomElement(EnemyGUIDs));

            if (!sourceActor)
            {
                return;
            }

            float damageMod = m_baseDamageMod;

            if (projectile.sprite && projectile.sprite.renderer)
            {
                projectile.sprite.renderer.enabled = false;
            }

            if (sourceActor.EnemyGuid == "128db2f0781141bcb505d8f00f9e4d47" | sourceActor.EnemyGuid == "b54d89f9e802455cbb2b8a96a31e8259")
            {
                damageMod += 0.35f;
            }

            if (m_FiresJammedEnemies)
            {
                damageMod += 0.25f;
            }

            projectile.baseData.damage *= damageMod;

            if (sourceActor.EnemyGuid == "76bc43539fc24648bff4568c75c686d1")
            {
                projectile.baseData.damage    /= 2f;
                projectile.AppliesStun         = true;
                projectile.AppliedStunDuration = 3f;
                projectile.StunApplyChance     = 0.4f;
            }

            if (!sourceActor.gameObject.GetComponent <ExplodeOnDeath>() && sourceActor.EnemyGuid != "76bc43539fc24648bff4568c75c686d1")
            {
                projectile.baseData.force += 5;
            }

            projectile.pierceMinorBreakables = true;

            Vector3 targetPosition = projectile.transform.position;
            AIActor targetAIActor  = Instantiate(sourceActor, targetPosition, projectile.transform.rotation);

            if (projectile.Owner && projectile.Owner is PlayerController)
            {
                float ScaleMod = (projectile.Owner as PlayerController).BulletScaleModifier;
                targetAIActor.gameObject.layer = LayerMask.NameToLayer("Unpixelated");
                targetAIActor.EnemyScale       = new Vector2(ScaleMod, ScaleMod);
                SpriteOutlineManager.ChangeOutlineLayer(targetAIActor.sprite, LayerMask.NameToLayer("Unpixelated"));
                if (targetAIActor.EnemyScale != Vector2.one)
                {
                    targetAIActor.HasShadow = false;
                    Destroy(targetAIActor.ShadowObject);
                }
                ;
            }
            targetAIActor.specRigidbody.enabled = false;
            targetAIActor.IgnoreForRoomClear    = true;
            targetAIActor.IsHarmlessEnemy       = true;
            targetAIActor.CanTargetEnemies      = true;
            targetAIActor.CanTargetPlayers      = false;
            targetAIActor.procedurallyOutlined  = false;
            if (!m_FiresJammedEnemies && targetAIActor.EnemyGuid != "76bc43539fc24648bff4568c75c686d1")
            {
                if (targetAIActor.EnemyGuid == "01972dee89fc4404a5c408d50007dad5")
                {
                    targetAIActor.RegisterOverrideColor(new Color32(255, 240, 190, 220), "Pale BulletKin");
                }
                else if (targetAIActor.EnemyGuid == "4d37ce3d666b4ddda8039929225b7ede")
                {
                    targetAIActor.RegisterOverrideColor(new Color32(170, 170, 170, 190), "Pale Generic Enemy");
                }
                else
                {
                    targetAIActor.RegisterOverrideColor(new Color32(160, 160, 160, 170), "Pale Generic Enemy");
                }
            }

            if (targetAIActor.specRigidbody.GetPixelCollider(ColliderType.Ground) != null)
            {
                PixelCollider EnemyCollider   = targetAIActor.specRigidbody.GetPixelCollider(ColliderType.HitBox);
                PixelCollider NewProjCollider = ExpandUtility.DuplicatePixelCollider(EnemyCollider);
                NewProjCollider.CollisionLayer          = CollisionLayer.Projectile;
                projectile.specRigidbody.PixelColliders = new List <PixelCollider>()
                {
                    NewProjCollider
                };
                projectile.specRigidbody.Reinitialize();
            }

            targetAIActor.gameObject.transform.parent = projectile.transform;

            if (sourceActor.EnemyGuid == "01972dee89fc4404a5c408d50007dad5" | sourceActor.EnemyGuid == "4d37ce3d666b4ddda8039929225b7ede")
            {
                // targetPosition -= new Vector3(0.5f, 0.5f);
                targetAIActor.gameObject.transform.localPosition -= new Vector3(0.5f, 0.5f);
            }
            else if (sourceActor.EnemyGuid == "128db2f0781141bcb505d8f00f9e4d47" | sourceActor.EnemyGuid == "b54d89f9e802455cbb2b8a96a31e8259")
            {
                // targetPosition -= new Vector3(0.5f, 1);
                targetAIActor.gameObject.transform.localPosition -= new Vector3(0.5f, 1);
            }

            targetAIActor.sprite.UpdateZDepth();

            if (m_FiresJammedEnemies)
            {
                targetAIActor.BecomeBlackPhantom();
            }

            projectile.OnDestruction += OnDestruction;
        }
예제 #7
0
        private IEnumerator HandleShrink(AIActor target)
        {
            AkSoundEngine.PostEvent("Play_OBJ_lightning_flash_01", base.gameObject);
            float elapsed = 0f;

            if (target == null)
            {
                affectedEnemies.Remove(target);
                yield break;
            }
            Vector2 startScale         = target.EnemyScale;
            int     cachedLayer        = target.gameObject.layer;
            int     cachedOutlineLayer = cachedLayer;

            if (this.DepixelatesTargets)
            {
                target.gameObject.layer = LayerMask.NameToLayer("Unpixelated");
                cachedOutlineLayer      = SpriteOutlineManager.ChangeOutlineLayer(target.sprite, LayerMask.NameToLayer("Unpixelated"));
            }
            target.ClearPath();
            DazedBehavior db = new DazedBehavior();

            db.PointReachedPauseTime = 0.5f;
            db.PathInterval          = 0.5f;
            if (target.knockbackDoer)
            {
                target.knockbackDoer.weight /= 3f;
            }
            if (target.healthHaver)
            {
                target.healthHaver.AllDamageMultiplier *= this.DamageMultiplier;
            }
            target.behaviorSpeculator.OverrideBehaviors.Insert(0, db);
            target.behaviorSpeculator.RefreshBehaviors();
            while (elapsed < this.ShrinkTime)
            {
                if (target == null)
                {
                    affectedEnemies.Remove(target);
                    yield break;
                }
                elapsed          += target.LocalDeltaTime;
                target.EnemyScale = Vector2.Lerp(startScale, this.TargetScale, elapsed / this.ShrinkTime);
                yield return(null);
            }
            elapsed = 0f;
            while (elapsed < this.HoldTime)
            {
                this.m_activeElapsed  = elapsed;
                this.m_activeDuration = this.HoldTime;
                if (target == null)
                {
                    affectedEnemies.Remove(target);
                    yield break;
                }
                elapsed += target.LocalDeltaTime;
                yield return(null);
            }
            elapsed = 0f;
            while (elapsed < this.RegrowTime)
            {
                if (target == null)
                {
                    affectedEnemies.Remove(target);
                    yield break;
                }
                elapsed          += target.LocalDeltaTime;
                target.EnemyScale = Vector2.Lerp(this.TargetScale, startScale, elapsed / this.RegrowTime);
                yield return(null);
            }
            if (target == null)
            {
                affectedEnemies.Remove(target);
                yield break;
            }
            if (target.knockbackDoer)
            {
                target.knockbackDoer.weight *= 3f;
            }
            if (target.healthHaver)
            {
                target.healthHaver.AllDamageMultiplier /= this.DamageMultiplier;
            }
            target.behaviorSpeculator.OverrideBehaviors.Remove(db);
            target.behaviorSpeculator.RefreshBehaviors();
            if (this.DepixelatesTargets)
            {
                target.gameObject.layer = cachedLayer;
                SpriteOutlineManager.ChangeOutlineLayer(target.sprite, cachedOutlineLayer);
            }
            affectedEnemies.Remove(target);
            yield break;
        }
        public IEnumerator ResizeEnemy(AIActor target, Vector2 ScaleValue, bool onlyDoRescale = true, bool isBigEnemy = false, bool delayed = false)
        {
            if (target == null | ScaleValue == null)
            {
                yield break;
            }

            if (delayed)
            {
                yield return(new WaitForSeconds(0.8f));
            }

            HealthHaver targetHealthHaver = target.GetComponent <HealthHaver>();
            float       knockBackValue    = 2f;

            int cachedLayer        = target.gameObject.layer;
            int cachedOutlineLayer = cachedLayer;

            target.gameObject.layer = LayerMask.NameToLayer("Unpixelated");
            cachedOutlineLayer      = SpriteOutlineManager.ChangeOutlineLayer(target.sprite, LayerMask.NameToLayer("Unpixelated"));
            // target.ClearPath();
            if (!onlyDoRescale)
            {
                if (target.knockbackDoer)
                {
                    if (isBigEnemy)
                    {
                        target.knockbackDoer.weight *= knockBackValue;
                    }
                    else
                    {
                        target.knockbackDoer.weight /= knockBackValue;
                    }
                }
                if (!isBigEnemy && targetHealthHaver != null && !onlyDoRescale)
                {
                    if (!targetHealthHaver.IsBoss && !ChaosLists.DontDieOnCollisionWhenTinyGUIDList.Contains(target.EnemyGuid))
                    {
                        target.DiesOnCollison   = true;
                        target.EnemySwitchState = "Blobulin";
                    }

                    target.CollisionDamage          = 0f;
                    target.CollisionDamageTypes     = 0;
                    target.PreventFallingInPitsEver = false;
                    // target.CollisionKnockbackStrength = target.CollisionKnockbackStrength - 0.6f;
                    target.PreventBlackPhantom = true;

                    if (targetHealthHaver.IsBoss)
                    {
                        if (targetHealthHaver != null)
                        {
                            targetHealthHaver.SetHealthMaximum(targetHealthHaver.GetMaxHealth() / 1.5f, null, false);
                        }
                        // aiActor.BaseMovementSpeed *= 1.1f;
                        // aiActor.MovementSpeed *= 1.1f;
                    }
                    else if (targetHealthHaver != null && !onlyDoRescale)
                    {
                        target.BaseMovementSpeed *= 1.15f;
                        target.MovementSpeed     *= 1.15f;
                        if (targetHealthHaver != null)
                        {
                            targetHealthHaver.SetHealthMaximum(targetHealthHaver.GetMaxHealth() / 2f, null, false);
                        }
                    }
                    target.OverrideDisplayName = ("Tiny " + target.GetActorName());
                }
                else if (isBigEnemy && targetHealthHaver != null && !onlyDoRescale)
                {
                    if (!target.IsFlying && !targetHealthHaver.IsBoss && !ChaosLists.OverrideFallIntoPitsList.Contains(target.EnemyGuid))
                    {
                        target.PreventFallingInPitsEver = true;
                    }
                    if (targetHealthHaver.IsBoss)
                    {
                        targetHealthHaver.SetHealthMaximum(targetHealthHaver.GetMaxHealth() * 1.2f, null, false);
                        // aiActor.BaseMovementSpeed *= 0.8f;
                        // aiActor.MovementSpeed *= 0.8f;
                    }
                    else
                    {
                        target.BaseMovementSpeed /= 1.25f;
                        target.MovementSpeed     /= 1.25f;
                        targetHealthHaver.SetHealthMaximum(targetHealthHaver.GetMaxHealth() * 1.5f, null, false);
                    }
                    target.OverrideDisplayName = ("Big " + target.GetActorName());
                }
            }
            Vector2 startScale = target.EnemyScale;
            float   elapsed    = 0f;
            float   ShrinkTime = 0.5f;

            while (elapsed < ShrinkTime)
            {
                elapsed          += BraveTime.DeltaTime;
                target.EnemyScale = Vector2.Lerp(startScale, ScaleValue, elapsed / ShrinkTime);
                if (target.specRigidbody)
                {
                    target.specRigidbody.UpdateCollidersOnScale = true;
                    target.specRigidbody.RegenerateColliders    = true;
                }
                yield return(null);
            }
            yield return(new WaitForSeconds(1.5f));

            ChaosUtility.CorrectForWalls(target);

            /*if (target.CorpseObject != null) {
             *  target.CorpseObject.transform.localScale = ScaleValue.ToVector3ZUp(1f);
             *  int cachedCorpseLayer = target.CorpseObject.layer;
             *  int cachedCorpseOutlineLayer = cachedCorpseLayer;
             *  target.CorpseObject.layer = LayerMask.NameToLayer("CorpseUnpixelated");
             *  cachedCorpseOutlineLayer = SpriteOutlineManager.ChangeOutlineLayer(target.CorpseObject.GetComponentInChildren<tk2dBaseSprite>(), LayerMask.NameToLayer("CorpseUnpixelated"));
             * }*/
            yield break;
        }