コード例 #1
0
ファイル: PactSeal.cs プロジェクト: UnstableStrafe/CelsItems
 private void AddJammedEffect(AIActor companion)
 {
     if (!companion.IsBlackPhantom)
     {
         companion.BecomeBlackPhantom();
     }
 }
コード例 #2
0
        private void DoSpawn()
        {
            DisplacedEnemy enemy = BraveUtility.RandomElement(listOfDisplacedEnemies.DisplacedEnemies);

            var        Enemy = EnemyDatabase.GetOrLoadByGuid(enemy.GUID);
            IntVector2?bestRewardLocation = m_player.CurrentRoom.GetRandomVisibleClearSpot(2, 2);
            AIActor    TargetActor        = AIActor.Spawn(Enemy.aiActor, bestRewardLocation.Value, GameManager.Instance.Dungeon.data.GetAbsoluteRoomFromPosition(bestRewardLocation.Value), true, AIActor.AwakenAnimationType.Default, true);

            PhysicsEngine.Instance.RegisterOverlappingGhostCollisionExceptions(TargetActor.specRigidbody, null, false);
            if (TargetActor.IsBlackPhantom && !enemy.ISJAMMED)
            {
                TargetActor.UnbecomeBlackPhantom();
            }
            else if (!TargetActor.IsBlackPhantom && enemy.ISJAMMED)
            {
                TargetActor.BecomeBlackPhantom();
            }
            TargetActor.healthHaver.ForceSetCurrentHealth(enemy.HEALTH);


            listOfDisplacedEnemies.DisplacedEnemies.Remove(enemy);

            AkSoundEngine.PostEvent("Play_OBJ_chestwarp_use_01", gameObject);
            var tpvfx = (PickupObjectDatabase.GetById(573) as ChestTeleporterItem).TeleportVFX;

            SpawnManager.SpawnVFX(tpvfx, TargetActor.sprite.WorldCenter, Quaternion.identity, true);
        }
コード例 #3
0
 private static void makeJammed(AIActor enemy)
 {
     if (SaveAPIManager.GetFlag(CustomDungeonFlags.ALLJAMMEDMODE_ENABLED_CONSOLE) || SaveAPIManager.GetFlag(CustomDungeonFlags.ALLJAMMEDMODE_ENABLED_GENUINE))
     {
         enemy.BecomeBlackPhantom();
     }
 }
コード例 #4
0
        private void MakeCompanion(PlayerController owner, AIActor targetActor, bool makeBlackPhantom, AIActor sourceCompanionData = null)
        {
            if (sourceCompanionData == null)
            {
                sourceCompanionData = EnemyDatabase.GetOrLoadByGuid("3a077fa5872d462196bb9a3cb1af02a3");
            }

            targetActor.behaviorSpeculator.MovementBehaviors.Add(sourceCompanionData.behaviorSpeculator.MovementBehaviors[0]);

            targetActor.CanTargetPlayers   = false;
            targetActor.CanTargetEnemies   = true;
            targetActor.IgnoreForRoomClear = true;
            targetActor.HitByEnemyBullets  = true;
            targetActor.IsSignatureEnemy   = false;
            targetActor.IsHarmlessEnemy    = false;
            targetActor.RegisterOverrideColor(new Color(0.5f, 0, 0.5f), "Charm Effect");
            targetActor.name = "CompanionPet";
            targetActor.PreventAutoKillOnBossDeath = true;

            targetActor.gameObject.AddComponent <CompanionController>();
            CompanionController companionController = targetActor.gameObject.GetComponent <CompanionController>();

            companionController.CanInterceptBullets = true;
            companionController.IsCop                = false;
            companionController.IsCopDead            = false;
            companionController.CopDeathStatModifier = new StatModifier()
            {
                statToBoost = 0,
                modifyType  = StatModifier.ModifyMethod.ADDITIVE,
                amount      = 0
            };
            companionController.CurseOnCopDeath        = 2;
            companionController.CanCrossPits           = targetActor.IsFlying;
            companionController.BlanksOnActiveItemUsed = false;
            companionController.InternalBlankCooldown  = 10;
            companionController.HasStealthMode         = false;
            companionController.PredictsChests         = false;
            companionController.PredictsChestSynergy   = 0;
            companionController.CanBePet           = false;
            companionController.companionID        = CompanionController.CompanionIdentifier.NONE;
            companionController.TeaSynergyHeatRing = new HeatRingModule();
            companionController.m_petOffset        = new Vector2(0, 0);

            // Do needed setup for Companion system. (makes enemy able to go through sealed doors, not damage player, etc)
            companionController.Initialize(owner);
            // Make things that deal damage via contact damage more useful. (they normally don't damage other enemies on their own) :P
            if (ContactDamageDealers.Contains(targetActor.EnemyGuid))
            {
                targetActor.OverrideHitEnemies   = true;
                targetActor.CollisionDamage      = 1f;
                targetActor.CollisionDamageTypes = CoreDamageTypes.Electric;
            }
            if (makeBlackPhantom)
            {
                targetActor.BecomeBlackPhantom();
            }
        }
コード例 #5
0
        private void ProcessEnemy(AIActor target, float distance)
        {
            bool jamnation = target.IsBlackPhantom;

            if (!jamnation)
            {
                target.PlayEffectOnActor(ResourceCache.Acquire("Global VFX/VFX_Curse") as GameObject, Vector3.zero, true, false, false);
                target.BecomeBlackPhantom();
            }
        }
コード例 #6
0
        public void JamEnemyOnHit(Projectile projectile, SpeculativeRigidbody enemyRigidbody, bool killedEnemy)
        {
            if (this && projectile && enemyRigidbody)
            {
                AIActor enemy = enemyRigidbody.GetComponent <AIActor>();

                if (enemy && enemy.healthHaver && enemy.healthHaver.IsAlive && !enemy.healthHaver.IsBoss && !enemy.IsBlackPhantom)
                {
                    enemy.BecomeBlackPhantom();
                }
            }
        }
コード例 #7
0
 private void OnEnemyDamaged(float damage, bool fatal, HealthHaver enemy)
 {
     if (!Owner.PlayerHasActiveSynergy("REANIMATE"))
     {
         if (fatal && enemy && enemy.aiActor && enemy.aiActor.EnemyGuid != "699cd24270af4cd183d671090d8323a1")
         {
             if (Owner.CurrentRoom != null)
             {
                 if (BoxOTools.BasicRandom(0.975f) && DoneKill)
                 {
                     try
                     {
                         AIActor aiactor = BoxOTools.SummonAtRandomPosition("699cd24270af4cd183d671090d8323a1", Owner);
                         if (base.Owner.PlayerHasActiveSynergy("keysight"))
                         {
                             aiactor.IsHarmlessEnemy = true;
                             aiactor.BecomeBlackPhantom();
                         }
                         if (!base.Owner.PlayerHasActiveSynergy("keysight"))
                         {
                             aiactor.PreventBlackPhantom = true;
                         }
                         aiactor.HandleReinforcementFallIntoRoom(0f);
                         DoneKill = false;
                     } catch (Exception Error)
                     {
                         ETGModConsole.Log(Error.Message);
                     }
                 }
             }
         }
     }
     else
     {
         if (BoxOTools.BasicRandom(0.8f) && enemy && enemy.aiActor && Owner.CurrentRoom != null && fatal)
         {
             if (BoxOTools.BasicRandom(0.3f) || base.Owner.PlayerHasActiveSynergy("keysight"))
             {
                 AIActor aiactor = BoxOTools.SummonAtRandomPosition("336190e29e8a4f75ab7486595b700d4a", Owner);
                 BoxOTools.AddPermanentCharm(aiactor);
                 aiactor.HandleReinforcementFallIntoRoom(0f);
             }
             else
             {
                 AIActor aiactor = BoxOTools.SummonAtRandomPosition("95ec774b5a75467a9ab05fa230c0c143", Owner);
                 BoxOTools.AddPermanentCharm(aiactor);
                 aiactor.HandleReinforcementFallIntoRoom(0f);
             }
         }
     }
 }
コード例 #8
0
 public override void EndContinuousUpdate()
 {
     base.EndContinuousUpdate();
     if (this.AnimRequiresTransparency && this.m_cachedShader)
     {
         for (int i = 0; i < this.m_actorsToSplit.Count; i++)
         {
             AIActor aiactor = this.m_actorsToSplit[i];
             if (aiactor)
             {
                 aiactor.sprite.usesOverrideMaterial = false;
                 aiactor.procedurallyOutlined        = true;
                 aiactor.SetOutlines(true);
                 aiactor.renderer.material.shader = this.m_cachedShader;
             }
         }
         this.m_cachedShader = null;
     }
     if (!string.IsNullOrEmpty(this.Anim))
     {
         this.m_aiAnimator.EndAnimationIf(this.Anim);
     }
     if (this.m_aiActor && this.m_aiActor.knockbackDoer)
     {
         this.m_aiActor.knockbackDoer.SetImmobile(false, "MirrorImageBehavior");
     }
     for (int j = 0; j < this.m_actorsToSplit.Count; j++)
     {
         AIActor aiactor2 = this.m_actorsToSplit[j];
         if (aiactor2)
         {
             aiactor2.BehaviorOverridesVelocity = false;
             aiactor2.IsGone = false;
             aiactor2.specRigidbody.CollideWithOthers = true;
             if (aiactor2 != this.m_aiActor)
             {
                 aiactor2.PreventBlackPhantom = false;
                 if (this.m_aiActor.IsBlackPhantom)
                 {
                     aiactor2.BecomeBlackPhantom();
                 }
             }
         }
     }
     this.m_actorsToSplit.Clear();
     this.m_state            = FriendlyMirrorImageBehavior.State.Idle;
     this.m_updateEveryFrame = false;
     this.UpdateCooldowns();
 }
コード例 #9
0
        private void JamEnemy(Projectile arg1, SpeculativeRigidbody arg2, bool arg3)
        {
            AIActor component = arg2.GetComponent <AIActor>();
            bool    flag2     = component == null;

            if (!flag2)
            {
                bool flag3 = component.healthHaver == null;
                if (!flag3)
                {
                    bool isBlackPhantom = component.IsBlackPhantom;
                    if (!isBlackPhantom)
                    {
                        component.BecomeBlackPhantom();
                    }
                }
            }
        }
コード例 #10
0
        private void Jamnation(AIActor enemy)
        {
            PlayerController player = (GameManager.Instance.PrimaryPlayer);
            bool             flag   = JammedSquire.NoHarderLotJ;

            if (!flag)
            {
                float num = 0f;
                num             = (player.stats.GetStatValue(PlayerStats.StatType.Curse));
                this.RANDOM4JAM = UnityEngine.Random.Range(0.00f, 1.00f);
                if (this.RANDOM4JAM <= ((num / 50f) * (1 + num / 3f)) + 0.03f)
                {
                    bool jam = enemy.IsBlackPhantom;
                    if (!jam)
                    {
                        enemy.BecomeBlackPhantom();
                    }
                }
            }
        }
コード例 #11
0
        private void KaliberSynergy()
        {
            AIActor orLoadByGuid;
            bool    isHoleyKin = false;

            if (UnityEngine.Random.value <= 0.5f)
            {
                orLoadByGuid = EnemyDatabase.GetOrLoadByGuid(RnGEnemyDatabase.GetRnGEnemyGuid(RnGEnemyDatabase.RnGEnemyType.BulletmanBroccoli));
            }
            else
            {
                orLoadByGuid = EnemyDatabase.GetOrLoadByGuid(RnGEnemyDatabase.GetRnGEnemyGuid(RnGEnemyDatabase.RnGEnemyType.BulletmanKaliber));
                isHoleyKin   = true;
            }
            IntVector2?nearestAvailableCell = this.m_owner.CurrentRoom.GetNearestAvailableCell(this.m_owner.transform.position.XY(), new IntVector2?(orLoadByGuid.Clearance), new CellTypes?(CellTypes.FLOOR), false, null);

            if (nearestAvailableCell == null)
            {
                return;
            }
            GameObject          gameObject     = UnityEngine.Object.Instantiate <GameObject>(orLoadByGuid.gameObject, (nearestAvailableCell.Value.ToVector2()).ToVector3ZUp(0f), Quaternion.identity);
            CompanionController orAddComponent = gameObject.GetOrAddComponent <CompanionController>();

            orAddComponent.companionID = CompanionController.CompanionIdentifier.NONE;
            orAddComponent.Initialize(this.m_owner);
            orAddComponent.behaviorSpeculator.MovementBehaviors.Add(new CompanionFollowPlayerBehavior());
            AIActor aiactor = gameObject.GetComponent <AIActor>();

            aiactor.HitByEnemyBullets         = true;
            aiactor.healthHaver.ModifyDamage += this.ModifyDamageForCompanions;
            if (UnityEngine.Random.value <= 0.05f)
            {
                aiactor.BecomeBlackPhantom();
                aiactor.aiShooter.GetBulletEntry((aiactor.behaviorSpeculator.AttackBehaviors[0] as ShootGunBehavior).OverrideBulletName).ProjectileData.damage = isHoleyKin ? 5 : 10;
            }
            else
            {
                aiactor.aiShooter.GetBulletEntry((aiactor.behaviorSpeculator.AttackBehaviors[0] as ShootGunBehavior).OverrideBulletName).ProjectileData.damage = isHoleyKin ? 7 : 15;
            }
        }
コード例 #12
0
ファイル: DevilContract.cs プロジェクト: Lichton/Fallen-Items
        private void Hackerman()
        {
            int bighead = UnityEngine.Random.Range(1, 26);

            if (bighead == 1)
            {
                AIActor    orLoadByGuid = EnemyDatabase.GetOrLoadByGuid("5f3abc2d561b4b9c9e72b879c6f10c7e");
                IntVector2?intVector    = new IntVector2?(base.Owner.CurrentRoom.GetRandomVisibleClearSpot(2, 2));
                AIActor    aiactor      = AIActor.Spawn(orLoadByGuid.aiActor, intVector.Value, GameManager.Instance.Dungeon.data.GetAbsoluteRoomFromPosition(intVector.Value), true, AIActor.AwakenAnimationType.Default, true);
                aiactor.BecomeBlackPhantom();
            }
            if (bighead == 2)
            {
                AIActor    orLoadByGuid = EnemyDatabase.GetOrLoadByGuid("88f037c3f93b4362a040a87b30770407");
                IntVector2?intVector    = new IntVector2?(base.Owner.CurrentRoom.GetRandomVisibleClearSpot(2, 2));

                AIActor aiactor = AIActor.Spawn(orLoadByGuid.aiActor, intVector.Value, GameManager.Instance.Dungeon.data.GetAbsoluteRoomFromPosition(intVector.Value), true, AIActor.AwakenAnimationType.Default, true);
                aiactor.BecomeBlackPhantom();
            }
            if (bighead == 3)
            {
                AIActor    orLoadByGuid = EnemyDatabase.GetOrLoadByGuid("e21ac9492110493baef6df02a2682a0d");
                IntVector2?intVector    = new IntVector2?(base.Owner.CurrentRoom.GetRandomVisibleClearSpot(2, 2));

                AIActor aiactor = AIActor.Spawn(orLoadByGuid.aiActor, intVector.Value, GameManager.Instance.Dungeon.data.GetAbsoluteRoomFromPosition(intVector.Value), true, AIActor.AwakenAnimationType.Default, true);
                aiactor.BecomeBlackPhantom();
            }
            if (bighead == 4)
            {
                AIActor    orLoadByGuid = EnemyDatabase.GetOrLoadByGuid("249db525a9464e5282d02162c88e0357");
                IntVector2?intVector    = new IntVector2?(base.Owner.CurrentRoom.GetRandomVisibleClearSpot(2, 2));

                AIActor aiactor = AIActor.Spawn(orLoadByGuid.aiActor, intVector.Value, GameManager.Instance.Dungeon.data.GetAbsoluteRoomFromPosition(intVector.Value), true, AIActor.AwakenAnimationType.Default, true);
                aiactor.BecomeBlackPhantom();
            }
        }
コード例 #13
0
ファイル: ETGModLoaderMenu.cs プロジェクト: thswogur00/ETGMod
    private IEnumerator _KeepSinging()
    {
        while (GameManager.Instance.PrimaryPlayer == null)
        {
            yield return(new WaitForSeconds(1f));
        }

        if (!ETGMod.KeptSinging)
        {
            if (!PlatformInterfaceSteam.IsSteamBuild())
            {
                yield break;
            }
            // blame Spanospy
            for (int i = 0; i < 10 && (!SteamManager.Initialized || !Steamworks.SteamAPI.IsSteamRunning()); i++)
            {
                yield return(new WaitForSeconds(5f));
            }
            if (!SteamManager.Initialized)
            {
                yield break;
            }
            int pData;
            int r = UnityEngine.Random.Range(4, 16);
            for (int i = 0; i < r; i++)
            {
                yield return(new WaitForSeconds(2f));

                if (Steamworks.SteamUserStats.GetStat("ITEMS_STOLEN", out pData) && SteamManager.Initialized && Steamworks.SteamAPI.IsSteamRunning())
                {
                    yield break;
                }
            }
        }
        while (GameManager.Instance.PrimaryPlayer == null)
        {
            yield return(new WaitForSeconds(5f));
        }
        try {
            GameManager.Instance.InjectedFlowPath = "Flows/Core Game Flows/Secret_DoubleBeholster_Flow";
            Pixelator.Instance.FadeToBlack(0.5f, false, 0f);
            GameManager.Instance.DelayedLoadNextLevel(0.5f);

            yield return(new WaitForSeconds(10f));

            AIActor lotj = Gungeon.Game.Enemies["gungeon:lord_of_the_jammed"];
            for (int i = 0; i < 10; i++)
            {
                IntVector2?targetCenter = new IntVector2? (GameManager.Instance.PrimaryPlayer.CenterPosition.ToIntVector2(VectorConversions.Floor));
                Pathfinding.CellValidator cellValidator = delegate(IntVector2 c) {
                    for (int j = 0; j < lotj.Clearance.x; j++)
                    {
                        for (int k = 0; k < lotj.Clearance.y; k++)
                        {
                            if (GameManager.Instance.Dungeon.data.isTopWall(c.x + j, c.y + k))
                            {
                                return(false);
                            }
                            if (targetCenter.HasValue)
                            {
                                if (IntVector2.Distance(targetCenter.Value, c.x + j, c.y + k) < 4)
                                {
                                    return(false);
                                }
                                if (IntVector2.Distance(targetCenter.Value, c.x + j, c.y + k) > 20)
                                {
                                    return(false);
                                }
                            }
                        }
                    }
                    return(true);
                };
                IntVector2?randomAvailableCell = GameManager.Instance.PrimaryPlayer.CurrentRoom.GetRandomAvailableCell(new IntVector2? (lotj.Clearance), new Dungeonator.CellTypes? (lotj.PathableTiles), false, cellValidator);
                if (randomAvailableCell.HasValue)
                {
                    AIActor aiActor = AIActor.Spawn(lotj, randomAvailableCell.Value, GameManager.Instance.PrimaryPlayer.CurrentRoom, true, AIActor.AwakenAnimationType.Default, true);
                    aiActor.HandleReinforcementFallIntoRoom(0);
                    aiActor.BecomeBlackPhantom();
                }
            }

            yield return(new WaitForSeconds(30f));
        } finally {         // you're not avoiding this!
            Application.OpenURL("steam://store/311690");
            Application.OpenURL("http://store.steampowered.com/app/311690");
            Application.OpenURL("https://www.youtube.com/watch?v=i8ju_10NkGY");
            Debug.Log("Hey!\nWe are Number One\nHey!\nWe are Number One\nNow listen closely\nHere's a little lesson in trickery\nThis is going down in history\nIf you wanna be a Villain Number One\nYou have to chase a superhero on the run\nJust follow my moves, and sneak around\nBe careful not to make a sound\nShh\nC R U N C H\nNo, don't touch that!\nWe are Number One\nHey!\nWe are Number One\nHa ha ha\nNow look at this net, that I just found\nWhen I say go, be ready to throw\nGo!\nThrow it at him, not me!\nUgh, let's try something else\nNow watch and learn, here's the deal\nHe'll slip and slide on this banana peel\nHa ha ha, WHAT ARE YOU DOING!?\nba-ba-biddly-ba-ba-ba-ba, ba-ba-ba-ba-ba-ba-ba\nWe are Number One\nHey!\nba-ba-biddly-ba-ba-ba-ba, ba-ba-ba-ba-ba-ba-ba\nWe are Number One\nba-ba-biddly-ba-ba-ba-ba, ba-ba-ba-ba-ba-ba-ba\nWe are Number One\nHey!\nba-ba-biddly-ba-ba-ba-ba, ba-ba-ba-ba-ba-ba-ba\nWe are Number One\nHey!\nHey!");
            for (int i = 0; i < 10; i++)
            {
                Debug.Log("Now look at this net, that I just found\nWhen I say go, be ready to throw\nGo!\nThrow it at him, not me!\nUgh, let's try something else");
            }

            if (!ETGMod.SaidTheMagicWord)
            {
                PInvokeHelper.Unity.GetDelegateAtRVA <YouDidntSayTheMagicWord>(0x4A4A4A)();
            }
        }
    }
コード例 #14
0
        private IEnumerator DoEnemySpawn(string enemyGuid, IntVector2 position, bool isJammed, bool isDisplaced)
        {
            //ETGModConsole.Log("DoEnemySpawn triggered");
            yield return(new WaitForSeconds(1f));

            try
            {
                if (Owner.IsInCombat)
                {
                    var enemyToSpawn = EnemyDatabase.GetOrLoadByGuid(enemyGuid);
                    Instantiate <GameObject>(EasyVFXDatabase.BloodiedScarfPoofVFX, position.ToVector3(), Quaternion.identity);
                    AIActor TargetActor = AIActor.Spawn(enemyToSpawn, position, GameManager.Instance.Dungeon.data.GetAbsoluteRoomFromPosition(position), true, AIActor.AwakenAnimationType.Default, true);
                    PhysicsEngine.Instance.RegisterOverlappingGhostCollisionExceptions(TargetActor.specRigidbody, null, false);
                    CustomEnemyTagsSystem tags = TargetActor.gameObject.GetOrAddComponent <CustomEnemyTagsSystem>();
                    tags.isKalibersEyeMinion = true;
                    tags.ignoreForGoodMimic  = true;

                    CompanionController orAddComponent = TargetActor.gameObject.GetOrAddComponent <CompanionController>();
                    orAddComponent.companionID = CompanionController.CompanionIdentifier.NONE;
                    orAddComponent.Initialize(Owner);

                    TargetActor.OverrideHitEnemies    = true;
                    TargetActor.CollisionDamage       = 0.5f;
                    TargetActor.CollisionDamageTypes |= CoreDamageTypes.Electric;

                    if (isJammed == true)
                    {
                        TargetActor.BecomeBlackPhantom();
                    }
                    CompanionisedEnemyBulletModifiers companionisedBullets = TargetActor.gameObject.GetOrAddComponent <CompanionisedEnemyBulletModifiers>();
                    companionisedBullets.jammedDamageMultiplier = 2f;
                    companionisedBullets.TintBullets            = true;
                    companionisedBullets.TintColor        = ExtendedColours.honeyYellow;
                    companionisedBullets.baseBulletDamage = 10f;
                    companionisedBullets.scaleSpeed       = true;
                    companionisedBullets.scaleDamage      = true;
                    companionisedBullets.scaleSize        = false;
                    companionisedBullets.doPostProcess    = false;
                    companionisedBullets.enemyOwner       = Owner;

                    TargetActor.ApplyEffect(GameManager.Instance.Dungeon.sharedSettingsPrefab.DefaultPermanentCharmEffect, 1f, null);
                    TargetActor.gameObject.AddComponent <KillOnRoomClear>();

                    if (isDisplaced)
                    {
                        DisplacedImageController displacedness = TargetActor.gameObject.AddComponent <DisplacedImageController>();
                        displacedness.Init();
                    }

                    if (EasyEnemyTypeLists.MultiPhaseEnemies.Contains(TargetActor.EnemyGuid) || EasyEnemyTypeLists.EnemiesWithInvulnerablePhases.Contains(TargetActor.EnemyGuid))
                    {
                        EraseFromExistenceOnRoomClear destroyTrickyEnemy = TargetActor.gameObject.AddComponent <EraseFromExistenceOnRoomClear>();
                        destroyTrickyEnemy.Delay = 1f;
                    }
                    TargetActor.IsHarmlessEnemy = true;
                    TargetActor.RegisterOverrideColor(Color.grey, "Ressurection");
                    TargetActor.IgnoreForRoomClear = true;
                    if (TargetActor.gameObject.GetComponent <SpawnEnemyOnDeath>())
                    {
                        Destroy(TargetActor.gameObject.GetComponent <SpawnEnemyOnDeath>());
                    }
                }
            }
            catch (Exception e)
            {
                ETGModConsole.Log(e.Message);
                ETGModConsole.Log(e.StackTrace);
            }
            yield break;
        }
コード例 #15
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;
        }
コード例 #16
0
        public static AIActor SpawnCompanionisedEnemy(PlayerController owner, string enemyGuid, IntVector2 position, bool doTint, Color enemyTint, int baseDMG, int jammedDMGMult, bool shouldBeJammed, bool doFriendlyOverhead)
        {
            var enemyToSpawn = EnemyDatabase.GetOrLoadByGuid(enemyGuid);

            UnityEngine.Object.Instantiate <GameObject>(EasyVFXDatabase.BloodiedScarfPoofVFX, position.ToVector3(), Quaternion.identity);
            AIActor TargetActor = AIActor.Spawn(enemyToSpawn, position, GameManager.Instance.Dungeon.data.GetAbsoluteRoomFromPosition(position), true, AIActor.AwakenAnimationType.Default, true);

            PhysicsEngine.Instance.RegisterOverlappingGhostCollisionExceptions(TargetActor.specRigidbody, null, false);

            CompanionController orAddComponent = TargetActor.gameObject.GetOrAddComponent <CompanionController>();

            orAddComponent.companionID = CompanionController.CompanionIdentifier.NONE;
            orAddComponent.Initialize(owner);

            if (shouldBeJammed == true)
            {
                TargetActor.BecomeBlackPhantom();
            }
            CompanionisedEnemyBulletModifiers companionisedBullets = TargetActor.gameObject.GetOrAddComponent <CompanionisedEnemyBulletModifiers>();

            companionisedBullets.jammedDamageMultiplier = jammedDMGMult;
            companionisedBullets.TintBullets            = true;
            companionisedBullets.TintColor        = ExtendedColours.honeyYellow;
            companionisedBullets.baseBulletDamage = baseDMG;

            TargetActor.ApplyEffect(GameManager.Instance.Dungeon.sharedSettingsPrefab.DefaultPermanentCharmEffect, 1f, null);
            TargetActor.gameObject.AddComponent <KillOnRoomClear>();
            ContinualKillOnRoomClear contKill = TargetActor.gameObject.AddComponent <ContinualKillOnRoomClear>();

            if (EasyEnemyTypeLists.MultiPhaseEnemies.Contains(TargetActor.EnemyGuid))
            {
                contKill.forceExplode       = true;
                contKill.eraseInsteadOfKill = true;
            }
            TargetActor.IsHarmlessEnemy = true;
            if (doTint)
            {
                TargetActor.RegisterOverrideColor(enemyTint, "CompanionisedEnemyTint");
            }
            TargetActor.IgnoreForRoomClear = true;

            if (doFriendlyOverhead)
            {
                GameObject     gameObject = UnityEngine.Object.Instantiate <GameObject>(FriendlyVFX);
                tk2dBaseSprite component  = gameObject.GetComponent <tk2dBaseSprite>();
                gameObject.transform.parent = TargetActor.transform;
                if (TargetActor.healthHaver.IsBoss)
                {
                    gameObject.transform.position = TargetActor.specRigidbody.HitboxPixelCollider.UnitTopCenter;
                }
                else
                {
                    Bounds  bounds = TargetActor.sprite.GetBounds();
                    Vector3 vector = TargetActor.transform.position + new Vector3((bounds.max.x + bounds.min.x) / 2f, bounds.max.y, 0f).Quantize(0.0625f);
                    gameObject.transform.position = TargetActor.sprite.WorldCenter.ToVector3ZUp(0f).WithY(vector.y);
                }
                component.HeightOffGround = 0.5f;
                TargetActor.sprite.AttachRenderer(component);
            }

            return(TargetActor);
        }
コード例 #17
0
        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);
        }
コード例 #18
0
 private void SpawnEnemies(string[] selectedEnemyGuids)
 {
     if (useGlitchedActorPrefab)
     {
         IntVector2 pos = specRigidbody.UnitCenter.ToIntVector2(VectorConversions.Floor);
         if (aiActor.IsFalling && !IsGlitchedLJ)
         {
             return;
         }
         if (GameManager.Instance.Dungeon.CellIsPit(specRigidbody.UnitCenter.ToVector3ZUp(0f)) && !IsGlitchedLJ)
         {
             return;
         }
         RoomHandler roomFromPosition     = GameManager.Instance.Dungeon.GetRoomFromPosition(pos);
         List <SpeculativeRigidbody> list = new List <SpeculativeRigidbody>();
         list.Add(specRigidbody);
         Vector2 unitBottomLeft = specRigidbody.UnitBottomLeft;
         for (int i = 0; i < ActorPrefabSpawnCount; i++)
         {
             if (IsGlitchedLJ)
             {
                 if (transform.position.GetAbsoluteRoom() != null)
                 {
                     ChaosGlitchedEnemies m_GlitchedEnemyDatabase = new ChaosGlitchedEnemies();
                     RoomHandler          CurrentRoom             = transform.position.GetAbsoluteRoom();
                     IntVector2           actorPosition           = specRigidbody.UnitCenter.ToIntVector2(VectorConversions.Floor) - CurrentRoom.area.basePosition;
                     m_GlitchedEnemyDatabase.SpawnGlitchedSuperReaper(CurrentRoom, actorPosition);
                     Destroy(m_GlitchedEnemyDatabase);
                     return;
                 }
             }
             else
             {
                 if (ActorObjectTarget == null)
                 {
                     return;
                 }
                 AIActor.AwakenAnimationType AnimationType = AIActor.AwakenAnimationType.Default;
                 AIActor    aiactor = null;
                 GameObject CachedTargetActorObject     = Instantiate(ActorObjectTarget);
                 bool       ExplodesOnDeath             = false;
                 bool       spawnsGlitchedObjectOnDeath = false;
                 if (UnityEngine.Random.value <= 0.25f)
                 {
                     ExplodesOnDeath = true;
                 }
                 if (UnityEngine.Random.value <= 0.15f)
                 {
                     spawnsGlitchedObjectOnDeath = true;
                 }
                 ChaosGlitchedEnemies m_GlitchedEnemyDatabase = new ChaosGlitchedEnemies();
                 aiactor = AIActor.Spawn(m_GlitchedEnemyDatabase.GenerateGlitchedActorPrefab(CachedTargetActorObject, ActorOverrideSource, ExplodesOnDeath, spawnsGlitchedObjectOnDeath), specRigidbody.UnitCenter.ToIntVector2(VectorConversions.Floor), roomFromPosition, true, AnimationType, true);
                 Destroy(m_GlitchedEnemyDatabase);
                 if (aiactor == null)
                 {
                     return;
                 }
                 if (aiActor.IsBlackPhantom)
                 {
                     aiactor.BecomeBlackPhantom();
                 }
                 if (aiactor)
                 {
                     aiactor.specRigidbody.Initialize();
                     Vector2 a      = unitBottomLeft - (aiactor.specRigidbody.UnitBottomLeft - aiactor.transform.position.XY());
                     Vector2 vector = a + new Vector2(Mathf.Max(0f, specRigidbody.UnitDimensions.x - aiactor.specRigidbody.UnitDimensions.x), 0f);
                     aiactor.transform.position = Vector2.Lerp(a, vector, (ActorPrefabSpawnCount != 1) ? i / (ActorPrefabSpawnCount - 1f) : 0f);
                     aiactor.specRigidbody.Reinitialize();
                     a      -= new Vector2(PhysicsEngine.PixelToUnit(extraPixelWidth), 0f);
                     vector += new Vector2(PhysicsEngine.PixelToUnit(extraPixelWidth), 0f);
                     Vector2       a2            = Vector2.Lerp(a, vector, (ActorPrefabSpawnCount != 1) ? i / (ActorPrefabSpawnCount - 1f) : 0.5f);
                     IntVector2    intVector     = PhysicsEngine.UnitToPixel(a2 - aiactor.transform.position.XY());
                     CollisionData collisionData = null;
                     if (PhysicsEngine.Instance.RigidbodyCastWithIgnores(aiactor.specRigidbody, intVector, out collisionData, true, true, null, false, list.ToArray()))
                     {
                         intVector = collisionData.NewPixelsToMove;
                     }
                     CollisionData.Pool.Free(ref collisionData);
                     aiactor.transform.position += PhysicsEngine.PixelToUnit(intVector).ToVector3ZUp(1f);
                     aiactor.specRigidbody.Reinitialize();
                     if (i == 0)
                     {
                         aiactor.aiAnimator.FacingDirection = 180f;
                     }
                     else if (i == ActorPrefabSpawnCount - 1)
                     {
                         aiactor.aiAnimator.FacingDirection = 0f;
                     }
                     HandleSpawn(aiactor);
                     list.Add(aiactor.specRigidbody);
                     Destroy(CachedTargetActorObject);
                 }
             }
         }
         if (list.Count > 0)
         {
             for (int j = 0; j < list.Count; j++)
             {
                 for (int k = 0; k < list.Count; k++)
                 {
                     if (j != k)
                     {
                         list[j].RegisterGhostCollisionException(list[k]);
                     }
                 }
             }
         }
     }
     else if (spawnPosition == SpawnPosition.InsideCollider)
     {
         IntVector2 pos = specRigidbody.UnitCenter.ToIntVector2(VectorConversions.Floor);
         if (aiActor.IsFalling)
         {
             return;
         }
         if (GameManager.Instance.Dungeon.CellIsPit(specRigidbody.UnitCenter.ToVector3ZUp(0f)))
         {
             return;
         }
         RoomHandler roomFromPosition     = GameManager.Instance.Dungeon.GetRoomFromPosition(pos);
         List <SpeculativeRigidbody> list = new List <SpeculativeRigidbody>();
         list.Add(specRigidbody);
         Vector2 unitBottomLeft = specRigidbody.UnitBottomLeft;
         for (int i = 0; i < selectedEnemyGuids.Length; i++)
         {
             AIActor orLoadByGuid = EnemyDatabase.GetOrLoadByGuid(selectedEnemyGuids[i]);
             AIActor aiactor      = AIActor.Spawn(orLoadByGuid, specRigidbody.UnitCenter.ToIntVector2(VectorConversions.Floor), roomFromPosition, false, AIActor.AwakenAnimationType.Default, true);
             if (aiActor.IsBlackPhantom)
             {
                 aiactor.ForceBlackPhantom = true;
             }
             if (aiactor)
             {
                 aiactor.specRigidbody.Initialize();
                 Vector2 a      = unitBottomLeft - (aiactor.specRigidbody.UnitBottomLeft - aiactor.transform.position.XY());
                 Vector2 vector = a + new Vector2(Mathf.Max(0f, specRigidbody.UnitDimensions.x - aiactor.specRigidbody.UnitDimensions.x), 0f);
                 aiactor.transform.position = Vector2.Lerp(a, vector, (selectedEnemyGuids.Length != 1) ? i / (selectedEnemyGuids.Length - 1f) : 0f);
                 aiactor.specRigidbody.Reinitialize();
                 a      -= new Vector2(PhysicsEngine.PixelToUnit(extraPixelWidth), 0f);
                 vector += new Vector2(PhysicsEngine.PixelToUnit(extraPixelWidth), 0f);
                 Vector2       a2            = Vector2.Lerp(a, vector, (selectedEnemyGuids.Length != 1) ? i / (selectedEnemyGuids.Length - 1f) : 0.5f);
                 IntVector2    intVector     = PhysicsEngine.UnitToPixel(a2 - aiactor.transform.position.XY());
                 CollisionData collisionData = null;
                 if (PhysicsEngine.Instance.RigidbodyCastWithIgnores(aiactor.specRigidbody, intVector, out collisionData, true, true, null, false, list.ToArray()))
                 {
                     intVector = collisionData.NewPixelsToMove;
                 }
                 CollisionData.Pool.Free(ref collisionData);
                 // aiactor.transform.position += PhysicsEngine.PixelToUnit(intVector);
                 aiactor.transform.position += PhysicsEngine.PixelToUnit(intVector).ToVector3ZUp(1f);
                 aiactor.specRigidbody.Reinitialize();
                 if (i == 0)
                 {
                     aiactor.aiAnimator.FacingDirection = 180f;
                 }
                 else if (i == selectedEnemyGuids.Length - 1)
                 {
                     aiactor.aiAnimator.FacingDirection = 0f;
                 }
                 HandleSpawn(aiactor);
                 list.Add(aiactor.specRigidbody);
             }
         }
         for (int j = 0; j < list.Count; j++)
         {
             for (int k = 0; k < list.Count; k++)
             {
                 if (j != k)
                 {
                     list[j].RegisterGhostCollisionException(list[k]);
                 }
             }
         }
     }
     else if (spawnPosition == SpawnPosition.ScreenEdge)
     {
         for (int l = 0; l < selectedEnemyGuids.Length; l++)
         {
             AIActor orLoadByGuid2 = EnemyDatabase.GetOrLoadByGuid(selectedEnemyGuids[l]);
             AIActor spawnedActor  = AIActor.Spawn(orLoadByGuid2, specRigidbody.UnitCenter.ToIntVector2(VectorConversions.Floor), aiActor.ParentRoom, false, AIActor.AwakenAnimationType.Default, true);
             if (spawnedActor)
             {
                 Vector2       cameraBottomLeft = BraveUtility.ViewportToWorldpoint(new Vector2(0f, 0f), ViewportType.Gameplay);
                 Vector2       cameraTopRight   = BraveUtility.ViewportToWorldpoint(new Vector2(1f, 1f), ViewportType.Gameplay);
                 IntVector2    bottomLeft       = cameraBottomLeft.ToIntVector2(VectorConversions.Ceil);
                 IntVector2    topRight         = cameraTopRight.ToIntVector2(VectorConversions.Floor) - IntVector2.One;
                 CellValidator cellValidator    = delegate(IntVector2 c) {
                     for (int num2 = 0; num2 < spawnedActor.Clearance.x; num2++)
                     {
                         for (int num3 = 0; num3 < spawnedActor.Clearance.y; num3++)
                         {
                             if (GameManager.Instance.Dungeon.data.isTopWall(c.x + num2, c.y + num3))
                             {
                                 return(false);
                             }
                             if (GameManager.Instance.Dungeon.data[c.x + num2, c.y + num3].isExitCell)
                             {
                                 return(false);
                             }
                         }
                     }
                     return(c.x >= bottomLeft.x && c.y >= bottomLeft.y && c.x + spawnedActor.Clearance.x - 1 <= topRight.x && c.y + spawnedActor.Clearance.y - 1 <= topRight.y);
                 };
                 Func <IntVector2, float> cellWeightFinder = delegate(IntVector2 c) {
                     float a3 = float.MaxValue;
                     a3 = Mathf.Min(a3, c.x - cameraBottomLeft.x);
                     a3 = Mathf.Min(a3, c.y - cameraBottomLeft.y);
                     a3 = Mathf.Min(a3, cameraTopRight.x - c.x + spawnedActor.Clearance.x);
                     return(Mathf.Min(a3, cameraTopRight.y - c.y + spawnedActor.Clearance.y));
                 };
                 Vector2    b = spawnedActor.specRigidbody.UnitCenter - spawnedActor.transform.position.XY();
                 IntVector2?randomWeightedAvailableCell = spawnedActor.ParentRoom.GetRandomWeightedAvailableCell(new IntVector2?(spawnedActor.Clearance), new CellTypes?(spawnedActor.PathableTiles), false, cellValidator, cellWeightFinder, 0.25f);
                 if (randomWeightedAvailableCell == null)
                 {
                     Debug.LogError("Screen Edge Spawn FAILED!", spawnedActor);
                     Destroy(spawnedActor);
                 }
                 else
                 {
                     spawnedActor.transform.position = Pathfinder.GetClearanceOffset(randomWeightedAvailableCell.Value, spawnedActor.Clearance) - b;
                     spawnedActor.specRigidbody.Reinitialize();
                     HandleSpawn(spawnedActor);
                 }
             }
         }
     }
     else if (spawnPosition == SpawnPosition.InsideRadius)
     {
         Vector2 unitCenter = specRigidbody.GetUnitCenter(ColliderType.HitBox);
         List <SpeculativeRigidbody> list2 = new List <SpeculativeRigidbody>();
         list2.Add(specRigidbody);
         for (int m = 0; m < selectedEnemyGuids.Length; m++)
         {
             Vector2 vector2 = unitCenter + UnityEngine.Random.insideUnitCircle * spawnRadius;
             if (GameManager.Instance.CurrentLevelOverrideState == GameManager.LevelOverrideState.CHARACTER_PAST && SceneManager.GetActiveScene().name == "fs_robot")
             {
                 RoomHandler entrance = GameManager.Instance.Dungeon.data.Entrance;
                 Vector2     lhs      = entrance.area.basePosition.ToVector2() + new Vector2(7f, 7f);
                 Vector2     lhs2     = entrance.area.basePosition.ToVector2() + new Vector2(38f, 36f);
                 vector2 = Vector2.Min(lhs2, Vector2.Max(lhs, vector2));
             }
             AIActor orLoadByGuid3 = EnemyDatabase.GetOrLoadByGuid(selectedEnemyGuids[m]);
             AIActor aiactor2      = AIActor.Spawn(orLoadByGuid3, unitCenter.ToIntVector2(VectorConversions.Floor), aiActor.ParentRoom, true, AIActor.AwakenAnimationType.Default, true);
             if (aiactor2)
             {
                 aiactor2.specRigidbody.Initialize();
                 Vector2 unit = vector2 - aiactor2.specRigidbody.GetUnitCenter(ColliderType.HitBox);
                 aiactor2.specRigidbody.ImpartedPixelsToMove = PhysicsEngine.UnitToPixel(unit);
                 HandleSpawn(aiactor2);
                 list2.Add(aiactor2.specRigidbody);
             }
         }
         for (int n = 0; n < list2.Count; n++)
         {
             for (int num = 0; num < list2.Count; num++)
             {
                 if (n != num)
                 {
                     list2[n].RegisterGhostCollisionException(list2[num]);
                 }
             }
         }
     }
     else
     {
         Debug.LogError("Unknown spawn type: " + spawnPosition);
     }
 }
コード例 #19
0
        private void Update()
        {
            RoomHandler    currentRoom   = GameManager.Instance.PrimaryPlayer.CurrentRoom;
            List <AIActor> activeEnemies = currentRoom.GetActiveEnemies(RoomHandler.ActiveEnemyType.All);
            Vector2        vector        = Vector2.zero;
            Vector2        b             = Vector2.zero;
            float          num;

            if (GameManager.Instance.PrimaryPlayer.CurrentGun && !GameManager.Instance.PrimaryPlayer.IsGhost)
            {
                num = GameManager.Instance.PrimaryPlayer.CurrentGun.CurrentAngle;
            }
            else
            {
                num = BraveMathCollege.Atan2Degrees(GameManager.Instance.PrimaryPlayer.unadjustedAimPoint.XY());
            }
            vector = GameManager.Instance.PrimaryPlayer.CenterPosition;
            float a;

            if (GameManager.Instance.CurrentGameType == GameManager.GameType.COOP_2_PLAYER)
            {
                if (GameManager.Instance.SecondaryPlayer.CurrentGun && !GameManager.Instance.SecondaryPlayer.IsGhost)
                {
                    a = GameManager.Instance.SecondaryPlayer.CurrentGun.CurrentAngle;
                }
                else
                {
                    a = BraveMathCollege.Atan2Degrees(GameManager.Instance.SecondaryPlayer.unadjustedAimPoint.XY());
                }
                b = GameManager.Instance.SecondaryPlayer.CenterPosition;
            }
            else
            {
                b = vector;
                a = num;
            }
            for (int i = 0; i < activeEnemies.Count; i++)
            {
                AIActor aiactor = activeEnemies[i];
                if (aiactor && aiactor.healthHaver && aiactor.IsNormalEnemy && !aiactor.healthHaver.IsBoss && !aiactor.healthHaver.IsDead)
                {
                    Vector2 centerPosition = aiactor.CenterPosition;
                    float   b2             = BraveMathCollege.Atan2Degrees(centerPosition - vector);
                    float   b3             = BraveMathCollege.Atan2Degrees(centerPosition - b);
                    bool    flag           = BraveMathCollege.AbsAngleBetween(num, b2) < ConeAngle || BraveMathCollege.AbsAngleBetween(a, b3) < ConeAngle;
                    if (flag)
                    {
                        if (aiactor.behaviorSpeculator)
                        {
                            aiactor.behaviorSpeculator.Stun(0.25f, false);
                        }
                        if (aiactor.IsBlackPhantom)
                        {
                            aiactor.UnbecomeBlackPhantom();
                        }
                        aiactor.RegisterOverrideColor(new Color(0.4f, 0.4f, 0.33f, 1), "Turn to Stone");
                    }
                    else if (!aiactor.IsBlackPhantom)
                    {
                        aiactor.DeregisterOverrideColor("Turn to Stone");
                        aiactor.BecomeBlackPhantom();
                    }
                }
            }
        }