/*private IEnumerator HandleDistort(Gun gun, Material distort)
         * {
         *  float currentRadius = 0f;
         *  while (currentRadius < 1)
         *  {
         *      currentRadius += BraveTime.DeltaTime;
         *
         *      Vector2 center = gun.sprite.WorldCenter;
         *      Vector3 vector = GameManager.Instance.MainCameraController.GetComponent<Camera>().WorldToViewportPoint(center.ToVector3ZUp(0f));
         *      Vector4 vec4 = new Vector4(vector.x, vector.y, distRadius, distIntensity);
         *
         *      distort.SetVector("_WaveCenter", vec4);
         *      distort.SetFloat("_DistortProgress", currentRadius);
         *
         *      yield return null;
         *  }
         *  if (Pixelator.Instance != null && distort != null)
         *  {
         *      Pixelator.Instance.DeregisterAdditionalRenderPass(distort);
         *      UnityEngine.Object.Destroy(distort);
         *  }
         *  yield break;
         * }
         * private static float distIntensity = 0.5f;
         * private static float distRadius = 1f;*/
        protected override void Update()
        {
            if (gun.CurrentOwner && gun.GunPlayerOwner())
            {
                if (m_timer > 0)
                {
                    this.m_timer -= BraveTime.DeltaTime;
                    float num = BraveMathCollege.LinearToSmoothStepInterpolate(0f, 20f, 1f - this.m_timer / 1.5f);

                    List <AIActor> activeEnemies = gun.GunPlayerOwner().CurrentRoom.GetActiveEnemies(RoomHandler.ActiveEnemyType.All);

                    if (activeEnemies != null)
                    {
                        for (int i = 0; i < activeEnemies.Count; i++)
                        {
                            AIActor aiactor = activeEnemies[i];

                            Vector2 unitCenter = aiactor.specRigidbody.GetUnitCenter(ColliderType.HitBox);

                            float num2 = Vector2.Distance(unitCenter, lastCenter);
                            if (num2 >= this.m_prevWaveDist - 0.25f && num2 <= num + 0.25f)
                            {
                                aiactor.behaviorSpeculator.Stun(2f);
                                if ((aiactor.healthHaver && aiactor.healthHaver.GetCurrentHealthPercentage() < 0.5f) || gun.GunPlayerOwner().PlayerHasActiveSynergy("Gorgun's Gaze"))
                                {
                                    if (EasyEnemyTypeLists.VanillaShotgunKin.Contains(aiactor.EnemyGuid))
                                    {
                                        UnityEngine.Object.Instantiate <GameObject>((PickupObjectDatabase.GetById(37) as Gun).DefaultModule.chargeProjectiles[0].Projectile.hitEffects.overrideMidairDeathVFX, aiactor.specRigidbody.UnitCenter, Quaternion.identity);
                                        aiactor.EraseFromExistenceWithRewards();
                                        UnityEngine.Object.Instantiate <GameObject>(BraveUtility.RandomElement(stoneShotgunKin), aiactor.specRigidbody.UnitBottomLeft, Quaternion.identity);
                                    }
                                    else if (ValidBulletKin.Contains(aiactor.EnemyGuid))
                                    {
                                        UnityEngine.Object.Instantiate <GameObject>((PickupObjectDatabase.GetById(37) as Gun).DefaultModule.chargeProjectiles[0].Projectile.hitEffects.overrideMidairDeathVFX, aiactor.specRigidbody.UnitCenter, Quaternion.identity);
                                        aiactor.EraseFromExistenceWithRewards();
                                        UnityEngine.Object.Instantiate <GameObject>(BraveUtility.RandomElement(stoneBulletKin), aiactor.specRigidbody.UnitBottomLeft, Quaternion.identity);
                                    }
                                }
                            }
                        }
                    }
                    this.m_prevWaveDist = num;
                }
            }
            base.Update();
            if (!gun.IsReloading && hasScreamed)
            {
                hasScreamed = false;
            }
        }
 public void AIActorMods(AIActor target)
 {
     if (!target.healthHaver.IsBoss)
     {
         if (target.GetAbsoluteParentRoom().area.PrototypeRoomCategory == PrototypeDungeonRoom.RoomCategory.BOSS && (!target.IsHarmlessEnemy || target.EnemyGuid == EnemyGuidDatabase.Entries["mine_flayers_claymore"]) && target.GetAbsoluteParentRoom().IsSealed)
         {
             if (Owner.PlayerHasActiveSynergy("Frenemies"))
             {
                 target.ApplyEffect(GameManager.Instance.Dungeon.sharedSettingsPrefab.DefaultPermanentCharmEffect, 1f, null);
                 target.IsHarmlessEnemy = true;
             }
             else
             {
                 target.EraseFromExistenceWithRewards(true);
             }
             if (Owner.PlayerHasActiveSynergy("Dirty Tricks"))
             {
                 List <AIActor> activeEnemies = target.GetAbsoluteParentRoom().GetActiveEnemies(RoomHandler.ActiveEnemyType.All);
                 if (activeEnemies != null)
                 {
                     for (int i = 0; i < activeEnemies.Count; i++)
                     {
                         AIActor aiactor = activeEnemies[i];
                         if (aiactor.healthHaver.IsBoss)
                         {
                             aiactor.healthHaver.ApplyDamage(50, Vector2.zero, "Dirty Tricks", CoreDamageTypes.None, DamageCategory.Unstoppable, true, null, true);
                         }
                     }
                 }
             }
         }
     }
 }
        private IEnumerator HandleEnemyDeath(AIActor target)
        {
            target.EraseFromExistenceWithRewards(false);
            Transform  copyTransform = this.CreateEmptySprite(target);
            tk2dSprite copySprite    = copyTransform.GetComponentInChildren <tk2dSprite>();
            GameObject gameObject    = UnityEngine.Object.Instantiate <GameObject>(InfinityGuontletPassive.effect.ParticleSystemToSpawn, copySprite.WorldCenter.ToVector3ZisY(0f), Quaternion.identity);

            gameObject.transform.parent = copyTransform;
            float elapsed  = 0f;
            float duration = 2.5f;

            copySprite.renderer.material.DisableKeyword("TINTING_OFF");
            copySprite.renderer.material.EnableKeyword("TINTING_ON");
            copySprite.renderer.material.DisableKeyword("EMISSIVE_OFF");
            copySprite.renderer.material.EnableKeyword("EMISSIVE_ON");
            copySprite.renderer.material.DisableKeyword("BRIGHTNESS_CLAMP_ON");
            copySprite.renderer.material.EnableKeyword("BRIGHTNESS_CLAMP_OFF");
            copySprite.renderer.material.SetFloat("_EmissiveThresholdSensitivity", 5f);
            copySprite.renderer.material.SetFloat("_EmissiveColorPower", 1f);
            int emId = Shader.PropertyToID("_EmissivePower");

            while (elapsed < duration)
            {
                elapsed += BraveTime.DeltaTime;
                float t = elapsed / duration;
                copySprite.renderer.material.SetFloat(emId, Mathf.Lerp(1f, 10f, t));
                copySprite.renderer.material.SetFloat("_BurnAmount", t);
                copyTransform.position += Vector3.up * BraveTime.DeltaTime * 1f;
                yield return(null);
            }
            UnityEngine.Object.Destroy(copyTransform.gameObject);
            yield break;
        }
Beispiel #4
0
 private void ProcessEnemy(AIActor actor, float distance)
 {
     if (actor.healthHaver && actor.healthHaver.GetCurrentHealthPercentage() <= .1f && !actor.healthHaver.IsBoss)
     {
         GameManager.Instance.Dungeon.StartCoroutine(this.HandleEnemySuck(actor.gameObject));
         actor.healthHaver.Die(Vector2.zero);
         actor.EraseFromExistenceWithRewards();
     }
 }
Beispiel #5
0
        public void SpecialTransmogrify(AIActor InputEnemy, AIActor OutputEnemy, GameObject EffectVFX)
        {
            if (InputEnemy.IsTransmogrified && InputEnemy.ActorName == OutputEnemy.ActorName)
            {
                return;
            }
            if (InputEnemy.IsMimicEnemy || !InputEnemy.healthHaver || InputEnemy.healthHaver.IsBoss)
            {
                return;
            }
            if (InputEnemy.ParentRoom == null)
            {
                return;
            }
            Vector2 centerPosition   = InputEnemy.CenterPosition;
            float   healthPercentage = InputEnemy.healthHaver.GetCurrentHealthPercentage();

            if (EffectVFX != null)
            {
                SpawnManager.SpawnVFX(EffectVFX, centerPosition, Quaternion.identity);
            }
            AIActor aiactor = AIActor.Spawn(OutputEnemy, centerPosition.ToIntVector2(VectorConversions.Floor), InputEnemy.ParentRoom, true, AIActor.AwakenAnimationType.Default, true);

            if (aiactor)
            {
                aiactor.IsTransmogrified = true;
                float currentHealth  = aiactor.healthHaver.GetCurrentHealth();
                float modifiedHealth = currentHealth *= healthPercentage;
                aiactor.healthHaver.ForceSetCurrentHealth(modifiedHealth);
                if (aiactor.healthHaver.GetCurrentHealth() <= 0)
                {
                    aiactor.healthHaver.ApplyDamage(100000, Vector2.zero, "Demoted To Corpse");
                }
            }
            AkSoundEngine.PostEvent("Play_ENM_wizardred_appear_01", base.gameObject);

            InputEnemy.EraseFromExistenceWithRewards(false);
        }
Beispiel #6
0
            private IEnumerator HandleEnemyDeath(AIActor target)
            {
                tk2dBaseSprite sprite = Instantiate(SmiteVFX, target.CenterPosition, Quaternion.identity).GetComponent <tk2dBaseSprite>();

                sprite.HeightOffGround = 20f;
                sprite.UpdateZDepth();
                target.EraseFromExistenceWithRewards(false);
                Transform  copyTransform = this.CreateEmptySprite(target);
                tk2dSprite copySprite    = copyTransform.GetComponentInChildren <tk2dSprite>();
                GameObject gameObject    = Instantiate(Toolbox.GetGunById(519).alternateVolley.projectiles[0].projectiles[0].GetComponent <CombineEvaporateEffect>().ParticleSystemToSpawn,
                                                       copySprite.WorldCenter.ToVector3ZisY(0f), Quaternion.identity);

                gameObject.transform.parent = copyTransform;
                float elapsed  = 0f;
                float duration = 2.5f;

                copySprite.renderer.material.DisableKeyword("TINTING_OFF");
                copySprite.renderer.material.EnableKeyword("TINTING_ON");
                copySprite.renderer.material.DisableKeyword("EMISSIVE_OFF");
                copySprite.renderer.material.EnableKeyword("EMISSIVE_ON");
                copySprite.renderer.material.DisableKeyword("BRIGHTNESS_CLAMP_ON");
                copySprite.renderer.material.EnableKeyword("BRIGHTNESS_CLAMP_OFF");
                copySprite.renderer.material.SetFloat("_EmissiveThresholdSensitivity", 5f);
                copySprite.renderer.material.SetFloat("_EmissiveColorPower", 1f);
                int emId = Shader.PropertyToID("_EmissivePower");

                while (elapsed < duration)
                {
                    elapsed += BraveTime.DeltaTime;
                    float t = elapsed / duration;
                    copySprite.renderer.material.SetFloat(emId, Mathf.Lerp(1f, 10f, t));
                    copySprite.renderer.material.SetFloat("_BurnAmount", t);
                    copyTransform.position += Vector3.up * BraveTime.DeltaTime * 1f;
                    yield return(null);
                }
                Destroy(copyTransform.gameObject);
                yield break;
            }
        public static AIActor AdvancedTransmogrify(this AIActor startEnemy, AIActor EnemyPrefab, GameObject EffectVFX, string audioEvent = "Play_ENM_wizardred_appear_01", bool ignoreAlreadyTransmogged = false, bool canTransmogMimics = false, bool defuseExplosives = true, bool carryOverRewards = false, bool maintainHealthPercent = false, bool maintainsJammedState = false, bool giveIsTransmogrifiedBool = true, bool logEverything = false)
        {
            if (startEnemy == null)
            {
                Debug.LogError("Tried to transmog a null enemy!"); return(null);
            }
            if (EnemyPrefab == null)
            {
                Debug.LogError("Tried to transmog to a null prefab!"); return(startEnemy);
            }
            if (startEnemy.EnemyGuid == EnemyPrefab.EnemyGuid)
            {
                if (logEverything)
                {
                    Debug.Log($"Tried to transmog an enemy into an actor with the same guid!");
                }
                return(startEnemy);
            }
            if (ignoreAlreadyTransmogged && startEnemy.IsTransmogrified)
            {
                if (logEverything)
                {
                    Debug.Log("Tried to transmog an enemy that has already been transmogged.");
                }
                return(startEnemy);
            }
            if (!startEnemy.healthHaver || startEnemy.healthHaver.IsBoss || startEnemy.ParentRoom == null)
            {
                if (logEverything)
                {
                    Debug.Log("Either the healthhaver or parent room on the target was null, or they were a boss!");
                }
                return(startEnemy);
            }

            Vector2 centerPosition = startEnemy.CenterPosition;

            if (EffectVFX != null)
            {
                SpawnManager.SpawnVFX(EffectVFX, centerPosition, Quaternion.identity);
            }

            AIActor aiactor = AIActor.Spawn(EnemyPrefab, centerPosition.ToIntVector2(VectorConversions.Floor), startEnemy.ParentRoom, true, AIActor.AwakenAnimationType.Default, true);

            if (aiactor)
            {
                if (giveIsTransmogrifiedBool)
                {
                    aiactor.IsTransmogrified = true;
                }

                if (maintainHealthPercent)
                {
                    float healthPercent = startEnemy.healthHaver.GetCurrentHealthPercentage();
                    //ETGModConsole.Log("HP Percent: " + healthPercent);
                    float aiactorHP = aiactor.healthHaver.GetMaxHealth();
                    float resultHP  = aiactorHP * healthPercent;
                    aiactor.healthHaver.ForceSetCurrentHealth(resultHP);
                }
            }

            if (!string.IsNullOrEmpty(audioEvent))
            {
                AkSoundEngine.PostEvent(audioEvent, startEnemy.gameObject);
            }

            if (maintainsJammedState)
            {
                if (startEnemy.IsBlackPhantom && !aiactor.IsBlackPhantom)
                {
                    aiactor.BecomeBlackPhantom();
                }
                if (!startEnemy.IsBlackPhantom && aiactor.IsBlackPhantom)
                {
                    aiactor.UnbecomeBlackPhantom();
                }
            }

            if (defuseExplosives && startEnemy.GetComponent <ExplodeOnDeath>() != null)
            {
                UnityEngine.Object.Destroy(startEnemy.GetComponent <ExplodeOnDeath>());
            }

            if (carryOverRewards && aiactor)
            {
                aiactor.CanDropCurrency                = startEnemy.CanDropCurrency;
                aiactor.AssignedCurrencyToDrop         = startEnemy.AssignedCurrencyToDrop;
                aiactor.AdditionalSafeItemDrops        = startEnemy.AdditionalSafeItemDrops;
                aiactor.AdditionalSimpleItemDrops      = startEnemy.AdditionalSimpleItemDrops;
                aiactor.AdditionalSingleCoinDropChance = startEnemy.AdditionalSingleCoinDropChance;
                aiactor.CanDropDuplicateItems          = startEnemy.CanDropDuplicateItems;
                aiactor.CanDropItems              = startEnemy.CanDropItems;
                aiactor.ChanceToDropCustomChest   = startEnemy.ChanceToDropCustomChest;
                aiactor.CustomLootTableMaxDrops   = startEnemy.CustomLootTableMaxDrops;
                aiactor.CustomLootTableMinDrops   = startEnemy.CustomLootTableMinDrops;
                aiactor.CustomLootTable           = startEnemy.CustomLootTable;
                aiactor.SpawnLootAtRewardChestPos = startEnemy.SpawnLootAtRewardChestPos;
                if (startEnemy.GetComponent <KeyBulletManController>())
                {
                    KeyBulletManController controller = startEnemy.GetComponent <KeyBulletManController>();
                    int numberOfIterations            = 1;
                    if (startEnemy.IsBlackPhantom && controller.doubleForBlackPhantom)
                    {
                        numberOfIterations++;
                    }
                    for (int i = 0; i < numberOfIterations; i++)
                    {
                        GameObject objToAdd = null;
                        if (controller.lootTable)
                        {
                            objToAdd = controller.lootTable.SelectByWeight(false);
                        }
                        else if (controller.lookPickupId > -1)
                        {
                            objToAdd = PickupObjectDatabase.GetById(controller.lookPickupId).gameObject;
                        }
                        if (objToAdd != null)
                        {
                            aiactor.AdditionalSafeItemDrops.Add(objToAdd.GetComponent <PickupObject>());
                        }
                    }
                }
                startEnemy.EraseFromExistence(false);
            }
            else
            {
                startEnemy.EraseFromExistenceWithRewards(false);
            }
            return(aiactor);
        }