Пример #1
0
    /*
     * initialize enemy actor with enemy param
     */
    public void Initialize(EnemyData.Param p, EnemyDatabase db, ItemDatabase itemdb)
    {
        //tk2dSpriteAnimation
        m_sprite.Library = db.GetAnimationFromName(p.graphic);

        id = p.id;
        charName = p.name;
        hp = p.hpMax;
        hpMax = p.hpMax;
        hunger = 0;
        hungerMax = 0;
        agility = (float)p.agility;
        doesGetHungry = false;
        for(int i =0; i < (int)ElementType.ET_MAX; ++i) {
            ap[i] 		= (float)p.ApMax[i];
            apMax[i] 	= (float)p.ApMax[i];
            def[i] 		= (float)p.DpMax[i];
            defMax[i] 	= (float)p.DpMax[i];
        }
        canDie = true;
        race = Race.Creature;

        level = p.level;
        exp = p.exp;
        earnExp = p.earnExp;

        attackEffect = p.attackEffect;

        // TODO: item
    }
 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)
                 {
                     RoomHandler CurrentRoom   = transform.position.GetAbsoluteRoom();
                     IntVector2  actorPosition = specRigidbody.UnitCenter.ToIntVector2(VectorConversions.Floor) - CurrentRoom.area.basePosition;
                     ExpandGlitchedEnemies.Instance.SpawnGlitchedSuperReaper(CurrentRoom, actorPosition);
                     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;
                 }
                 aiactor = AIActor.Spawn(ExpandGlitchedEnemies.Instance.GenerateGlitchedActorPrefab(CachedTargetActorObject, ActorOverrideSource, ExplodesOnDeath, spawnsGlitchedObjectOnDeath), specRigidbody.UnitCenter.ToIntVector2(VectorConversions.Floor), roomFromPosition, true, AnimationType, true);
                 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);
     }
 }
Пример #3
0
        public static void BuildCharacter(CustomCharacterData data, bool hasAltSkin, bool paradoxUsesSprites, bool removeFoyerExtras, bool hasArmourlessAnimations = false, bool usesArmourNotHealth = false, bool hasCustomPast = false, string customPast = "", int metaCost = 0, bool useGlow = false,
                                          GlowMatDoer glowVars = null, GlowMatDoer altGlowVars = null)
        {
            var basePrefab = GetPlayerPrefab(data.baseCharacter);

            if (basePrefab == null)
            {
                ToolsCharApi.PrintError("Could not find prefab for: " + data.baseCharacter.ToString());
                return;
            }

            ToolsCharApi.Print("");
            ToolsCharApi.Print("--Building Character: " + data.nameShort + "--", "0000FF");

            PlayerController playerController;
            GameObject       gameObject = GameObject.Instantiate(basePrefab);

            playerController = gameObject.GetComponent <PlayerController>();
            var customCharacter = gameObject.AddComponent <CustomCharacter>();

            customCharacter.data = data;
            data.characterID     = storedCharacters.Count;

            playerController.AllowZeroHealthState = usesArmourNotHealth;
            playerController.ForceZeroHealthState = usesArmourNotHealth;

            playerController.hasArmorlessAnimations = hasArmourlessAnimations;


            playerController.altHandName           = "hand_alt";
            playerController.SwapHandsOnAltCostume = true;


            GameObject.DontDestroyOnLoad(gameObject);

            CustomizeCharacter(playerController, data, paradoxUsesSprites);

            data.useGlow = useGlow;

            if (useGlow)
            {
                data.emissiveColor      = glowVars.emissiveColor;
                data.emissiveColorPower = glowVars.emissiveColorPower;
                data.emissivePower      = glowVars.emissivePower;
            }
            data.removeFoyerExtras = removeFoyerExtras;
            data.metaCost          = metaCost;

            if (useGlow)
            {
                var material = new Material(EnemyDatabase.GetOrLoadByName("GunNut").sprite.renderer.material);
                //var material = new Material(ShaderCache.Acquire("Brave/UnlitTintableCutoutEmissive"));
                material.DisableKeyword("BRIGHTNESS_CLAMP_ON");
                material.EnableKeyword("BRIGHTNESS_CLAMP_OFF");
                material.SetTexture("_MainTexture", material.GetTexture("_MainTex"));
                material.SetColor("_EmissiveColor", glowVars.emissiveColor);
                material.SetFloat("_EmissiveColorPower", glowVars.emissiveColorPower);
                material.SetFloat("_EmissivePower", glowVars.emissivePower);
                material.SetFloat("_EmissiveThresholdSensitivity", 0.5f);

                data.glowMaterial = material;
            }

            if (useGlow && hasAltSkin)
            {
                var material = new Material(EnemyDatabase.GetOrLoadByName("GunNut").sprite.renderer.material);
                //var material = new Material(ShaderCache.Acquire("Brave/UnlitTintableCutoutEmissive"));
                material.DisableKeyword("BRIGHTNESS_CLAMP_ON");
                material.EnableKeyword("BRIGHTNESS_CLAMP_OFF");
                material.SetTexture("_MainTexture", material.GetTexture("_MainTex"));
                material.SetColor("_EmissiveColor", altGlowVars.emissiveColor);
                material.SetFloat("_EmissiveColorPower", altGlowVars.emissiveColorPower);
                material.SetFloat("_EmissivePower", altGlowVars.emissivePower);
                material.SetFloat("_EmissiveThresholdSensitivity", 0.5f);

                data.altGlowMaterial = material;
            }

            data.normalMaterial = new Material(ShaderCache.Acquire("Brave/PlayerShader"));



            basePrefab = null;
            storedCharacters.Add(data.nameInternal.ToLower(), new Tuple <CustomCharacterData, GameObject>(data, gameObject));
            //BotsModule.Log("nameInternal: " + data.nameInternal, BotsModule.TEXT_COLOR);

            customCharacter.past    = customPast;
            customCharacter.hasPast = hasCustomPast;



            gameObject.SetActive(false);
            FakePrefab.MarkAsFakePrefab(gameObject);
        }
 public static string GetRnGEnemyGuid(RnGEnemyDatabase.RnGEnemyType type)
 {
     return(EnemyDatabase.GetOrLoadByName(type.ToString()).EnemyGuid);
 }
        // Token: 0x06000056 RID: 86 RVA: 0x00004194 File Offset: 0x00002394
        public void KnightPlacer(PlayerController owner)
        {
            try
            {
                AIActor     orLoadByGuid             = EnemyDatabase.GetOrLoadByGuid("ec8ea75b557d4e7b8ceeaacdf6f8238c");
                IntVector2  intVector                = Vector2Extensions.ToIntVector2(owner.unadjustedAimPoint, (VectorConversions)2);
                RoomHandler absoluteRoomFromPosition = GameManager.Instance.Dungeon.data.GetAbsoluteRoomFromPosition(intVector);
                bool        flag = absoluteRoomFromPosition != null && absoluteRoomFromPosition == owner.CurrentRoom && owner.IsInCombat;
                if (flag)
                {
                    AIActor aiactor = AIActor.Spawn(orLoadByGuid.aiActor, owner.CenterPosition, absoluteRoomFromPosition, true, (AIActor.AwakenAnimationType) 2, true);
                    PhysicsEngine.Instance.RegisterOverlappingGhostCollisionExceptions(aiactor.specRigidbody, null, false);
                    aiactor.CanTargetEnemies   = true;
                    aiactor.CanTargetPlayers   = false;
                    aiactor.IsHarmlessEnemy    = true;
                    aiactor.CanDropCurrency    = false;
                    aiactor.IgnoreForRoomClear = true;
                    aiactor.MovementSpeed      = 5.95f;
                    aiactor.CompanionOwner     = owner;
                    aiactor.IsBuffEnemy        = true;
                    aiactor.isPassable         = true;
                    aiactor.gameObject.AddComponent <KillOnRoomClear>();
                    aiactor.reinforceType = (AIActor.ReinforceType) 2;
                    aiactor.HandleReinforcementFallIntoRoom(0.1f);

                    aiactor.specRigidbody.AddCollisionLayerIgnoreOverride(
                        CollisionMask.LayerToMask(CollisionLayer.EnemyHitBox, CollisionLayer.EnemyCollider, CollisionLayer.PlayerHitBox,
                                                  CollisionLayer.Projectile, CollisionLayer.PlayerCollider, CollisionLayer.PlayerBlocker, CollisionLayer.BeamBlocker)
                        );
                    aiactor.specRigidbody.AddCollisionLayerIgnoreOverride(CollisionMask.LayerToMask(CollisionLayer.BulletBlocker, CollisionLayer.BulletBreakable, CollisionLayer.Trap));

                    /*
                     * aiactor.gameObject.AddComponent<CompanionController>();
                     * CompanionController component = aiactor.gameObject.GetComponent<CompanionController>();
                     * component.Initialize(owner);
                     */


                    this.nut = aiactor;
                    MindControlEffect orAddComponent = GameObjectExtensions.GetOrAddComponent <MindControlEffect>(aiactor.gameObject);
                    orAddComponent.owner = (this.gun.CurrentOwner as PlayerController);
                    if (aiactor.healthHaver != null)
                    {
                        aiactor.healthHaver.PreventAllDamage = true;
                    }
                    if (aiactor.bulletBank != null)
                    {
                        AIBulletBank bulletBank = aiactor.bulletBank;
                        bulletBank.OnProjectileCreated = (Action <Projectile>)Delegate.Combine(bulletBank.OnProjectileCreated, new Action <Projectile>(this.OnPostProcessProjectile));
                    }
                    if (aiactor.aiShooter != null)
                    {
                        AIShooter aiShooter = aiactor.aiShooter;
                        aiShooter.PostProcessProjectile = (Action <Projectile>)Delegate.Combine(aiShooter.PostProcessProjectile, new Action <Projectile>(this.OnPostProcessProjectile));
                    }
                    aiactor.LocalTimeScale = 3;
                }
            }
            catch (Exception e)
            {
                Tools.Print("Copper KnightPlacer", "FFFFFF", true);
                Tools.PrintException(e);
            }
        }
Пример #6
0
    void OnEnable()
    {
        _target = (EnemyDatabase) target;

        if (_target.enemies == null)
        {
            Debug.Log("Creating new enemy list");
            _target.enemies = new List<CharacterData>();
        }

        foldoutStatus = new List<bool>();
        for (int i = 0; i < _target.enemies.Count; i++)
            foldoutStatus.Add(false);
    }
Пример #7
0
        private void OnKill(Projectile arg1, SpeculativeRigidbody arg2)
        {
            PlayerController player = this.gun.CurrentOwner as PlayerController;
            bool             flag   = !arg2.aiActor.healthHaver.IsDead;

            if (flag)
            {
                AssetBundle assetBundle1 = ResourceManager.LoadAssetBundle("shared_auto_001");
                this.Nuke = assetBundle1.LoadAsset <GameObject>("assets/data/vfx prefabs/vfx_explosion_firework.prefab");
                GameObject gameObject1 = UnityEngine.Object.Instantiate <GameObject>(this.Nuke);
                gameObject1.GetComponent <tk2dBaseSprite>().PlaceAtLocalPositionByAnchor(arg2.specRigidbody.UnitCenter, tk2dBaseSprite.Anchor.LowerCenter);
                gameObject1.transform.position = gameObject.transform.position.Quantize(0.0625f);
                gameObject1.GetComponent <tk2dBaseSprite>().UpdateZDepth();
                this.random = UnityEngine.Random.Range(0.0f, 1.0f);
                if (random <= 0.33f)
                {
                    AkSoundEngine.PostEvent("Play_BOSS_doormimic_flame_01", base.gameObject);
                    AIActor orLoadByGuid = EnemyDatabase.GetOrLoadByGuid(GunSoulBlue.guid1);
                    Vector3 vector       = arg2.transform.position;
                    bool    flag9        = GameManager.Instance.CurrentLevelOverrideState == GameManager.LevelOverrideState.FOYER;
                    bool    flag10       = flag9;
                    bool    flag11       = flag10;
                    bool    flag12       = flag11;
                    if (flag12)
                    {
                        vector += new Vector3(1.125f, -0.3125f, 0f);
                    }
                    GameObject          gameObject     = UnityEngine.Object.Instantiate <GameObject>(orLoadByGuid.gameObject, vector, Quaternion.identity);
                    CompanionController orAddComponent = gameObject.GetOrAddComponent <CompanionController>();
                    this.companionsSpawned.Add(orAddComponent);
                    orAddComponent.Initialize(player);
                    bool flag13 = orAddComponent.specRigidbody;
                    bool flag14 = flag13;
                    bool flag15 = flag14;
                    bool flag16 = flag15;
                    if (flag16)
                    {
                        PhysicsEngine.Instance.RegisterOverlappingGhostCollisionExceptions(orAddComponent.specRigidbody, null, false);
                    }
                }
                else
                {
                    int  num3  = UnityEngine.Random.Range(0, 4);
                    bool flag3 = num3 == 0;
                    if (flag3)
                    {
                        AkSoundEngine.PostEvent("Play_BOSS_doormimic_flame_01", base.gameObject);
                        AIActor orLoadByGuid = EnemyDatabase.GetOrLoadByGuid(GunSoulGreen.guid2);
                        Vector3 vector       = arg2.transform.position;
                        bool    flag9        = GameManager.Instance.CurrentLevelOverrideState == GameManager.LevelOverrideState.FOYER;
                        bool    flag10       = flag9;
                        bool    flag11       = flag10;
                        bool    flag12       = flag11;
                        if (flag12)
                        {
                            vector += new Vector3(1.125f, -0.3125f, 0f);
                        }
                        GameObject          gameObject     = UnityEngine.Object.Instantiate <GameObject>(orLoadByGuid.gameObject, vector, Quaternion.identity);
                        CompanionController orAddComponent = gameObject.GetOrAddComponent <CompanionController>();
                        this.companionsSpawned.Add(orAddComponent);
                        orAddComponent.Initialize(player);
                        bool flag13 = orAddComponent.specRigidbody;
                        bool flag14 = flag13;
                        bool flag15 = flag14;
                        bool flag16 = flag15;
                        if (flag16)
                        {
                            PhysicsEngine.Instance.RegisterOverlappingGhostCollisionExceptions(orAddComponent.specRigidbody, null, false);
                        }
                    }
                    bool flag4 = num3 == 1;
                    if (flag4)
                    {
                        AkSoundEngine.PostEvent("Play_BOSS_doormimic_flame_01", base.gameObject);
                        AIActor orLoadByGuid = EnemyDatabase.GetOrLoadByGuid(GunSoulRed.guid3);
                        Vector3 vector       = arg2.transform.position;
                        bool    flag9        = GameManager.Instance.CurrentLevelOverrideState == GameManager.LevelOverrideState.FOYER;
                        bool    flag10       = flag9;
                        bool    flag11       = flag10;
                        bool    flag12       = flag11;
                        if (flag12)
                        {
                            vector += new Vector3(1.125f, -0.3125f, 0f);
                        }
                        GameObject          gameObject     = UnityEngine.Object.Instantiate <GameObject>(orLoadByGuid.gameObject, vector, Quaternion.identity);
                        CompanionController orAddComponent = gameObject.GetOrAddComponent <CompanionController>();
                        this.companionsSpawned.Add(orAddComponent);
                        orAddComponent.Initialize(player);
                        bool flag13 = orAddComponent.specRigidbody;
                        bool flag14 = flag13;
                        bool flag15 = flag14;
                        bool flag16 = flag15;
                        if (flag16)
                        {
                            PhysicsEngine.Instance.RegisterOverlappingGhostCollisionExceptions(orAddComponent.specRigidbody, null, false);
                        }
                    }
                    bool flag5 = num3 == 2;
                    if (flag5)
                    {
                        AkSoundEngine.PostEvent("Play_BOSS_doormimic_flame_01", base.gameObject);
                        AIActor orLoadByGuid = EnemyDatabase.GetOrLoadByGuid(GunSoulYellow.guid4);
                        Vector3 vector       = arg2.transform.position;
                        bool    flag9        = GameManager.Instance.CurrentLevelOverrideState == GameManager.LevelOverrideState.FOYER;
                        bool    flag10       = flag9;
                        bool    flag11       = flag10;
                        bool    flag12       = flag11;
                        if (flag12)
                        {
                            vector += new Vector3(1.125f, -0.3125f, 0f);
                        }
                        GameObject          gameObject     = UnityEngine.Object.Instantiate <GameObject>(orLoadByGuid.gameObject, vector, Quaternion.identity);
                        CompanionController orAddComponent = gameObject.GetOrAddComponent <CompanionController>();
                        this.companionsSpawned.Add(orAddComponent);
                        orAddComponent.Initialize(player);
                        bool flag13 = orAddComponent.specRigidbody;
                        bool flag14 = flag13;
                        bool flag15 = flag14;
                        bool flag16 = flag15;
                        if (flag16)
                        {
                            PhysicsEngine.Instance.RegisterOverlappingGhostCollisionExceptions(orAddComponent.specRigidbody, null, false);
                        }
                    }
                    bool flag6a = num3 == 3;
                    if (flag6a)
                    {
                        AkSoundEngine.PostEvent("Play_BOSS_doormimic_flame_01", base.gameObject);
                        AIActor orLoadByGuid = EnemyDatabase.GetOrLoadByGuid(GunSoulPink.guid5);
                        Vector3 vector       = arg2.transform.position;
                        bool    flag9        = GameManager.Instance.CurrentLevelOverrideState == GameManager.LevelOverrideState.FOYER;
                        bool    flag10       = flag9;
                        bool    flag11       = flag10;
                        bool    flag12       = flag11;
                        if (flag12)
                        {
                            vector += new Vector3(1.125f, -0.3125f, 0f);
                        }
                        GameObject          gameObject     = UnityEngine.Object.Instantiate <GameObject>(orLoadByGuid.gameObject, vector, Quaternion.identity);
                        CompanionController orAddComponent = gameObject.GetOrAddComponent <CompanionController>();
                        this.companionsSpawned.Add(orAddComponent);
                        orAddComponent.Initialize(player);
                        bool flag13 = orAddComponent.specRigidbody;
                        bool flag14 = flag13;
                        bool flag15 = flag14;
                        bool flag16 = flag15;
                        if (flag16)
                        {
                            PhysicsEngine.Instance.RegisterOverlappingGhostCollisionExceptions(orAddComponent.specRigidbody, null, false);
                        }
                    }
                }
            }
        }
Пример #8
0
    void InventoryDraw()
    {
        Inventory inventory = null;

        if (GameStateMachine.currentGameMode == GameStateMachine.GameMode.singlePlayer)
        {
            if (GameStateMachine.currentGameState == GameStateMachine.State.playerTurn)
            {
                inventory = PlayerDatabase.getSelected().GetComponent <Inventory>();
            }
            else if (GameStateMachine.currentGameState == GameStateMachine.State.enemyTurn)
            {
                if (EnemyDatabase.getSelected() != null)
                {
                    inventory = EnemyDatabase.getSelected().GetComponent <Inventory>();
                }
            }
        }
        if (GameStateMachine.currentGameMode == GameStateMachine.GameMode.multiPlayer)
        {
            if (GameStateMachine.currentMPGameState == GameStateMachine.MPState.player1Turn)
            {
                inventory = PlayerDatabase.getPlayer1Selected().GetComponent <Inventory>();
            }
            else if (GameStateMachine.currentMPGameState == GameStateMachine.MPState.player2Turn)
            {
                inventory = PlayerDatabase.getPlayer2Selected().GetComponent <Inventory>();
            }
        }

        if (inventory != null)
        {
            int a = 0;
            for (int i = 0; i < 5; i++)
            {
                if (inventory.inventory[i].currDurability == 0)
                {
                    inventory.inventory[i] = new Item();
                }
                //rect (x pos, y pos, x size, y size)

                Rect slotRect      = new Rect(Screen.width * 0.8625f, i * Screen.height * 0.080f + Screen.height * 0.022f, Screen.width * 0.125f, Screen.height * 0.078f);
                Rect highLightRect = new Rect(Screen.width * 0.8615f, i * Screen.height * 0.080f + Screen.height * 0.0205f, Screen.width * 0.127f, Screen.height * 0.082f);
                Rect iconRect      = new Rect(Screen.width * 0.868f, i * Screen.height * 0.080f + Screen.height * 0.033f, Screen.width * 0.028f, Screen.width * 0.028f);
                Rect duraRect      = new Rect(Screen.width * 0.92f, i * Screen.height * 0.080f + Screen.height * 0.065f, Screen.width * 0.125f, Screen.height * 0.078f);
                Rect TextRect      = new Rect(Screen.width * 0.9f, i * Screen.height * 0.080f + Screen.height * 0.038f, 160, 50);
                Rect equippedRect  = new Rect(Screen.width * 0.9f, i * Screen.height * 0.080f + Screen.height * 0.060f, Screen.width * 0.125f, Screen.height * 0.078f);
                GUI.skin.label.normal.textColor = Color.black;
                GUI.skin.label.fontSize         = (int)(Screen.width * 0.013);

                if (GameStateMachine.currentGameMode == GameStateMachine.GameMode.singlePlayer || GameStateMachine.currentGameMode == GameStateMachine.GameMode.multiPlayer)
                {
                    if (GameStateMachine.currentGameState == GameStateMachine.State.playerTurn ||
                        GameStateMachine.currentMPGameState == GameStateMachine.MPState.player1Turn ||
                        GameStateMachine.currentMPGameState == GameStateMachine.MPState.player2Turn)
                    {
                        if (i == inventory.highlightedItem)
                        {
                            GUI.DrawTexture(highLightRect, Resources.Load <Texture2D>("SelectionBack"));
                        }
                    }
                }
                GUI.Box(slotRect, "", skin.GetStyle("Slot"));
                GUI.Label(TextRect, inventory.inventory[i].itemName);

                inventory.slots [a] = inventory.inventory [a];
                if (inventory.slots [i].itemIcon != null)
                {
                    GUI.DrawTexture(iconRect, inventory.inventory [i].itemIcon);
                    if (GameStateMachine.currentGameMode == GameStateMachine.GameMode.singlePlayer)
                    {
                        if (GameStateMachine.currentGameState == GameStateMachine.State.playerTurn)
                        {
                            if (slotRect.Contains(Event.current.mousePosition))
                            {
                                inventory.highlightedItem = i;
                                if (Event.current.button == 0 && Event.current.type == EventType.mouseDrag && !draggingItem)
                                {
                                    draggingItem             = true;
                                    inventory.isBeingDragged = true;
                                    prevIndex              = i;
                                    draggedItem            = inventory.slots[i];
                                    inventory.inventory[i] = new Item();
                                }
                                if (Event.current.type == EventType.mouseUp && draggingItem)
                                {
                                    if (prevIndex == inventory.equippedIndex)
                                    {
                                        inventory.equippedIndex = i;
                                    }
                                    inventory.inventory[prevIndex] = inventory.inventory[i];
                                    inventory.inventory [i]        = draggedItem;
                                    inventory.isBeingDragged       = false;
                                    draggingItem = false;
                                    draggedItem  = null;
                                }
                                if (Event.current.button == 1 && Event.current.type == EventType.mouseUp)
                                {
                                    if (inventory.inventory[i].itemType == Item.ItemType.Weapon)
                                    {
                                        inventory.equippedIndex = i;
                                    }
                                    else if (inventory.inventory[i].itemType == Item.ItemType.Consumable)
                                    {
                                        inventory.UseItem(inventory.inventory[i].itemID);
                                        inventory.inventory[i] = new Item();
                                    }
                                }
                            }
                            else if (Event.current.type == EventType.mouseUp && draggingItem && i == 4)
                            {
                                inventory.inventory[prevIndex] = draggedItem;
                                inventory.isBeingDragged       = false;
                                draggingItem = false;
                                draggedItem  = null;
                            }
                        }
                    }
                }
                else
                {
                    if (slotRect.Contains(Event.current.mousePosition))
                    {
                        if (Event.current.type == EventType.mouseUp && draggingItem)
                        {
                            if (prevIndex == inventory.equippedIndex)
                            {
                                inventory.equippedIndex = i;
                            }
                            inventory.inventory [i]  = draggedItem;
                            inventory.isBeingDragged = false;
                            draggingItem             = false;
                            draggedItem = null;
                        }
                    }
                    else if (Event.current.type == EventType.mouseUp && draggingItem && i == 4)
                    {
                        inventory.inventory[prevIndex] = draggedItem;
                        inventory.isBeingDragged       = false;
                        draggingItem = false;
                        draggedItem  = null;
                    }
                }
                GUI.skin.label.normal.textColor = Color.white;
                GUI.skin.label.fontSize         = (int)(Screen.width * 0.009);

                if (inventory.inventory [i].maxDurability != -1)
                {
                    GUI.Label(duraRect, inventory.inventory [i].currDurability.ToString() + "/" + inventory.inventory [i].maxDurability.ToString());

                    if (inventory.inventory[i] == inventory.currentEquipped)
                    {
                        GUI.skin.label.fontSize = (int)(Screen.width * 0.012);
                        GUI.Label(equippedRect, "E");
                    }
                }

                a++;
            }
        }
    }
Пример #9
0
        public static void BuildPrefab()
        {
            if (prefab == null || !EnemyBuilder.Dictionary.ContainsKey(guid))
            {
                //Sets up the prefab of the enemy. The spritepath, "CakeMod/Resources/Lovebulon/Idle/milton_idle_001", determines the setup sprite for your enemy. vvvv This bool right here determines whether or not an enemy has an AiShooter or not. AIShooters are necessary if you want your enemy to hold a gun for example. An example of this can be seen in Humphrey.
                prefab = EnemyBuilder.BuildPrefab("Lovebulon", guid, "CakeMod/Resources/Lovebulon/Idle/lovebulon_idle_001", new IntVector2(0, 0), new IntVector2(0, 0), false);
                //This line extends a BraveBehavior called EnemyBehavior, this is a generic behavior I use for setting up things that can't be setup in BuildPrefab.
                var enemy = prefab.AddComponent <EnemyBehavior>();
                //Here you can setup various things like movement speed, weight, and health. There's a lot you can do with the AiActor parameter so feel free to experiment.
                enemy.aiActor.MovementSpeed        = 6.7f;
                enemy.aiActor.knockbackDoer.weight = 100;
                enemy.aiActor.IgnoreForRoomClear   = false;
                enemy.aiActor.CollisionDamage      = 10f;
                enemy.aiActor.healthHaver.ForceSetCurrentHealth(15f);
                enemy.aiActor.healthHaver.SetHealthMaximum(15f, null, false);


                //This is where you setup your animations. Most animations need specific frame names to be recognized like idle or die.
                //The AddAnimation lines gets sprites from the folder specified in second phrase of the this line. At the very least you need an animation that contains the word idle for the idle animations for example.
                //AnimationType determines what kind of animation your making. In Gungeon there are 7 different Animation Types: Move, Idle, Fidget, Flight, Hit, Talk, Other. For a majority of these animations, these play automatically, however specific animations need to be told when to play such as Attack.
                //DirectionType determines the amount of ways an animation can face. You'll have to change your animation names to correspond with the DirectionType. For example if you want an animation to face eight ways you'll have to name your animations something like ""attack_south_west", "attack_north_east",  "attack_east", "attack_south_east",  "attack_north",  "attack_south", "attack_west", "attack_north_west" and change DirectionType to  DirectionType.EightWayOrdinal.
                //I suggest looking at the sprites of base game enemies to determine the names for the different directions.
                prefab.AddAnimation("idle_left", "CakeMod/Resources/Lovebulon/Idle", fps: 7, AnimationType.Idle, DirectionType.TwoWayHorizontal);
                prefab.AddAnimation("idle_right", "CakeMod/Resources/Lovebulon/Idle", fps: 7, AnimationType.Idle, DirectionType.TwoWayHorizontal);
                prefab.AddAnimation("run_left", "CakeMod/Resources/Lovebulon/Run", fps: 7, AnimationType.Move, DirectionType.TwoWayHorizontal);
                prefab.AddAnimation("run_right", "CakeMod/Resources/Lovebulon/Run", fps: 7, AnimationType.Move, DirectionType.TwoWayHorizontal);
                prefab.AddAnimation("pitfall", "CakeMod/Resources/Lovebulon/Fall", fps: 7, AnimationType.Idle, DirectionType.TwoWayHorizontal, tk2dSpriteAnimationClip.WrapMode.Once);
                //Note that the "die" and "attack" animations are only set to Move because they will be overwritten later.
                //tk2dSpriteAnimationClip.WrapMode.Once determines how an animation plays out. If you don't want it to loop, leave it to Once, otherwise you can change it to Loop or something.
                //Assign animation well assigns an animation to an animation type. By default this is on, but since we're overwritting this set this to false.
                prefab.AddAnimation("attack_left", "CakeMod/Resources/Lovebulon/Attack", fps: 8, AnimationType.Move, DirectionType.TwoWayHorizontal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false);
                prefab.AddAnimation("attack_right", "CakeMod/Resources/Lovebulon/Attack", fps: 8, AnimationType.Move, DirectionType.TwoWayHorizontal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false);
                prefab.AddAnimation("die_left", "CakeMod/Resources/Lovebulon/Die", fps: 12, AnimationType.Move, DirectionType.TwoWayHorizontal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false);
                prefab.AddAnimation("die_right", "CakeMod/Resources/Lovebulon/Die", fps: 12, AnimationType.Move, DirectionType.TwoWayHorizontal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false);
                //Here we create a new DirectionalAnimation for our enemy to pull from.
                //Make sure the AnimNames correspong to the AddAnimation names.
                DirectionalAnimation attack = new DirectionalAnimation()
                {
                    AnimNames = new string[] { "attack_right", "attack_left" },
                    Flipped   = new FlipType[] { FlipType.None, FlipType.None },
                    Type      = DirectionType.TwoWayHorizontal,
                    Prefix    = string.Empty
                };
                DirectionalAnimation die = new DirectionalAnimation()
                {
                    AnimNames = new string[] { "die_right", "die_left" },
                    Flipped   = new FlipType[] { FlipType.None, FlipType.None },
                    Type      = DirectionType.TwoWayHorizontal,
                    Prefix    = string.Empty
                };
                //Because Dodge Roll is Dodge Roll and there is no animation types for attack and death, we have to assign them to the Other category.
                enemy.aiAnimator.AssignDirectionalAnimation("attack", attack, AnimationType.Other);
                enemy.aiAnimator.AssignDirectionalAnimation("die", die, AnimationType.Other);
                //This is where we get into the meat and potatoes of our enemy. This is where all the behaviors of our enemy are made.
                //This shootpoint block of code determines where our bullets will orginate from. In this case, the center of the enemy.
                shootpoint = new GameObject("lovebuloncenter");
                shootpoint.transform.parent   = enemy.transform;
                shootpoint.transform.position = enemy.sprite.WorldCenter;
                GameObject position = enemy.transform.Find("lovebuloncenter").gameObject;
                //this line adds a BehaviorSpeculator to our enemy which is the base for adding behaviors on to.
                var bs = prefab.GetComponent <BehaviorSpeculator>();
                //Here we will add some basic behaviors such as TargetPlayerBehavior and SeekTargetBehavior.
                //You can change many things in these behaviors so feel free to go nuts.
                enemy.aiActor.specRigidbody.PixelColliders.Clear();
                enemy.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyCollider,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 11,
                    ManualHeight           = 9,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0
                });
                enemy.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyHitBox,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 11,
                    ManualHeight           = 9,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0
                });
                BehaviorSpeculator BEHAVIORIAL = EnemyDatabase.GetOrLoadByGuid("42be66373a3d4d89b91a35c9ff8adfec").behaviorSpeculator;
                BehaviorSpeculator spec        = enemy.behaviorSpeculator;
                spec.OverrideBehaviors = BEHAVIORIAL.OverrideBehaviors;
                spec.OtherBehaviors    = BEHAVIORIAL.OtherBehaviors;
                spec.TargetBehaviors   = BEHAVIORIAL.TargetBehaviors;

                spec.AttackBehaviors                 = BEHAVIORIAL.AttackBehaviors;
                spec.MovementBehaviors               = BEHAVIORIAL.MovementBehaviors;
                spec.InstantFirstTick                = BEHAVIORIAL.InstantFirstTick;
                spec.TickInterval                    = BEHAVIORIAL.TickInterval;
                spec.PostAwakenDelay                 = BEHAVIORIAL.PostAwakenDelay;
                spec.RemoveDelayOnReinforce          = BEHAVIORIAL.RemoveDelayOnReinforce;
                spec.OverrideStartingFacingDirection = BEHAVIORIAL.OverrideStartingFacingDirection;
                spec.StartingFacingDirection         = BEHAVIORIAL.StartingFacingDirection;
                spec.SkipTimingDifferentiator        = BEHAVIORIAL.SkipTimingDifferentiator;
                //Now this is one of the most important behaviors because it allows our enemy to shoot.
                bs.AttackBehaviors = new List <AttackBehaviorBase>()
                {
                    new ShootBehavior()
                    {
                        ShootPoint = position,
                        //This line selects our Bullet Script
                        BulletScript        = new CustomBulletScriptSelector(typeof(MiltonScript)),
                        LeadAmount          = 0f,
                        AttackCooldown      = 4f,
                        FireAnimation       = "attack",
                        RequiresLineOfSight = true,
                        Uninterruptible     = false,
                    }
                };
                bs.MovementBehaviors = new List <MovementBehaviorBase>
                {
                    new SeekTargetBehavior
                    {
                        StopWhenInRange     = false,
                        CustomRange         = 15f,
                        LineOfSight         = false,
                        ReturnToSpawn       = false,
                        SpawnTetherDistance = 0f,
                        PathInterval        = 0.5f,
                        SpecifyRange        = false,
                        MinActiveRange      = 0f,
                        MaxActiveRange      = 0f
                    }
                };
                //Adds the enemy to MTG spawn pool and spawn command
                Game.Enemies.Add("cak:lovebulon", enemy.aiActor);
            }
        }
Пример #10
0
        public static void BuildPrefab()
        {
            // source = EnemyDatabase.GetOrLoadByGuid("c50a862d19fc4d30baeba54795e8cb93");
            bool flag  = prefab != null || BossBuilder.Dictionary.ContainsKey(guid);
            bool flag2 = flag;

            if (!flag2)
            {
                prefab = BossBuilder.BuildPrefab("Kill Shrine", guid, spritePaths[0], new IntVector2(0, 0), new IntVector2(8, 9), false, true);
                var companion = prefab.AddComponent <EnemyBehavior23>();

                companion.aiActor.knockbackDoer.weight         = 200;
                companion.aiActor.MovementSpeed                = 6f;
                companion.aiActor.healthHaver.PreventAllDamage = false;
                companion.aiActor.CollisionDamage              = 1f;
                companion.aiActor.HasShadow                        = true;
                companion.aiActor.IgnoreForRoomClear               = false;
                companion.aiActor.aiAnimator.HitReactChance        = 0.05f;
                companion.aiActor.specRigidbody.CollideWithOthers  = true;
                companion.aiActor.specRigidbody.CollideWithTileMap = true;
                companion.aiActor.PreventFallingInPitsEver         = true;
                companion.aiActor.healthHaver.ForceSetCurrentHealth(500f);
                companion.aiActor.healthHaver.SetHealthMaximum(500f);
                companion.aiActor.CollisionKnockbackStrength = 5f;
                companion.aiActor.procedurallyOutlined       = true;
                companion.aiActor.CanTargetPlayers           = true;

                ItemsMod.Strings.Enemies.Set("#KILLSHRINE", "Sepulchergiest");
                ItemsMod.Strings.Enemies.Set("#????", "???");
                ItemsMod.Strings.Enemies.Set("#KILLSHRINESUBTITLE", "KILL SHRINE");
                ItemsMod.Strings.Enemies.Set("#KILLSHRINEQUOTE", "THE SHRINING");
                companion.aiActor.healthHaver.overrideBossName = "#KILLSHRINE";
                companion.aiActor.OverrideDisplayName          = "#KILLSHRINE";
                companion.aiActor.ActorName = "#KILLSHRINE";
                companion.aiActor.name      = "#KILLSHRINE";
                companion.aiActor.SetIsFlying(true, "Flying Enemy", true, true);

                prefab.name = companion.aiActor.OverrideDisplayName;

                GenericIntroDoer miniBossIntroDoer = prefab.AddComponent <GenericIntroDoer>();
                miniBossIntroDoer.triggerType  = GenericIntroDoer.TriggerType.PlayerEnteredRoom;
                miniBossIntroDoer.initialDelay = 0.15f;

                miniBossIntroDoer.cameraMoveSpeed        = 14;
                miniBossIntroDoer.specifyIntroAiAnimator = null;
                miniBossIntroDoer.BossMusicEvent         = "Play_MUS_Boss_Theme_Beholster";
                companion.aiActor.ShadowObject           = EnemyDatabase.GetOrLoadByGuid("c00390483f394a849c36143eb878998f").ShadowObject;
                companion.aiActor.HasShadow        = true;
                miniBossIntroDoer.PreventBossMusic = false;

                miniBossIntroDoer.InvisibleBeforeIntroAnim = false;
                miniBossIntroDoer.preIntroAnim             = string.Empty;
                miniBossIntroDoer.preIntroDirectionalAnim  = string.Empty;
                miniBossIntroDoer.introAnim                  = "intro";
                miniBossIntroDoer.introDirectionalAnim       = string.Empty;
                miniBossIntroDoer.continueAnimDuringOutro    = false;
                miniBossIntroDoer.cameraFocus                = null;
                miniBossIntroDoer.roomPositionCameraFocus    = Vector2.zero;
                miniBossIntroDoer.restrictPlayerMotionToRoom = false;
                miniBossIntroDoer.fusebombLock               = false;
                miniBossIntroDoer.AdditionalHeightOffset     = 0;
                miniBossIntroDoer.portraitSlideSettings      = new PortraitSlideSettings()
                {
                    bossNameString          = "#KILLSHRINE",
                    bossSubtitleString      = "#KILLSHRINESUBTITLE",
                    bossQuoteString         = "#KILLSHRINEQUOTE",
                    bossSpritePxOffset      = IntVector2.Zero,
                    topLeftTextPxOffset     = IntVector2.Zero,
                    bottomRightTextPxOffset = IntVector2.Zero,
                    bgColor = Color.cyan
                };
                miniBossIntroDoer.SkipBossCard = false;
                miniBossIntroDoer.portraitSlideSettings.bossArtSprite = BossCardTexture;
                companion.aiActor.healthHaver.bossHealthBar           = HealthHaver.BossBarType.MainBar;
                miniBossIntroDoer.SkipFinalizeAnimation = true;

                miniBossIntroDoer.RegenerateCache();
                //BehaviorSpeculator aIActor = EnemyDatabase.GetOrLoadByGuid("465da2bb086a4a88a803f79fe3a27677").behaviorSpeculator;
                //Tools.DebugInformation(aIActor);

                /////



                companion.aiActor.healthHaver.SetHealthMaximum(500f, null, false);
                companion.aiActor.specRigidbody.PixelColliders.Clear();
                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider

                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyCollider,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 15,
                    ManualOffsetY          = 10,
                    ManualWidth            = 60,
                    ManualHeight           = 80,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0
                });
                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyHitBox,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 15,
                    ManualOffsetY          = 10,
                    ManualWidth            = 60,
                    ManualHeight           = 80,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0,
                });
                companion.aiActor.CorpseObject        = EnemyDatabase.GetOrLoadByGuid("c0ff3744760c4a2eb0bb52ac162056e6").CorpseObject;
                companion.aiActor.PreventBlackPhantom = false;
                AIAnimator aiAnimator = companion.aiAnimator;
                aiAnimator.IdleAnimation = new DirectionalAnimation
                {
                    Type      = DirectionalAnimation.DirectionType.Single,
                    Prefix    = "idle",
                    AnimNames = new string[1],
                    Flipped   = new DirectionalAnimation.FlipType[1]
                };
                DirectionalAnimation almostdone = new DirectionalAnimation
                {
                    Type      = DirectionalAnimation.DirectionType.Single,
                    Prefix    = "intro",
                    AnimNames = new string[1],
                    Flipped   = new DirectionalAnimation.FlipType[1]
                };
                aiAnimator.OtherAnimations = new List <AIAnimator.NamedDirectionalAnimation>
                {
                    new AIAnimator.NamedDirectionalAnimation
                    {
                        name = "intro",
                        anim = almostdone
                    }
                };
                bool flag3 = BishopCollection == null;
                if (flag3)
                {
                    BishopCollection = SpriteBuilder.ConstructCollection(prefab, "FlameChamber_Collection");
                    UnityEngine.Object.DontDestroyOnLoad(BishopCollection);
                    for (int i = 0; i < spritePaths.Length; i++)
                    {
                        SpriteBuilder.AddSpriteToCollection(spritePaths[i], BishopCollection);
                    }
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, BishopCollection, new List <int>
                    {
                        0,
                        1
                    }, "idle", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 7f;

                    SpriteBuilder.AddAnimation(companion.spriteAnimator, BishopCollection, new List <int>
                    {
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8
                    }, "intro", tk2dSpriteAnimationClip.WrapMode.Once).fps = 7f;
                }
                var bs = prefab.GetComponent <BehaviorSpeculator>();
                BehaviorSpeculator behaviorSpeculator = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").behaviorSpeculator;
                bs.OverrideBehaviors          = behaviorSpeculator.OverrideBehaviors;
                bs.OtherBehaviors             = behaviorSpeculator.OtherBehaviors;
                shootpoint                    = new GameObject("attach");
                shootpoint.transform.parent   = companion.transform;
                shootpoint.transform.position = companion.sprite.WorldCenter;
                GameObject m_CachedGunAttachPoint = companion.transform.Find("attach").gameObject;
                bs.TargetBehaviors = new List <TargetBehaviorBase>
                {
                    new TargetPlayerBehavior
                    {
                        Radius              = 35f,
                        LineOfSight         = false,
                        ObjectPermanence    = true,
                        SearchInterval      = 0.25f,
                        PauseOnTargetSwitch = false,
                        PauseTime           = 0.25f
                    }
                };
                float[] angles = { 45, 135, 225, 135 };
                bs.MovementBehaviors = new List <MovementBehaviorBase>
                {
                };

                bs.AttackBehaviorGroup.AttackBehaviors = new List <AttackBehaviorGroup.AttackGroupItem>
                {
                };


                bs.InstantFirstTick                = behaviorSpeculator.InstantFirstTick;
                bs.TickInterval                    = behaviorSpeculator.TickInterval;
                bs.PostAwakenDelay                 = behaviorSpeculator.PostAwakenDelay;
                bs.RemoveDelayOnReinforce          = behaviorSpeculator.RemoveDelayOnReinforce;
                bs.OverrideStartingFacingDirection = behaviorSpeculator.OverrideStartingFacingDirection;
                bs.StartingFacingDirection         = behaviorSpeculator.StartingFacingDirection;
                bs.SkipTimingDifferentiator        = behaviorSpeculator.SkipTimingDifferentiator;
                Game.Enemies.Add("cak:killshrine", companion.aiActor);
            }
        }
Пример #11
0
    public Enemy AddEnemyEntity(EnemyData data)
    {
        EnemyPrototype proto = EnemyDatabase.GetEnemyPrototype(data.type);

        if (proto == null)
        {
            return(null);
        }
        Enemy temp = null;

        switch (proto.enemyType)
        {
        case EnemyType.Slime:
            temp = new Slime(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.Eye:
            temp = new Eye(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.WurmAlien:
            temp = new WurmAlien(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.Snek:
            temp = new Snek(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.Stag:
            temp = new Stag(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.Snowball:
            temp = new Snowball(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.Sporby:
            temp = new Sporby(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.Voidling:
            temp = new Voidling(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.Ghost:
            temp = new Ghost(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.Snowdrift:
            temp = new Snowdrift(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.Treedude:
            temp = new Treedude(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.FrogLegs:
            temp = new FrogLegs(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.Hedgehog:
            temp = new Hedgehog(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.Nest:
            temp = new Nest(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.Crawler:
            temp = new Crawler(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.Nipper:
            temp = new Nipper(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;

        case EnemyType.PhoenixEgg:
            temp = new PhoenixEgg(proto);
            temp.Spawn(GetMapTilePosition(data.TilePosition));
            break;
        }

        return(temp);
    }
Пример #12
0
        public static GameObject BuildPrefab(string name, string guid, string defaultSpritePath, IntVector2 hitboxOffset, IntVector2 hitBoxSize, bool HasAiShooter, bool UsesAttackGroup = false)
        {
            if (BossBuilder.Dictionary.ContainsKey(guid))
            {
                ETGModConsole.Log("BossBuilder: Yea something went wrong. Complain to Neighborino about it.");
                return(null);
            }
            var prefab = GameObject.Instantiate(behaviorSpeculatorPrefab);

            prefab.name = name;

            //setup misc components
            var sprite = SpriteBuilder.SpriteFromResource(defaultSpritePath, prefab).GetComponent <tk2dSprite>();

            sprite.SetUpSpeculativeRigidbody(hitboxOffset, hitBoxSize).CollideWithOthers = true;
            prefab.AddComponent <tk2dSpriteAnimator>();
            prefab.AddComponent <AIAnimator>();
            PickupObject item = PickupObjectDatabase.GetById(291);
            //setup knockback
            var knockback = prefab.AddComponent <KnockbackDoer>();

            knockback.weight = 1;



            //setup health haver
            var healthHaver = prefab.AddComponent <HealthHaver>();

            healthHaver.RegisterBodySprite(sprite);
            healthHaver.PreventAllDamage = false;
            healthHaver.SetHealthMaximum(15000);
            healthHaver.FullHeal();


            //setup AI Actor
            var aiActor = prefab.AddComponent <AIActor>();

            aiActor.State     = AIActor.ActorState.Normal;
            aiActor.EnemyGuid = guid;
            aiActor.HasShadow = false;

            //setup behavior speculator
            var bs = prefab.GetComponent <BehaviorSpeculator>();

            bs.MovementBehaviors = new List <MovementBehaviorBase>();
            bs.TargetBehaviors   = new List <TargetBehaviorBase>();
            bs.OverrideBehaviors = new List <OverrideBehaviorBase>();
            bs.OtherBehaviors    = new List <BehaviorBase>();
            bs.AttackBehaviorGroup.AttackBehaviors = new List <AttackBehaviorGroup.AttackGroupItem>();
            if (HasAiShooter)
            {
                var actor = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5");
                behaviorSpeculatorPrefab = GameObject.Instantiate(actor.gameObject);
                foreach (Transform child in behaviorSpeculatorPrefab.transform)
                {
                    if (child != behaviorSpeculatorPrefab.transform)
                    {
                        GameObject.DestroyImmediate(child);
                    }
                }

                foreach (var comp in behaviorSpeculatorPrefab.GetComponents <Component>())
                {
                    if (comp.GetType() != typeof(BehaviorSpeculator))
                    {
                        GameObject.DestroyImmediate(comp);
                    }
                }

                GameObject.DontDestroyOnLoad(behaviorSpeculatorPrefab);
                FakePrefab.MarkAsFakePrefab(behaviorSpeculatorPrefab);
                behaviorSpeculatorPrefab.SetActive(false);
            }
            else
            {
                AIBulletBank aibulletBank = prefab.AddComponent <AIBulletBank>();
            }

            //Add to enemy database
            EnemyDatabaseEntry enemyDatabaseEntry = new EnemyDatabaseEntry
            {
                myGuid          = guid,
                placeableWidth  = 2,
                placeableHeight = 2,
                isNormalEnemy   = true,
                path            = guid,
                isInBossTab     = true,
                encounterGuid   = guid,
            };

            EnemyDatabase.Instance.Entries.Add(enemyDatabaseEntry);
            BossBuilder.Dictionary.Add(guid, prefab);
            //finalize
            GameObject.DontDestroyOnLoad(prefab);
            FakePrefab.MarkAsFakePrefab(prefab);
            prefab.SetActive(false);

            return(prefab);
        }
Пример #13
0
 public void Initialize(int enemyId, EnemyDatabase db, ItemDatabase itemdb)
 {
     Initialize(db.GenerateEnemyDirect(enemyId), db, itemdb);
 }
Пример #14
0
 public void Initialize(string questname, int currentStep, EnemyDatabase db, ItemDatabase itemdb)
 {
     Initialize(db.GenerateNextEnemy(questname, currentStep), db, itemdb);
 }
Пример #15
0
        public void HandleEnemyDamage(SpeculativeRigidbody enemy, PixelCollider hitPixelCollider)
        {
            if (enemy.spriteAnimator != null && enemy.spriteAnimator.QueryInvulnerabilityFrame())
            {
                return;
            }
            bool flag = !enemy.healthHaver.IsDead;

            if (this.currentProjectile.OnWillKillEnemy != null && this.damage >= enemy.healthHaver.GetCurrentHealth())
            {
                this.currentProjectile.OnWillKillEnemy(this.currentProjectile, enemy);
            }
            enemy.aiActor.healthHaver.ApplyDamage(this.damage, enemy.Velocity, this.m_owner.ActorName, this.damageTypes, DamageCategory.Normal, false, hitPixelCollider, this.ignoreDamageCaps);
            if (this.m_owner.activeItems != null)
            {
                foreach (PlayerItem active in this.m_owner.activeItems)
                {
                    if (active is SprenThing)
                    {
                        active.CurrentDamageCooldown = Mathf.Max(0, active.CurrentDamageCooldown - this.damage);
                    }
                }
            }
            bool killedTarget = (flag && enemy.healthHaver.IsDead);

            this.currentProjectile.OnHitEnemy?.Invoke(this.currentProjectile, enemy, killedTarget);
            if (!killedTarget && enemy.gameActor != null)
            {
                if (this.AppliesPoison && UnityEngine.Random.value < this.PoisonApplyChance)
                {
                    enemy.gameActor.ApplyEffect(this.healthEffect, 1f, null);
                }
                if (this.AppliesSpeedModifier && UnityEngine.Random.value < this.SpeedApplyChance)
                {
                    enemy.gameActor.ApplyEffect(this.speedEffect, 1f, null);
                }
                if (this.AppliesCharm && UnityEngine.Random.value < this.CharmApplyChance)
                {
                    enemy.gameActor.ApplyEffect(this.charmEffect, 1f, null);
                }
                if (this.AppliesFreeze && UnityEngine.Random.value < this.FreezeApplyChance)
                {
                    enemy.gameActor.ApplyEffect(this.freezeEffect, 1f, null);
                }
                if (this.AppliesCheese && UnityEngine.Random.value < this.CheeseApplyChance)
                {
                    enemy.gameActor.ApplyEffect(this.cheeseEffect, 1f, null);
                }
                if (this.AppliesBleed && UnityEngine.Random.value < this.BleedApplyChance)
                {
                    enemy.gameActor.ApplyEffect(this.bleedEffect, -1f, null);
                }
                if (this.AppliesFire && UnityEngine.Random.value < this.FireApplyChance)
                {
                    enemy.gameActor.ApplyEffect(this.fireEffect, 1f, null);
                }
                if (this.AppliesStun && UnityEngine.Random.value < this.StunApplyChance && enemy.gameActor.behaviorSpeculator)
                {
                    enemy.gameActor.behaviorSpeculator.Stun(this.AppliedStunDuration, true);
                }
                for (int i = 0; i < this.statusEffectsToApply.Count; i++)
                {
                    enemy.gameActor.ApplyEffect(this.statusEffectsToApply[i], 1f, null);
                }
                foreach (AppliedEffectBase effect in this.appliedEffects)
                {
                    effect.AddSelfToTarget(enemy.gameObject);
                }
                if (this.CanTransmogrify && UnityEngine.Random.value < this.ChanceToTransmogrify && enemy.aiActor && !enemy.aiActor.IsMimicEnemy && enemy.aiActor.healthHaver && !enemy.aiActor.healthHaver.IsBoss && enemy.aiActor.healthHaver.IsVulnerable)
                {
                    enemy.aiActor.Transmogrify(EnemyDatabase.GetOrLoadByGuid(this.TransmogrifyTargetGuids[UnityEngine.Random.Range(0, this.TransmogrifyTargetGuids.Length)]), (GameObject)ResourceCache.Acquire("Global VFX/VFX_Item_Spawn_Poof"));
                }
            }
            this.ignoreList.Clear();
            this.ignoreList.Add(enemy);
        }
Пример #16
0
        public static void Add()
        {
            Gun gun = ETGMod.Databases.Items.NewGun("Prime Cannon", "prime_cannon");

            Game.Items.Rename("outdated_gun_mods:prime_cannon", "cel:prime_cannon");
            gun.gameObject.AddComponent <PrimeCannon>();
            gun.SetShortDescription("Leedle");
            gun.SetLongDescription("u-u");
            gun.SetupSprite(null, "prime_cannon_idle_001", 8);
            gun.SetAnimationFPS(gun.shootAnimation, 4);
            gun.SetAnimationFPS(gun.reloadAnimation, 2);
            gun.AddProjectileModuleFrom("38_special", true, false);
            gun.DefaultModule.ammoType      = GameUIAmmoType.AmmoType.SMALL_BULLET;
            gun.DefaultModule.ammoCost      = 1;
            gun.DefaultModule.shootStyle    = ProjectileModule.ShootStyle.Automatic;
            gun.DefaultModule.sequenceStyle = ProjectileModule.ProjectileSequenceStyle.Random;
            gun.reloadTime     = 0f;
            gun.gunSwitchGroup = (PickupObjectDatabase.GetById(19) as Gun).gunSwitchGroup;
            gun.DefaultModule.angleVariance       = 0f;
            gun.DefaultModule.cooldownTime        = 1f;
            gun.DefaultModule.numberOfShotsInClip = 150;
            Gun gun2 = PickupObjectDatabase.GetById(15) as Gun;

            gun.muzzleFlashEffects = gun2.muzzleFlashEffects;
            gun.SetBaseMaxAmmo(150);
            gun.quality = PickupObject.ItemQuality.EXCLUDED;
            gun.encounterTrackable.EncounterGuid = "For what purpose are you reading this????? why would you?? creep.";
            gun.sprite.IsPerpendicular           = true;
            gun.gunClass = GunClass.RIFLE;
            Projectile projectile = UnityEngine.Object.Instantiate <Projectile>(gun.DefaultModule.projectiles[0]);

            projectile.gameObject.SetActive(false);
            FakePrefab.MarkAsFakePrefab(projectile.gameObject);
            UnityEngine.Object.DontDestroyOnLoad(projectile);
            gun.DefaultModule.projectiles[0]          = projectile;
            gun.barrelOffset.transform.localPosition -= new Vector3(0, .4f);
            projectile.transform.parent = gun.barrelOffset;
            AIActor           Grenat    = EnemyDatabase.GetOrLoadByGuid("b4666cb6ef4f4b038ba8924fd8adf38f");
            ExplosiveModifier GetFucked = projectile.gameObject.AddComponent <ExplosiveModifier>();
            ExplosionData     die       = new ExplosionData
            {
                damageRadius         = 1.5f,
                damageToPlayer       = 0f,
                doDamage             = true,
                damage               = 20f,
                doExplosionRing      = true,
                doDestroyProjectiles = true,
                doForce              = true,
                debrisForce          = 5f,
                pushRadius           = 1.6f,
                force = 8f,
                preventPlayerForce     = true,
                explosionDelay         = 0f,
                usesComprehensiveDelay = false,
                doScreenShake          = false,
                playDefaultSFX         = true,
                effect = Grenat.GetComponent <ExplodeOnDeath>().explosionData.effect
            };

            GetFucked.explosionData = die;
            projectile.SetProjectileSpriteRight("prime_bomb", 9, 9, null, null);
            ETGMod.Databases.Items.Add(gun, null, "ANY");
        }
        public static void BuildPrefab()
        {
            if (!(prefab != null || AdvEnemyBuilder.Dictionary.ContainsKey(guid)))
            {
                prefab = AdvEnemyBuilder.BuildPrefab("Test Enemy", guid, spritePaths[0], new IntVector2(14, 5), new IntVector2(5, 5), false);
                var companion = prefab.AddComponent <EnemyBehavior>();
                //Actor Variables
                companion.aiActor.MovementSpeed              = 7f;
                companion.aiActor.CollisionDamage            = 1f;
                companion.aiActor.HasShadow                  = true;
                companion.aiActor.IgnoreForRoomClear         = false;
                companion.aiActor.CanTargetPlayers           = true;
                companion.aiActor.CanTargetEnemies           = false;
                companion.aiActor.PreventFallingInPitsEver   = false;
                companion.aiActor.CollisionKnockbackStrength = 10f;
                companion.aiActor.procedurallyOutlined       = true;
                companion.aiActor.PreventBlackPhantom        = false;
                //Body Variables
                companion.aiActor.specRigidbody.CollideWithOthers  = true;
                companion.aiActor.specRigidbody.CollideWithTileMap = true;

                //Health Variables
                companion.aiActor.healthHaver.PreventAllDamage = false;
                companion.aiActor.healthHaver.SetHealthMaximum(15f, null, false);
                companion.aiActor.healthHaver.ForceSetCurrentHealth(15f);
                //Other Variables
                companion.aiActor.knockbackDoer.weight = 10f;
                //AnimatorVariables
                companion.aiAnimator.HitReactChance        = 1f;
                companion.aiAnimator.faceSouthWhenStopped  = false;
                companion.aiAnimator.faceTargetWhenStopped = true;
                companion.aiActor.SetIsFlying(true, "Flying Entity");
                AdvEnemyBuilder.Strings.Enemies.Set("#TEST_ENEMY_NAME_SMALL", "Test Enemy");
                companion.aiActor.OverrideDisplayName = "#TEST_ENEMY_NAME_SMALL";
                companion.aiActor.specRigidbody.PixelColliders.Clear();
                companion.aiActor.gameObject.AddComponent <tk2dSpriteAttachPoint>();
                companion.aiActor.gameObject.AddComponent <ObjectVisibilityManager>();
                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyCollider,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 14,
                    ManualOffsetY          = 5,
                    ManualWidth            = 5,
                    ManualHeight           = 5,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0
                });
                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyHitBox,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 14,
                    ManualOffsetY          = 5,
                    ManualWidth            = 5,
                    ManualHeight           = 5,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0,
                });
                AIAnimator aiAnimator = companion.aiAnimator;
                aiAnimator.IdleAnimation = new DirectionalAnimation {
                    Type = DirectionalAnimation.DirectionType.TwoWayHorizontal, Flipped = new DirectionalAnimation.FlipType[0], AnimNames = new string[] { "idle_right", "idle_left", }
                };
                aiAnimator.MoveAnimation = new DirectionalAnimation {
                    Type = DirectionalAnimation.DirectionType.TwoWayHorizontal, Flipped = new DirectionalAnimation.FlipType[0], AnimNames = new string[] { "move_right", "move_left", }
                };



                aiAnimator.OtherAnimations = new List <AIAnimator.NamedDirectionalAnimation> {
                    new AIAnimator.NamedDirectionalAnimation {
                        name = "sex", anim = new DirectionalAnimation {
                            Prefix = "sex", Type = DirectionalAnimation.DirectionType.TwoWayHorizontal, Flipped = new DirectionalAnimation.FlipType[0], AnimNames = new string[] { "sex_right", "sex_left", }
                        }
                    },
                };
                if (TestEnemyCollection == null)
                {
                    TestEnemyCollection = SpriteBuilder.ConstructCollection(prefab, "TestEnemyCollection");
                    UnityEngine.Object.DontDestroyOnLoad(TestEnemyCollection);
                    for (int i = 0; i < spritePaths.Length; i++)
                    {
                        SpriteBuilder.AddSpriteToCollection(spritePaths[i], TestEnemyCollection);
                    }
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, TestEnemyCollection, new List <int> {
                        0, 1, 2, 3,
                    }, "idle_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 15
                    ; SpriteBuilder.AddAnimation(companion.spriteAnimator, TestEnemyCollection, new List <int> {
                        4, 5, 6, 7,
                    }, "idle_left", tk2dSpriteAnimationClip.WrapMode.Once).fps = 15
                    ; SpriteBuilder.AddAnimation(companion.spriteAnimator, TestEnemyCollection, new List <int> {
                        8, 9, 10, 11,
                    }, "move_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 15;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, TestEnemyCollection, new List <int> {
                        12, 13, 14, 15,
                    }, "move_left", tk2dSpriteAnimationClip.WrapMode.Once).fps = 15;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, TestEnemyCollection, new List <int> {
                        16, 17, 18,
                    }, "sex_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 20;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, TestEnemyCollection, new List <int> {
                        19, 20, 21,
                    }, "sex_left", tk2dSpriteAnimationClip.WrapMode.Once).fps = 20;
                }
                var bs = prefab.GetComponent <BehaviorSpeculator>();
                prefab.GetComponent <ObjectVisibilityManager>();
                BehaviorSpeculator behaviorSpeculator = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").behaviorSpeculator;
                bs.OverrideBehaviors = behaviorSpeculator.OverrideBehaviors;
                bs.OtherBehaviors    = behaviorSpeculator.OtherBehaviors;

                //ATTACK BEHAVIOUR SETUP (Must be done BY HAND)
                shootpoint = new GameObject("f**k");
                shootpoint.transform.parent   = companion.transform;
                shootpoint.transform.position = (companion.sprite.WorldCenter + new Vector2(0, 0));
                GameObject m_CachedGunAttachPoint = companion.transform.Find("f**k").gameObject;
                bs.TargetBehaviors = new List <TargetBehaviorBase> { //Add your target behaviours here!
                    new TargetPlayerBehavior {
                        Radius = 1000, LineOfSight = false, ObjectPermanence = true, SearchInterval = 0.25f, PauseOnTargetSwitch = false, PauseTime = 0.25f,
                    },
                };

                bs.MovementBehaviors = new List <MovementBehaviorBase>()  //Add your movement behaviours here!
                {
                    new SeekTargetBehavior()
                    {
                        StopWhenInRange = true, CustomRange = 5, LineOfSight = false, ReturnToSpawn = true, SpawnTetherDistance = -1, PathInterval = 0.25f, SpecifyRange = false, MinActiveRange = 0, MaxActiveRange = 0
                    },
                };

                bs.AttackBehaviors = new List <AttackBehaviorBase>()
                {
                    //Attack behaviours must be added here MANUALLY
                };

                bs.InstantFirstTick                = behaviorSpeculator.InstantFirstTick;
                bs.TickInterval                    = behaviorSpeculator.TickInterval;
                bs.StartingFacingDirection         = behaviorSpeculator.StartingFacingDirection;
                bs.PostAwakenDelay                 = behaviorSpeculator.PostAwakenDelay;
                bs.RemoveDelayOnReinforce          = behaviorSpeculator.RemoveDelayOnReinforce;
                bs.OverrideStartingFacingDirection = behaviorSpeculator.OverrideStartingFacingDirection;
                bs.SkipTimingDifferentiator        = behaviorSpeculator.SkipTimingDifferentiator;



                if (companion.GetComponent <EncounterTrackable>() != null)
                {
                    UnityEngine.Object.Destroy(companion.GetComponent <EncounterTrackable>());
                }
                Game.Enemies.Add("nn:Test_Enemy".ToLower(), companion.aiActor);
                SpriteBuilder.AddSpriteToCollection("AmmonomiconSprite", AdvEnemyBuilder.ammonomiconCollection);
                companion.encounterTrackable               = companion.gameObject.AddComponent <EncounterTrackable>();
                companion.encounterTrackable.journalData   = new JournalEntry();
                companion.encounterTrackable.EncounterGuid = "nn:Test Enemy".ToLower();
                companion.encounterTrackable.prerequisites = new DungeonPrerequisite[0];
                companion.encounterTrackable.journalData.SuppressKnownState    = false;
                companion.encounterTrackable.journalData.IsEnemy               = true;
                companion.encounterTrackable.journalData.SuppressInAmmonomicon = false;
                companion.encounterTrackable.ProxyEncounterGuid              = "";
                companion.encounterTrackable.journalData.AmmonomiconSprite   = "Bingly Bungly Boo";
                companion.encounterTrackable.journalData.enemyPortraitSprite = ItemAPI.ResourceExtractor.GetTextureFromResource("Bungle Bish bash bosh");
                AdvEnemyBuilder.Strings.Enemies.Set("#TEST_ENEMY", "Test Enemy");
                AdvEnemyBuilder.Strings.Enemies.Set("#TEST_ENEMY_SHORTDESC", "Quote");
                AdvEnemyBuilder.Strings.Enemies.Set("#TEST_ENEMY_LONGDESC", "Description");
                companion.encounterTrackable.journalData.PrimaryDisplayName           = "#TEST_ENEMY";
                companion.encounterTrackable.journalData.NotificationPanelDescription = "#TEST_ENEMY_SHORTDESC";
                companion.encounterTrackable.journalData.AmmonomiconFullEntry         = "#TEST_ENEMY_LONGDESC";
                AdvEnemyBuilder.AddEnemyToDatabase(companion.gameObject, "nn:Test_Enemy".ToLower());
                EnemyDatabase.GetEntry("nn:Test_Enemy".ToLower()).ForcedPositionInAmmonomicon = 15;
                EnemyDatabase.GetEntry("nn:Test_Enemy".ToLower()).isInBossTab   = false;
                EnemyDatabase.GetEntry("nn:Test_Enemy".ToLower()).isNormalEnemy = true;
            }
        }
Пример #18
0
    private static void Create()
    {
        EnemyDatabase enemyDatabase = ScriptableObject.CreateInstance <EnemyDatabase>();

        //武器の初期化用にデータベース取得
        WeaponDatabase weaponDatabase = Resources.Load <WeaponDatabase>("weaponDatabase");

        JobDatabase jobDatabase = Resources.Load <JobDatabase>("jobDatabase");

        //妖精
        string name = "妖精";

        int[]    status        = new int[] { 1, 20, 5, 3, 3, 3, 1, 3, 2 };
        Job      job           = jobDatabase.FindByJob(JobName.妖精);
        bool     isBoss        = false;
        RaceType race          = RaceType.FAIRY;
        string   pathName      = null;
        var      skillLevelMap = new Dictionary <WeaponType, SkillLevel>()
        {
            { WeaponType.SHOT, SkillLevel.D },
        };

        enemyDatabase.enemyList.Add(new Enemy(name, job, status, isBoss, race, pathName, skillLevelMap));

        //メイド妖精 上級職とのステータス補正は職業に持たせているので、基礎値は下級職の妖精と同じとなる
        name          = "メイド妖精";
        status        = new int[] { 1, 20, 5, 3, 3, 3, 1, 3, 2 };
        job           = jobDatabase.FindByJob(JobName.メイド妖精);
        isBoss        = false;
        race          = RaceType.FAIRY;
        skillLevelMap = new Dictionary <WeaponType, SkillLevel>()
        {
            { WeaponType.SHOT, SkillLevel.B },
            { WeaponType.STRIKE, SkillLevel.B },
            { WeaponType.HEAL, SkillLevel.C },
        };
        enemyDatabase.enemyList.Add(new Enemy(name, job, status, isBoss, race, pathName, skillLevelMap));

        //毛玉
        name          = "毛玉";
        status        = new int[] { 1, 18, 2, 4, 3, 5, 2, 1, 4 };
        job           = jobDatabase.FindByJob(JobName.毛玉);
        isBoss        = false;
        race          = RaceType.YOUKAI;
        skillLevelMap = new Dictionary <WeaponType, SkillLevel>()
        {
            { WeaponType.STRIKE, SkillLevel.D },
        };
        enemyDatabase.enemyList.Add(new Enemy(name, job, status, isBoss, race, pathName, skillLevelMap));


        name          = "妖獣";
        status        = new int[] { 1, 18, 4, 5, 5, 5, 3, 1, 4 };
        job           = jobDatabase.FindByJob(JobName.妖獣);
        isBoss        = false;
        race          = RaceType.YOUKAI;
        skillLevelMap = new Dictionary <WeaponType, SkillLevel>()
        {
            { WeaponType.STRIKE, SkillLevel.B },
        };
        enemyDatabase.enemyList.Add(new Enemy(name, job, status, isBoss, race, pathName, skillLevelMap));

        name          = "魔導書";
        status        = new int[] { 1, 20, 6, 1, 8, 3, 2, 8, 1 };
        job           = jobDatabase.FindByJob(JobName.魔導書);
        isBoss        = false;
        race          = RaceType.TSUKUMOGAMI;
        skillLevelMap = new Dictionary <WeaponType, SkillLevel>()
        {
            { WeaponType.STRIKE, SkillLevel.D },
        };
        enemyDatabase.enemyList.Add(new Enemy(name, job, status, isBoss, race, pathName, skillLevelMap));

        name          = "グリモワール";
        status        = new int[] { 1, 20, 6, 1, 8, 3, 2, 8, 1 };
        job           = jobDatabase.FindByJob(JobName.グリモワール);
        isBoss        = false;
        race          = RaceType.TSUKUMOGAMI;
        skillLevelMap = new Dictionary <WeaponType, SkillLevel>()
        {
            { WeaponType.STRIKE, SkillLevel.B },
        };
        enemyDatabase.enemyList.Add(new Enemy(name, job, status, isBoss, race, pathName, skillLevelMap));

        name          = "使い魔";
        status        = new int[] { 1, 17, 5, 3, 5, 2, 2, 3, 2 };
        job           = jobDatabase.FindByJob(JobName.使い魔);
        isBoss        = false;
        race          = RaceType.MAGIC;
        skillLevelMap = new Dictionary <WeaponType, SkillLevel>()
        {
            { WeaponType.SHOT, SkillLevel.E },
            { WeaponType.STRIKE, SkillLevel.E },
            { WeaponType.LASER, SkillLevel.E },
        };
        enemyDatabase.enemyList.Add(new Enemy(name, job, status, isBoss, race, pathName, skillLevelMap));

        name          = "ひまわり妖精";
        status        = new int[] { 1, 25, 6, 5, 6, 3, 2, 8, 3 };
        job           = jobDatabase.FindByJob(JobName.ひまわり妖精);
        isBoss        = false;
        race          = RaceType.FAIRY;
        skillLevelMap = new Dictionary <WeaponType, SkillLevel>()
        {
            { WeaponType.SHOT, SkillLevel.D },
        };
        enemyDatabase.enemyList.Add(new Enemy(name, job, status, isBoss, race, pathName, skillLevelMap));

        name          = "ハイフェアリー";
        status        = new int[] { 1, 25, 6, 5, 6, 3, 2, 8, 3 };
        job           = jobDatabase.FindByJob(JobName.ハイフェアリー);
        isBoss        = false;
        race          = RaceType.FAIRY;
        skillLevelMap = new Dictionary <WeaponType, SkillLevel>()
        {
            { WeaponType.SHOT, SkillLevel.B },
            { WeaponType.STRIKE, SkillLevel.B },
        };
        enemyDatabase.enemyList.Add(new Enemy(name, job, status, isBoss, race, pathName, skillLevelMap));

        name          = "ホブゴブリン";
        status        = new int[] { 1, 28, 7, 12, 7, 5, 1, 5, 5 };
        job           = jobDatabase.FindByJob(JobName.ホブゴブリン);
        isBoss        = false;
        race          = RaceType.YOUKAI;
        skillLevelMap = new Dictionary <WeaponType, SkillLevel>()
        {
            { WeaponType.STRIKE, SkillLevel.B },
        };
        enemyDatabase.enemyList.Add(new Enemy(name, job, status, isBoss, race, pathName, skillLevelMap));

        name          = "吸血コウモリ";
        status        = new int[] { 1, 20, 4, 6, 6, 8, 6, 2, 5 };
        job           = jobDatabase.FindByJob(JobName.吸血コウモリ);
        isBoss        = false;
        race          = RaceType.YOUKAI;
        skillLevelMap = new Dictionary <WeaponType, SkillLevel>()
        {
            { WeaponType.STRIKE, SkillLevel.C },
        };
        enemyDatabase.enemyList.Add(new Enemy(name, job, status, isBoss, race, pathName, skillLevelMap));

        name          = "ツパイ";
        status        = new int[] { 1, 20, 4, 6, 6, 8, 6, 2, 5 };
        job           = jobDatabase.FindByJob(JobName.ツパイ);
        isBoss        = false;
        race          = RaceType.YOUKAI;
        skillLevelMap = new Dictionary <WeaponType, SkillLevel>()
        {
            { WeaponType.STRIKE, SkillLevel.A },
        };
        enemyDatabase.enemyList.Add(new Enemy(name, job, status, isBoss, race, pathName, skillLevelMap));

        name          = "幽霊";
        status        = new int[] { 1, 18, 5, 1, 5, 4, 1, 2, 5 };
        job           = jobDatabase.FindByJob(JobName.幽霊);
        isBoss        = false;
        race          = RaceType.GHOST;
        skillLevelMap = new Dictionary <WeaponType, SkillLevel>()
        {
            { WeaponType.LASER, SkillLevel.D },
        };
        enemyDatabase.enemyList.Add(new Enemy(name, job, status, isBoss, race, pathName, skillLevelMap));

        name          = "怨霊";
        status        = new int[] { 1, 18, 5, 1, 5, 4, 1, 2, 5 };
        job           = jobDatabase.FindByJob(JobName.怨霊);
        isBoss        = false;
        race          = RaceType.GHOST;
        skillLevelMap = new Dictionary <WeaponType, SkillLevel>()
        {
            { WeaponType.LASER, SkillLevel.B },
        };
        enemyDatabase.enemyList.Add(new Enemy(name, job, status, isBoss, race, pathName, skillLevelMap));

        //魔理沙
        status        = new int[] { 1, 19, 6, 4, 5, 8, 4, 4, 2 };
        name          = "魔理沙";
        job           = jobDatabase.FindByJob(JobName.魔法使い);
        isBoss        = true;
        race          = RaceType.HUMAN;
        pathName      = "Marisa";
        skillLevelMap = new Dictionary <WeaponType, SkillLevel>()
        {
            { WeaponType.SHOT, SkillLevel.E },
            { WeaponType.LASER, SkillLevel.D },
        };
        enemyDatabase.enemyList.Add(new Enemy(name, job, status, isBoss, race, pathName, skillLevelMap));

        //ルーミア
        status        = new int[] { 1, 24, 10, 5, 4, 5, 4, 10, 9 };
        name          = "ルーミア";
        job           = jobDatabase.FindByJob(JobName.暗闇の妖怪);
        isBoss        = true;
        race          = RaceType.YOUKAI;
        pathName      = "Rumia";
        skillLevelMap = new Dictionary <WeaponType, SkillLevel>()
        {
            { WeaponType.SHOT, SkillLevel.E },
            { WeaponType.LASER, SkillLevel.D },
        };
        enemyDatabase.enemyList.Add(new Enemy(name, job, status, isBoss, race, pathName, skillLevelMap));

        //大妖精
        status        = new int[] { 1, 24, 8, 5, 6, 7, 8, 9, 8 };
        name          = "大妖精";
        job           = jobDatabase.FindByJob(JobName.大妖精);
        isBoss        = true;
        race          = RaceType.FAIRY;
        pathName      = "Daiyousei";
        skillLevelMap = new Dictionary <WeaponType, SkillLevel>()
        {
            { WeaponType.SHOT, SkillLevel.D },
            { WeaponType.HEAL, SkillLevel.C },
        };
        enemyDatabase.enemyList.Add(new Enemy(name, job, status, isBoss, race, pathName, skillLevelMap));

        //チルノ
        status        = new int[] { 1, 26, 10, 10, 6, 8, 4, 9, 8 };
        name          = "チルノ";
        job           = jobDatabase.FindByJob(JobName.湖上の氷精);
        isBoss        = true;
        race          = RaceType.FAIRY;
        pathName      = "Cirno";
        skillLevelMap = new Dictionary <WeaponType, SkillLevel>()
        {
            { WeaponType.SHOT, SkillLevel.C },
            { WeaponType.STRIKE, SkillLevel.D },
        };
        enemyDatabase.enemyList.Add(new Enemy(name, job, status, isBoss, race, pathName, skillLevelMap));

        //美鈴
        status        = new int[] { 1, 30, 5, 12, 8, 9, 2, 7, 11 };
        name          = "美鈴";
        job           = jobDatabase.FindByJob(JobName.門番);
        isBoss        = true;
        race          = RaceType.YOUKAI;
        pathName      = "Meirin";
        skillLevelMap = new Dictionary <WeaponType, SkillLevel>()
        {
            { WeaponType.STRIKE, SkillLevel.B },
            { WeaponType.HEAL, SkillLevel.D },
        };
        enemyDatabase.enemyList.Add(new Enemy(name, job, status, isBoss, race, pathName, skillLevelMap));

        //小悪魔
        status        = new int[] { 1, 23, 6, 4, 6, 5, 5, 3, 3 };
        name          = "小悪魔";
        isBoss        = true;
        job           = jobDatabase.FindByJob(JobName.小悪魔);
        race          = RaceType.YOUKAI;
        pathName      = "Koakuma";
        skillLevelMap = new Dictionary <WeaponType, SkillLevel>()
        {
            { WeaponType.SHOT, SkillLevel.C },
            { WeaponType.HEAL, SkillLevel.C },
        };
        enemyDatabase.enemyList.Add(new Enemy(name, job, status, isBoss, race, pathName, skillLevelMap));

        //パチュリー
        status        = new int[] { 1, 20, 10, 3, 6, 1, 4, 5, 1 };
        name          = "パチュリー";
        isBoss        = true;
        job           = jobDatabase.FindByJob(JobName.魔女);
        race          = RaceType.YOUKAI;
        pathName      = "Patu";
        skillLevelMap = new Dictionary <WeaponType, SkillLevel>()
        {
            { WeaponType.SHOT, SkillLevel.B },
            { WeaponType.LASER, SkillLevel.A },
            { WeaponType.STRIKE, SkillLevel.B },
            { WeaponType.HEAL, SkillLevel.C },
        };
        enemyDatabase.enemyList.Add(new Enemy(name, job, status, isBoss, race, pathName, skillLevelMap));

        //咲夜
        status = new int[] { 1, 25, 8, 8, 10, 8, 10, 6, 6 };

        name          = "咲夜";
        job           = jobDatabase.FindByJob(JobName.紅魔館のメイド);
        isBoss        = true;
        race          = RaceType.HUMAN;
        pathName      = "Sakuya";
        skillLevelMap = new Dictionary <WeaponType, SkillLevel>()
        {
            { WeaponType.SHOT, SkillLevel.A },
            { WeaponType.STRIKE, SkillLevel.S },
        };
        enemyDatabase.enemyList.Add(new Enemy(name, job, status, isBoss, race, pathName, skillLevelMap));

        //レミリア
        status = new int[] { 1, 30, 10, 10, 8, 9, 12, 7, 7 };

        name   = "レミリア";
        job    = jobDatabase.FindByJob(JobName.紅い悪魔);
        isBoss = true;

        race          = RaceType.YOUKAI;
        pathName      = "Remilia";
        skillLevelMap = new Dictionary <WeaponType, SkillLevel>()
        {
            { WeaponType.STRIKE, SkillLevel.S },
        };
        enemyDatabase.enemyList.Add(new Enemy(name, job, status, isBoss, race, pathName, skillLevelMap));

        //フラン
        status = new int[] { 1, 30, 10, 10, 8, 9, 12, 7, 7 };
        name   = "フランドール";
        job    = jobDatabase.FindByJob(JobName.紅のカタストロフ);
        isBoss = true;

        race          = RaceType.YOUKAI;
        pathName      = "Fran";
        skillLevelMap = new Dictionary <WeaponType, SkillLevel>()
        {
            { WeaponType.STRIKE, SkillLevel.S },
        };
        enemyDatabase.enemyList.Add(new Enemy(name, job, status, isBoss, race, pathName, skillLevelMap));

        //ファイル書き出し Resources配下に作る
        AssetDatabase.CreateAsset(enemyDatabase, "Assets/Resources/enemyDatabase.asset");
    }
Пример #19
0
        private IEnumerator BecomeMimic()
        {
            PlayerController player  = GameManager.Instance.PrimaryPlayer;
            PlayerController player2 = GameManager.Instance.SecondaryPlayer;

            if (!SpawnEnemyMode)
            {
                if (player)
                {
                    if (player.HasPassiveItem(293) && player.HasPassiveItem(CursedBrick.CursedBrickID))
                    {
                        SpawnEnemyMode = true;
                    }
                }
                if (player2)
                {
                    if (player2.HasPassiveItem(293) && player2.HasPassiveItem(CursedBrick.CursedBrickID))
                    {
                        SpawnEnemyMode = true;
                    }
                }
            }

            if (m_hands == null)
            {
                StartCoroutine(DoIntro());
            }

            if (SpawnEnemyMode)
            {
                m_ItemDropOdds += 0.1f;
            }

            m_isHidden = false;
            SpeculativeRigidbody specRigidbody = this.specRigidbody;

            specRigidbody.OnRigidbodyCollision = (SpeculativeRigidbody.OnRigidbodyCollisionDelegate)Delegate.Remove(specRigidbody.OnRigidbodyCollision, new SpeculativeRigidbody.OnRigidbodyCollisionDelegate(HandleRigidbodyCollision));
            SpeculativeRigidbody specRigidbody2 = this.specRigidbody;

            specRigidbody2.OnBeamCollision = (SpeculativeRigidbody.OnBeamCollisionDelegate)Delegate.Remove(specRigidbody2.OnBeamCollision, new SpeculativeRigidbody.OnBeamCollisionDelegate(HandleBeamCollision));
            AIAnimator tongueAnimator = aiAnimator.ChildAnimator;

            tongueAnimator.renderer.enabled       = true;
            tongueAnimator.spriteAnimator.enabled = true;
            AIAnimator spitAnimator = tongueAnimator.ChildAnimator;

            spitAnimator.renderer.enabled       = true;
            spitAnimator.spriteAnimator.enabled = true;
            tongueAnimator.PlayUntilFinished("spawn", false, null, -1f, false);
            float delay        = tongueAnimator.CurrentClipLength;
            float timer        = 0f;
            bool  hasPlayedVFX = false;

            while (timer < delay)
            {
                yield return(null);

                timer += BraveTime.DeltaTime;
                if (!hasPlayedVFX && delay - timer < 0.1f)
                {
                    hasPlayedVFX = true;
                    if (WallDisappearVFX)
                    {
                        Vector2 zero  = Vector2.zero;
                        Vector2 zero2 = Vector2.zero;
                        DungeonData.Direction facingDirection = m_facingDirection;
                        if (facingDirection != DungeonData.Direction.SOUTH)
                        {
                            if (facingDirection != DungeonData.Direction.EAST)
                            {
                                if (facingDirection == DungeonData.Direction.WEST)
                                {
                                    zero  = new Vector2(0f, -1f);
                                    zero2 = new Vector2(0f, 1f);
                                }
                            }
                            else
                            {
                                zero  = new Vector2(0f, -1f);
                                zero2 = new Vector2(0f, 1f);
                            }
                        }
                        else
                        {
                            zero  = new Vector2(0f, -1f);
                            zero2 = new Vector2(0f, 1f);
                        }
                        Vector2 min = Vector2.Min(pos1.ToVector2(), pos2.ToVector2()) + zero;
                        Vector2 max = Vector2.Max(pos1.ToVector2(), pos2.ToVector2()) + new Vector2(1f, 1f) + zero2;
                        for (int i = 0; i < 5; i++)
                        {
                            Vector2        v              = BraveUtility.RandomVector2(min, max, new Vector2(0.25f, 0.25f)) + new Vector2(0f, 1f);
                            GameObject     gameObject     = SpawnManager.SpawnVFX(WallDisappearVFX, v, Quaternion.identity);
                            tk2dBaseSprite tk2dBaseSprite = (!gameObject) ? null : gameObject.GetComponent <tk2dBaseSprite>();
                            if (tk2dBaseSprite)
                            {
                                tk2dBaseSprite.HeightOffGround = 8f;
                                tk2dBaseSprite.UpdateZDepth();
                            }
                        }
                    }
                }
            }
            if (!m_failedWallConfigure && SpawnEnemyMode)
            {
                if (aiActor.ParentRoom != null && SpawnEnemyList != null && SpawnEnemyList.Count > 0 && UnityEngine.Random.value <= m_spawnEnemyOdds)
                {
                    int count2 = this.specRigidbody.PixelColliders.Count;
                    this.specRigidbody.PixelColliders.RemoveAt(count2 - 1);
                    this.specRigidbody.PixelColliders.RemoveAt(count2 - 2);
                    StaticReferenceManager.AllShadowSystemDepthHavers.Remove(m_fakeWall.transform);
                    Destroy(m_fakeWall);
                    Destroy(m_fakeCeiling);

                    Vector3 targetPosForSpawn = m_startingPos + DungeonData.GetIntVector2FromDirection(m_facingDirection).ToVector3();
                    while (timer < delay)
                    {
                        aiAnimator.LockFacingDirection = true;
                        aiAnimator.FacingDirection     = DungeonData.GetAngleFromDirection(m_facingDirection);
                        yield return(null);

                        timer += BraveTime.DeltaTime;
                        transform.position = Vector3.Lerp(m_startingPos, targetPosForSpawn, Mathf.InverseLerp(0.42f, 0.58f, timer));
                        this.specRigidbody.Reinitialize();
                    }
                    yield return(null);

                    Vector3 FinalSpawnLocation             = transform.position;
                    Vector3 VFXExplosionLocation           = transform.position;
                    Vector2 VFXExplosionSource             = Vector2.zero;
                    DungeonData.Direction CurrentDirection = m_facingDirection;
                    if (CurrentDirection == DungeonData.Direction.WEST)
                    {
                        FinalSpawnLocation   += new Vector3(2.5f, 3.5f);
                        VFXExplosionLocation += new Vector3(3.5f, 3.5f);
                        VFXExplosionSource    = new Vector2(1, 0);
                    }
                    else if (CurrentDirection == DungeonData.Direction.EAST)
                    {
                        FinalSpawnLocation   += new Vector3(4f, 3.5f);
                        VFXExplosionLocation += new Vector3(3f, 3.5f);
                    }
                    else if (CurrentDirection == DungeonData.Direction.NORTH)
                    {
                        FinalSpawnLocation   += new Vector3(3.5f, 4f);
                        VFXExplosionLocation += new Vector3(3.5f, 3f);
                        VFXExplosionSource    = new Vector2(0, 1);
                    }
                    else if (CurrentDirection == DungeonData.Direction.SOUTH)
                    {
                        FinalSpawnLocation   += new Vector3(3.5f, 1.5f);
                        VFXExplosionLocation += new Vector3(3.5f, 2.5f);
                    }
                    yield return(null);

                    string        SelectedEnemy          = BraveUtility.RandomElement(SpawnEnemyList);
                    ExplosionData wallMimicExplosionData = new ExplosionData();
                    wallMimicExplosionData.CopyFrom(GameManager.Instance.Dungeon.sharedSettingsPrefab.DefaultExplosionData);
                    wallMimicExplosionData.damage = 0f;
                    wallMimicExplosionData.force /= 1.6f;

                    if (SelectedEnemy != "RATCORPSE")
                    {
                        Exploder.Explode(VFXExplosionLocation, wallMimicExplosionData, VFXExplosionSource, ignoreQueues: true, damageTypes: CoreDamageTypes.None);
                        GameObject SpawnVFXObject = Instantiate((GameObject)ResourceCache.Acquire("Global VFX/VFX_Item_Spawn_Poof"));

                        if (SpawnVFXObject)
                        {
                            tk2dBaseSprite SpawnVFXObjectComponent = SpawnVFXObject.GetComponent <tk2dBaseSprite>();
                            SpawnVFXObjectComponent.PlaceAtPositionByAnchor(FinalSpawnLocation + new Vector3(0f, 0.5f, 0f), tk2dBaseSprite.Anchor.MiddleCenter);
                            SpawnVFXObjectComponent.HeightOffGround = 1f;
                            SpawnVFXObjectComponent.UpdateZDepth();
                        }

                        AIActor glitchActor = AIActor.Spawn(EnemyDatabase.GetOrLoadByGuid(SelectedEnemy), FinalSpawnLocation, aiActor.ParentRoom, true, AIActor.AwakenAnimationType.Awaken, true);

                        if (glitchActor)
                        {
                            PickupObject.ItemQuality targetGlitchEnemyItemQuality = (UnityEngine.Random.value >= 0.2f) ? ((!BraveUtility.RandomBool()) ? PickupObject.ItemQuality.C : PickupObject.ItemQuality.D) : PickupObject.ItemQuality.B;
                            GenericLootTable         glitchEnemyLootTable         = (!BraveUtility.RandomBool()) ? GameManager.Instance.RewardManager.GunsLootTable : GameManager.Instance.RewardManager.ItemsLootTable;
                            PickupObject             glitchEnemyItem = LootEngine.GetItemOfTypeAndQuality <PickupObject>(targetGlitchEnemyItemQuality, glitchEnemyLootTable, false);

                            // if (BraveUtility.RandomBool()) { ChaosUtility.MakeCompanion(glitchActor); }

                            if (glitchEnemyItem)
                            {
                                glitchActor.AdditionalSafeItemDrops.Add(glitchEnemyItem);
                            }

                            if (m_isGlitched)
                            {
                                float RandomIntervalFloat       = UnityEngine.Random.Range(0.02f, 0.06f);
                                float RandomDispFloat           = UnityEngine.Random.Range(0.1f, 0.16f);
                                float RandomDispIntensityFloat  = UnityEngine.Random.Range(0.1f, 0.4f);
                                float RandomColorProbFloat      = UnityEngine.Random.Range(0.05f, 0.2f);
                                float RandomColorIntensityFloat = UnityEngine.Random.Range(0.1f, 0.25f);

                                targetGlitchEnemyItemQuality = (UnityEngine.Random.value >= 0.2f) ? ((!BraveUtility.RandomBool()) ? PickupObject.ItemQuality.B : PickupObject.ItemQuality.C) : PickupObject.ItemQuality.A;
                                glitchEnemyLootTable         = (!BraveUtility.RandomBool()) ? GameManager.Instance.RewardManager.GunsLootTable : GameManager.Instance.RewardManager.ItemsLootTable;
                                glitchEnemyItem = LootEngine.GetItemOfTypeAndQuality <PickupObject>(targetGlitchEnemyItemQuality, glitchEnemyLootTable, false);
                                if (glitchEnemyItem)
                                {
                                    aiActor.AdditionalSafeItemDrops.Add(glitchEnemyItem);
                                }

                                ExpandShaders.Instance.ApplyGlitchShader(glitchActor.sprite, true, RandomIntervalFloat, RandomDispFloat, RandomDispIntensityFloat, RandomColorProbFloat, RandomColorIntensityFloat);
                            }

                            if (glitchActor.ParentRoom != null && !glitchActor.ParentRoom.IsSealed)
                            {
                                glitchActor.IgnoreForRoomClear = true;
                            }
                        }
                        else
                        {
                            // AIActor is null! Time to bail out of this and continue as normal wall mimic!
                            goto IL_ESCAPE;
                        }
                    }
                    else
                    {
                        Exploder.Explode(VFXExplosionLocation, wallMimicExplosionData, VFXExplosionSource, ignoreQueues: true, damageTypes: CoreDamageTypes.None);
                        GameObject     SpawnVFXObject          = Instantiate((GameObject)ResourceCache.Acquire("Global VFX/VFX_Item_Spawn_Poof"));
                        tk2dBaseSprite SpawnVFXObjectComponent = SpawnVFXObject.GetComponent <tk2dBaseSprite>();
                        SpawnVFXObjectComponent.PlaceAtPositionByAnchor(FinalSpawnLocation + new Vector3(0f, 0.5f, 0f), tk2dBaseSprite.Anchor.MiddleCenter);
                        SpawnVFXObjectComponent.HeightOffGround = 1f;
                        SpawnVFXObjectComponent.UpdateZDepth();
                        GameObject   spawnedRatCorpseObject = Instantiate(ExpandPrefabs.RatCorpseNPC, FinalSpawnLocation, Quaternion.identity);
                        TalkDoerLite talkdoerComponent      = spawnedRatCorpseObject.GetComponent <TalkDoerLite>();
                        talkdoerComponent.transform.position.XY().GetAbsoluteRoom().RegisterInteractable(talkdoerComponent);
                        talkdoerComponent.transform.position.XY().GetAbsoluteRoom().TransferInteractableOwnershipToDungeon(talkdoerComponent);
                        talkdoerComponent.playmakerFsm.SetState("Set Mode");
                        ExpandUtility.AddHealthHaver(talkdoerComponent.gameObject, 60, flashesOnDamage: false, exploderSpawnsItem: true);
                    }
                    yield return(null);

                    Destroy(gameObject);
                    yield break;
                }
            }
IL_ESCAPE:
            PickupObject.ItemQuality targetQuality = (UnityEngine.Random.value >= 0.2f) ? ((!BraveUtility.RandomBool()) ? PickupObject.ItemQuality.C : PickupObject.ItemQuality.D) : PickupObject.ItemQuality.B;
            GenericLootTable lootTable = (!BraveUtility.RandomBool()) ? GameManager.Instance.RewardManager.GunsLootTable : GameManager.Instance.RewardManager.ItemsLootTable;
            PickupObject     item      = LootEngine.GetItemOfTypeAndQuality <PickupObject>(targetQuality, lootTable, false);

            if (item)
            {
                if (CursedBrickMode)
                {
                    if (UnityEngine.Random.value <= m_ItemDropOdds | m_isGlitched)
                    {
                        aiActor.AdditionalSafeItemDrops.Add(item);
                    }
                    else
                    {
                        aiActor.AdditionalSafeItemDrops.Add(PickupObjectDatabase.GetById(70));
                        if (BraveUtility.RandomBool())
                        {
                            aiActor.AdditionalSafeItemDrops.Add(PickupObjectDatabase.GetById(70));
                        }
                        if (SpawnEnemyMode)
                        {
                            aiActor.AdditionalSafeItemDrops.Add(PickupObjectDatabase.GetById(70));
                        }
                    }
                    if (SpawnEnemyMode && UnityEngine.Random.value <= m_FriendlyMimicOdds)
                    {
                        m_isFriendlyMimic = true;
                    }
                    if (m_isGlitched)
                    {
                        float RandomIntervalFloat       = UnityEngine.Random.Range(0.02f, 0.06f);
                        float RandomDispFloat           = UnityEngine.Random.Range(0.1f, 0.16f);
                        float RandomDispIntensityFloat  = UnityEngine.Random.Range(0.1f, 0.4f);
                        float RandomColorProbFloat      = UnityEngine.Random.Range(0.05f, 0.2f);
                        float RandomColorIntensityFloat = UnityEngine.Random.Range(0.1f, 0.25f);

                        targetQuality = (UnityEngine.Random.value >= 0.2f) ? ((!BraveUtility.RandomBool()) ? PickupObject.ItemQuality.B : PickupObject.ItemQuality.C) : PickupObject.ItemQuality.A;
                        lootTable     = (!BraveUtility.RandomBool()) ? GameManager.Instance.RewardManager.GunsLootTable : GameManager.Instance.RewardManager.ItemsLootTable;
                        item          = LootEngine.GetItemOfTypeAndQuality <PickupObject>(targetQuality, lootTable, false);
                        if (item)
                        {
                            aiActor.AdditionalSafeItemDrops.Add(item);
                        }

                        ExpandShaders.Instance.ApplyGlitchShader(sprite, true, RandomIntervalFloat, RandomDispFloat, RandomDispIntensityFloat, RandomColorProbFloat, RandomColorIntensityFloat);
                    }
                }
                else
                {
                    aiActor.AdditionalSafeItemDrops.Add(item);
                }
            }
            if (CursedBrickMode && SpawnEnemyMode && UnityEngine.Random.value <= m_FriendlyMimicOdds)
            {
                m_isFriendlyMimic = true;
            }
            aiActor.enabled            = true;
            behaviorSpeculator.enabled = true;
            if (aiActor.ParentRoom != null && aiActor.ParentRoom.IsSealed && !m_isFriendlyMimic)
            {
                aiActor.IgnoreForRoomClear = false;
            }
            // if (m_isFriendlyMimic) { ExpandUtility.MakeCompanion(aiActor); }
            if (m_isFriendlyMimic)
            {
                aiActor.ApplyEffect(GameManager.Instance.Dungeon.sharedSettingsPrefab.DefaultPermanentCharmEffect, 1f, null);
            }
            if (!m_failedWallConfigure)
            {
                int count = this.specRigidbody.PixelColliders.Count;
                for (int j = 0; j < count - 2; j++)
                {
                    this.specRigidbody.PixelColliders[j].Enabled = true;
                }
                this.specRigidbody.PixelColliders.RemoveAt(count - 1);
                this.specRigidbody.PixelColliders.RemoveAt(count - 2);
                StaticReferenceManager.AllShadowSystemDepthHavers.Remove(m_fakeWall.transform);
                Destroy(m_fakeWall);
                Destroy(m_fakeCeiling);
            }
            else
            {
                int count = this.specRigidbody.PixelColliders.Count;
                for (int j = 0; j < count; j++)
                {
                    this.specRigidbody.PixelColliders[j].Enabled = true;
                }
            }
            for (int k = 0; k < m_hands.Length; k++)
            {
                m_hands[k].gameObject.SetActive(true);
            }
            aiActor.ToggleRenderers(true);
            if (aiShooter)
            {
                aiShooter.ToggleGunAndHandRenderers(true, "ExpandWallMimicManager");
            }
            aiActor.IsGone           = false;
            healthHaver.IsVulnerable = true;
            aiActor.State            = AIActor.ActorState.Normal;
            for (int l = 0; l < m_hands.Length; l++)
            {
                m_hands[l].gameObject.SetActive(false);
            }
            m_isFinished = true;
            delay        = 0.58f;
            timer        = 0f;
            Vector3 targetPos = m_startingPos + DungeonData.GetIntVector2FromDirection(m_facingDirection).ToVector3();

            while (timer < delay)
            {
                aiAnimator.LockFacingDirection = true;
                aiAnimator.FacingDirection     = DungeonData.GetAngleFromDirection(m_facingDirection);
                yield return(null);

                timer += BraveTime.DeltaTime;
                transform.position = Vector3.Lerp(m_startingPos, targetPos, Mathf.InverseLerp(0.42f, 0.58f, timer));
                this.specRigidbody.Reinitialize();
            }
            aiAnimator.LockFacingDirection = false;
            knockbackDoer.SetImmobile(false, "ExpandWallMimicManager");
            aiActor.CollisionDamage            = 0.5f;
            aiActor.CollisionKnockbackStrength = m_collisionKnockbackStrength;
            yield break;
        }
Пример #20
0
        public static void Add()
        {
            Gun gun = ETGMod.Databases.Items.NewGun("Firework Rifle", "firework_rifle");

            Game.Items.Rename("outdated_gun_mods:firework_rifle", "cel:firework_rifle");
            gun.gameObject.AddComponent <FireworkRifle>();
            gun.SetShortDescription("Bang, Bang, Bang! Here We Go!");
            gun.SetLongDescription("Shoots powerful fireworks.\n\nThis gun came from a world caught in an eternal struggle for balance. It was created to celebrate the journey of a hero.");

            gun.SetupSprite(null, "firework_rifle_idle_001", 8);
            gun.SetAnimationFPS(gun.shootAnimation, 18);
            gun.SetAnimationFPS(gun.reloadAnimation, 2);
            gun.AddProjectileModuleFrom("ak-47", true, false);

            gun.DefaultModule.ammoCost      = 1;
            gun.DefaultModule.shootStyle    = ProjectileModule.ShootStyle.Automatic;
            gun.DefaultModule.sequenceStyle = ProjectileModule.ProjectileSequenceStyle.Random;
            gun.reloadTime = .8f;
            gun.DefaultModule.angleVariance       = 4f;
            gun.DefaultModule.cooldownTime        = .2f;
            gun.DefaultModule.numberOfShotsInClip = 12;
            gun.DefaultModule.ammoType            = (PickupObjectDatabase.GetById(16) as Gun).DefaultModule.ammoType;
            Gun gun2 = PickupObjectDatabase.GetById(32) as Gun;

            gun.muzzleFlashEffects = gun2.muzzleFlashEffects;
            gun.SetBaseMaxAmmo(150);
            gun.barrelOffset.transform.localPosition = new Vector3(2, .3f);
            gun.quality = PickupObject.ItemQuality.S;
            gun.encounterTrackable.EncounterGuid = "pewpewgoboomboomdeath.";
            gun.sprite.IsPerpendicular           = true;
            gun.gunClass = GunClass.EXPLOSIVE;
            Projectile projectile = UnityEngine.Object.Instantiate <Projectile>(gun.DefaultModule.projectiles[0]);

            projectile.gameObject.SetActive(false);
            FakePrefab.MarkAsFakePrefab(projectile.gameObject);
            UnityEngine.Object.DontDestroyOnLoad(projectile);
            gun.DefaultModule.projectiles[0] = projectile;
            projectile.transform.parent      = gun.barrelOffset;
            projectile.shouldRotate          = true;
            projectile.SetProjectileSpriteRight("firework_proj", 13, 7, null, null);
            AIActor           Firecracker = EnemyDatabase.GetOrLoadByGuid("5f15093e6f684f4fb09d3e7e697216b4");
            ExplosiveModifier GetFucked   = projectile.gameObject.AddComponent <ExplosiveModifier>();

            ExplosionData die = new ExplosionData
            {
                damageRadius         = 1.5f,
                damageToPlayer       = 0f,
                doDamage             = true,
                damage               = 15f,
                doExplosionRing      = true,
                doDestroyProjectiles = true,
                doForce              = true,
                debrisForce          = 5f,
                pushRadius           = 1.6f,
                force = 8f,
                preventPlayerForce     = true,
                explosionDelay         = 0f,
                usesComprehensiveDelay = false,
                doScreenShake          = false,
                playDefaultSFX         = true,
                effect = Firecracker.GetComponent <ExplodeOnDeath>().explosionData.effect,
                //AssetBundle assetBundle = ResourceManager.LoadAssetBundle("shared_auto_001");
                //  GameObject TestingVFX = assetBundle.LoadAsset<GameObject>("VFX_Dust_Explosion");
            };

            GetFucked.explosionData = die;


            ETGMod.Databases.Items.Add(gun, null, "ANY");

            gun.AddToSubShop(ItemBuilder.ShopType.Trorc);
        }
Пример #21
0
        public static void Add()
        {
            // Get yourself a new gun "base" first.
            // Let's just call it "Basic Gun", and use "jpxfrd" for all sprites and as "codename" All sprites must begin with the same word as the codename. For example, your firing sprite would be named "jpxfrd_fire_001".
            Gun gun = ETGMod.Databases.Items.NewGun("Neon Desimator", "Neon_desimator");

            // "kp:basic_gun determines how you spawn in your gun through the console. You can change this command to whatever you want, as long as it follows the "name:itemname" template.
            Game.Items.Rename("outdated_gun_mods:neon_desimator", "ski:neon_desimator");
            gun.gameObject.AddComponent <Neon>();
            //These two lines determines the description of your gun, ".SetShortDescription" being the description that appears when you pick up the gun and ".SetLongDescription" being the description in the Ammonomicon entry.
            gun.SetShortDescription("High voltage!");
            gun.SetLongDescription("Crits against wet enemies! Some enemies are wet naturally others will need to be forced into it." +
                                   "\n\n\n - Knife_to_a_Gunfight");
            // This is required, unless you want to use the sprites of the base gun.
            // That, by default, is the pea shooter.
            // SetupSprite sets up the default gun sprite for the ammonomicon and the "gun get" popup.
            // WARNING: Add a copy of your default sprite to Ammonomicon Encounter Icon Collection!
            // That means, "sprites/Ammonomicon Encounter Icon Collection/defaultsprite.png" in your mod .zip. You can see an example of this with inside the mod folder.
            gun.SetupSprite(null, "Neon_desimator_idle_001", 3);


            gun.SetAnimationFPS(gun.shootAnimation, 15);
            gun.SetAnimationFPS(gun.reloadAnimation, 9);

            gun.AddProjectileModuleFrom("dl45", true, true);


            gun.DefaultModule.ammoCost      = 1;
            gun.DefaultModule.angleVariance = 1;
            gun.gunClass      = GunClass.SILLY;
            gun.gunHandedness = GunHandedness.OneHanded;

            gun.DefaultModule.shootStyle    = ProjectileModule.ShootStyle.SemiAutomatic;
            gun.DefaultModule.sequenceStyle = ProjectileModule.ProjectileSequenceStyle.Random;

            gun.reloadTime = 2f;
            gun.DefaultModule.numberOfShotsInClip = 9;
            gun.DefaultModule.cooldownTime        = .25f;



            gun.SetBaseMaxAmmo(300);
            gun.quality = PickupObject.ItemQuality.C;
            gun.encounterTrackable.EncounterGuid = "*Krzirrrrt!";

            //swipe
            Projectile projectile = UnityEngine.Object.Instantiate <Projectile>(gun.DefaultModule.projectiles[0]);

            gun.DefaultModule.ammoType       = GameUIAmmoType.AmmoType.CUSTOM;
            gun.DefaultModule.customAmmoType = "samus";
            Gun flash = (Gun)PickupObjectDatabase.GetByEncounterName("Void Core Assault Rifle");

            gun.barrelOffset.transform.localPosition = new Vector3(2f, .7f, 0f);
            gun.muzzleFlashEffects = flash.muzzleFlashEffects;
            projectile.gameObject.SetActive(false);
            FakePrefab.MarkAsFakePrefab(projectile.gameObject);
            UnityEngine.Object.DontDestroyOnLoad(projectile);
            gun.DefaultModule.projectiles[0] = projectile;
            projectile.baseData.damage       = 5f;
            projectile.baseData.speed        = 15f;
            projectile.baseData.range        = 20f;
            projectile.baseData.force        = 5;


            gun.sprite.usesOverrideMaterial = true;

            Material mat = new Material(EnemyDatabase.GetOrLoadByName("GunNut").sprite.renderer.material);

            mat.SetColor("_EmissiveColor", new Color32(255, 5, 5, 255));
            mat.SetFloat("_EmissiveColorPower", 6f);
            mat.SetFloat("_EmissivePower", 4);

            MeshRenderer component = gun.GetComponent <MeshRenderer>();

            if (!component)
            {
                ETGModConsole.Log("nope");
                return;
            }
            Material[] sharedMaterials = component.sharedMaterials;
            for (int i = 0; i < sharedMaterials.Length; i++)
            {
                if (sharedMaterials[i].shader == mat)
                {
                    return;
                }
            }
            Array.Resize <Material>(ref sharedMaterials, sharedMaterials.Length + 1);
            Material material = new Material(mat);

            material.SetTexture("_MainTex", sharedMaterials[0].GetTexture("_MainTex"));
            sharedMaterials[sharedMaterials.Length - 1] = material;
            component.sharedMaterials = sharedMaterials;



            projectile.transform.parent = gun.barrelOffset;
            ETGMod.Databases.Items.Add(gun, null, "ANY");
        }
Пример #22
0
        public static void BuildPrefab()
        {
            bool flag  = prefab != null || EnemyBuilder.Dictionary.ContainsKey(guid);
            bool flag2 = flag;

            if (!flag2)
            {
                AIActor aIActor = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5");
                prefab = EnemyBuilder.BuildPrefab("fancykin", guid, spritePaths[0], new IntVector2(0, 0), new IntVector2(8, 9), true);
                var companion = prefab.AddComponent <EnemyBehavior>();;
                companion.aiActor.knockbackDoer.weight         = 800;
                companion.aiActor.MovementSpeed                = 2f;
                companion.aiActor.healthHaver.PreventAllDamage = false;
                companion.aiActor.CollisionDamage              = 1f;
                companion.aiActor.HasShadow                        = false;
                companion.aiActor.IgnoreForRoomClear               = false;
                companion.aiActor.aiAnimator.HitReactChance        = 0f;
                companion.aiActor.specRigidbody.CollideWithOthers  = true;
                companion.aiActor.specRigidbody.CollideWithTileMap = true;
                companion.aiActor.PreventFallingInPitsEver         = false;
                companion.aiActor.healthHaver.ForceSetCurrentHealth(30f);
                companion.aiActor.CollisionKnockbackStrength = 5f;
                companion.aiActor.CanTargetPlayers           = true;
                companion.aiActor.healthHaver.SetHealthMaximum(55f, null, false);
                companion.aiActor.specRigidbody.PixelColliders.Clear();
                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider

                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyCollider,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 15,
                    ManualHeight           = 17,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0
                });
                companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
                {
                    ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                    CollisionLayer         = CollisionLayer.EnemyHitBox,
                    IsTrigger = false,
                    BagleUseFirstFrameOnly = false,
                    SpecifyBagelFrame      = string.Empty,
                    BagelColliderNumber    = 0,
                    ManualOffsetX          = 0,
                    ManualOffsetY          = 0,
                    ManualWidth            = 15,
                    ManualHeight           = 17,
                    ManualDiameter         = 0,
                    ManualLeftX            = 0,
                    ManualLeftY            = 0,
                    ManualRightX           = 0,
                    ManualRightY           = 0,
                });
                companion.aiActor.CorpseObject        = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").CorpseObject;
                companion.aiActor.PreventBlackPhantom = false;
                AIAnimator aiAnimator = companion.aiAnimator;
                aiAnimator.OtherAnimations = new List <AIAnimator.NamedDirectionalAnimation>
                {
                    new AIAnimator.NamedDirectionalAnimation
                    {
                        name = "die",
                        anim = new DirectionalAnimation
                        {
                            Type      = DirectionalAnimation.DirectionType.TwoWayHorizontal,
                            Flipped   = new DirectionalAnimation.FlipType[2],
                            AnimNames = new string[]
                            {
                                "die_right",
                                "die_left"
                            }
                        }
                    }
                };
                aiAnimator.IdleAnimation = new DirectionalAnimation
                {
                    Type      = DirectionalAnimation.DirectionType.TwoWayHorizontal,
                    Flipped   = new DirectionalAnimation.FlipType[2],
                    AnimNames = new string[]
                    {
                        "idle_front_right",
                        "idle_front_left",
                        "idle_back_right",
                        "idle_back_left"
                    }
                };
                aiAnimator.MoveAnimation = new DirectionalAnimation
                {
                    Type      = DirectionalAnimation.DirectionType.FourWay,
                    Flipped   = new DirectionalAnimation.FlipType[4],
                    AnimNames = new string[]
                    {
                        "run_back_right",
                        "run_front_right",
                        "run_front_left",
                        "run_back_left",
                    }
                };

                bool flag3 = fancykinCollection == null;
                if (flag3)
                {
                    fancykinCollection = SpriteBuilder.ConstructCollection(prefab, "fancykin_Collection");
                    UnityEngine.Object.DontDestroyOnLoad(fancykinCollection);
                    for (int i = 0; i < spritePaths.Length; i++)
                    {
                        SpriteBuilder.AddSpriteToCollection(spritePaths[i], fancykinCollection);
                    }
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, fancykinCollection, new List <int>
                    {
                        0,
                    }, "idle_back_left", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 5f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, fancykinCollection, new List <int>
                    {
                        1,
                    }, "idle_back_right", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 5f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, fancykinCollection, new List <int>
                    {
                        2,
                    }, "idle_front_left", tk2dSpriteAnimationClip.WrapMode.Once).fps = 5f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, fancykinCollection, new List <int>
                    {
                        3,
                    }, "idle_front_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 5f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, fancykinCollection, new List <int>
                    {
                        4,
                        5,
                        6,
                        7,
                        8,
                        9
                    }, "run_back_left", tk2dSpriteAnimationClip.WrapMode.Once).fps = 10f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, fancykinCollection, new List <int>
                    {
                        10,
                        11,
                        12,
                        13,
                        14,
                        15
                    }, "run_back_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 10f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, fancykinCollection, new List <int>
                    {
                        16,
                        17,
                        18,
                        19,
                        20,
                        21
                    }, "run_front_left", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 14f;
                    SpriteBuilder.AddAnimation(companion.spriteAnimator, fancykinCollection, new List <int>
                    {
                        22,
                        23,
                        24,
                        25,
                        26,
                        27
                    }, "run_front_right", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 14f;
                }

                var bs = prefab.GetComponent <BehaviorSpeculator>();
                BehaviorSpeculator behaviorSpeculator = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").behaviorSpeculator;

                bs.OverrideBehaviors = behaviorSpeculator.OverrideBehaviors;
                bs.OtherBehaviors    = behaviorSpeculator.OtherBehaviors;
                bs.TargetBehaviors   = new List <TargetBehaviorBase>
                {
                    new TargetPlayerBehavior
                    {
                        Radius              = 35f,
                        LineOfSight         = true,
                        ObjectPermanence    = true,
                        SearchInterval      = 0.25f,
                        PauseOnTargetSwitch = false,
                        PauseTime           = 0.25f
                    }
                };
                bs.AttackBehaviors = new List <AttackBehaviorBase>()
                {
                    new ShootGunBehavior()
                    {
                        GroupCooldownVariance        = 0.2f,
                        LineOfSight                  = false,
                        WeaponType                   = WeaponType.BulletScript,
                        OverrideBulletName           = null,
                        BulletScript                 = new CustomBulletScriptSelector(typeof(fancykinScript)),
                        FixTargetDuringAttack        = true,
                        StopDuringAttack             = true,
                        LeadAmount                   = 0,
                        LeadChance                   = 1,
                        RespectReload                = true,
                        MagazineCapacity             = 3,
                        ReloadSpeed                  = 5f,
                        EmptiesClip                  = true,
                        SuppressReloadAnim           = false,
                        TimeBetweenShots             = -1,
                        PreventTargetSwitching       = true,
                        OverrideAnimation            = null,
                        OverrideDirectionalAnimation = null,
                        HideGun                      = false,
                        UseLaserSight                = false,
                        UseGreenLaser                = false,
                        PreFireLaserTime             = -1,
                        AimAtFacingDirectionWhenSafe = false,
                        Cooldown                     = 0.6f,
                        CooldownVariance             = 0,
                        AttackCooldown               = 0,
                        GlobalCooldown               = 0,
                        InitialCooldown              = 0,
                        InitialCooldownVariance      = 0,
                        GroupName                    = null,
                        GroupCooldown                = 0,
                        MinRange                     = 0,
                        Range                      = 16,
                        MinWallDistance            = 0,
                        MaxEnemiesInRoom           = 0,
                        MinHealthThreshold         = 0,
                        MaxHealthThreshold         = 1,
                        HealthThresholds           = new float[0],
                        AccumulateHealthThresholds = true,
                        targetAreaStyle            = null,
                        IsBlackPhantom             = false,
                        resetCooldownOnDamage      = null,
                        RequiresLineOfSight        = true,
                        MaxUsages                  = 0,
                    }
                };
                bs.MovementBehaviors = new List <MovementBehaviorBase>
                {
                    new SeekTargetBehavior
                    {
                        StopWhenInRange     = true,
                        CustomRange         = 7f,
                        LineOfSight         = false,
                        ReturnToSpawn       = false,
                        SpawnTetherDistance = 0f,
                        PathInterval        = 0.5f,
                        SpecifyRange        = false,
                        MinActiveRange      = 0f,
                        MaxActiveRange      = 0f
                    }
                };

                BehaviorSpeculator load = EnemyDatabase.GetOrLoadByGuid("206405acad4d4c33aac6717d184dc8d4").behaviorSpeculator;
                bs.InstantFirstTick                = behaviorSpeculator.InstantFirstTick;
                bs.TickInterval                    = behaviorSpeculator.TickInterval;
                bs.PostAwakenDelay                 = behaviorSpeculator.PostAwakenDelay;
                bs.RemoveDelayOnReinforce          = behaviorSpeculator.RemoveDelayOnReinforce;
                bs.OverrideStartingFacingDirection = behaviorSpeculator.OverrideStartingFacingDirection;
                bs.StartingFacingDirection         = behaviorSpeculator.StartingFacingDirection;
                bs.SkipTimingDifferentiator        = behaviorSpeculator.SkipTimingDifferentiator;
                GameObject m_CachedGunAttachPoint = companion.transform.Find("GunAttachPoint").gameObject;
                Vector2    offset = new Vector2(1.5f, -0.50f);
                m_CachedGunAttachPoint.transform.position = companion.sprite.WorldCenter + offset;
                EnemyBuilder.DuplicateAIShooterAndAIBulletBank(prefab, aIActor.aiShooter, aIActor.GetComponent <AIBulletBank>(), 476, m_CachedGunAttachPoint.transform);
                Game.Enemies.Add("cak:fancykin", companion.aiActor);
            }
        }
Пример #23
0
 void Awake()
 {
     m_enemyDB = GetComponent<EnemyDatabase>() as EnemyDatabase;
     m_itemDB = GetComponent<ItemDatabase>() as ItemDatabase;
     m_fgDB = GetComponent<FloorGimicDatabase>() as FloorGimicDatabase;
 }
Пример #24
0
        public static GameObject BuildPrefab(string name, string guid, string defaultSpritePath, IntVector2 hitboxOffset, IntVector2 hitBoxSize, bool HasAiShooter, bool UsesAttackGroup = false)
        {
            if (HasAiShooter)
            {
                var actor = EnemyDatabase.GetOrLoadByGuid("3cadf10c489b461f9fb8814abc1a09c1");
                behaviorSpeculatorPrefab = GameObject.Instantiate(actor.gameObject);
                foreach (Transform child in behaviorSpeculatorPrefab.transform)
                {
                    if (child != behaviorSpeculatorPrefab.transform)
                    {
                        GameObject.DestroyImmediate(child);
                    }
                }
                foreach (var comp in behaviorSpeculatorPrefab.GetComponents <Component>())
                {
                    if (comp.GetType() != typeof(BehaviorSpeculator))
                    {
                        GameObject.DestroyImmediate(comp);
                    }
                }
                GameObject.DontDestroyOnLoad(behaviorSpeculatorPrefab);
                FakePrefab.MarkAsFakePrefab(behaviorSpeculatorPrefab);
                behaviorSpeculatorPrefab.SetActive(false);
            }
            if (EnemyBuilder.Dictionary.ContainsKey(guid))
            {
                ETGModConsole.Log("EnemyBuilder: Yea something went wrong. Complain to Neighborino about it.");
                return(null);
            }
            var prefab = GameObject.Instantiate(behaviorSpeculatorPrefab);

            prefab.name = name;

            //setup misc components
            var sprite = SpriteBuilder.SpriteFromResource(defaultSpritePath, prefab).GetComponent <tk2dSprite>();

            sprite.SetUpSpeculativeRigidbody(hitboxOffset, hitBoxSize).CollideWithOthers = true;
            prefab.AddComponent <tk2dSpriteAnimator>();
            prefab.AddComponent <AIAnimator>();

            //setup knockback
            var knockback = prefab.AddComponent <KnockbackDoer>();

            knockback.weight = 1;

            //setup health haver
            var healthHaver = prefab.AddComponent <HealthHaver>();

            healthHaver.RegisterBodySprite(sprite);
            healthHaver.PreventAllDamage = false;
            healthHaver.SetHealthMaximum(15000);
            healthHaver.FullHeal();

            //setup AI Actor
            var aiActor = prefab.AddComponent <AIActor>();

            aiActor.State            = AIActor.ActorState.Normal;
            aiActor.EnemyGuid        = guid;
            aiActor.CanTargetPlayers = true;
            aiActor.HasShadow        = false;
            aiActor.specRigidbody.CollideWithOthers  = true;
            aiActor.specRigidbody.CollideWithTileMap = true;
            aiActor.specRigidbody.PixelColliders.Clear();
            aiActor.specRigidbody.PixelColliders.Add(new PixelCollider

            {
                ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                CollisionLayer         = CollisionLayer.EnemyCollider,
                IsTrigger = false,
                BagleUseFirstFrameOnly = false,
                SpecifyBagelFrame      = string.Empty,
                BagelColliderNumber    = 0,
                ManualOffsetX          = 0,
                ManualOffsetY          = 0,
                ManualWidth            = 15,
                ManualHeight           = 17,
                ManualDiameter         = 0,
                ManualLeftX            = 0,
                ManualLeftY            = 0,
                ManualRightX           = 0,
                ManualRightY           = 0
            });
            aiActor.specRigidbody.PixelColliders.Add(new PixelCollider
            {
                ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                CollisionLayer         = CollisionLayer.EnemyHitBox,
                IsTrigger = false,
                BagleUseFirstFrameOnly = false,
                SpecifyBagelFrame      = string.Empty,
                BagelColliderNumber    = 0,
                ManualOffsetX          = 0,
                ManualOffsetY          = 0,
                ManualWidth            = 15,
                ManualHeight           = 17,
                ManualDiameter         = 0,
                ManualLeftX            = 0,
                ManualLeftY            = 0,
                ManualRightX           = 0,
                ManualRightY           = 0,
            });
            aiActor.CorpseObject        = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").CorpseObject;
            aiActor.PreventBlackPhantom = false;
            //setup behavior speculator
            var bs = prefab.GetComponent <BehaviorSpeculator>();

            bs.MovementBehaviors = new List <MovementBehaviorBase>();
            bs.TargetBehaviors   = new List <TargetBehaviorBase>();
            bs.OverrideBehaviors = new List <OverrideBehaviorBase>();
            bs.OtherBehaviors    = new List <BehaviorBase>();
            if (UsesAttackGroup)
            {
                bs.AttackBehaviorGroup.AttackBehaviors = new List <AttackBehaviorGroup.AttackGroupItem>();
            }
            else
            {
                bs.AttackBehaviors = new List <AttackBehaviorBase>();
            }
            //allows enemies to be tinted
            prefab.AddComponent <Tint>();
            prefab.AddComponent <EngageLate>();
            prefab.AddComponent <AIBulletBank>();
            //Add to enemy database
            EnemyDatabaseEntry enemyDatabaseEntry = new EnemyDatabaseEntry()
            {
                myGuid          = guid,
                placeableWidth  = 2,
                placeableHeight = 2,
                isNormalEnemy   = true,
            };

            EnemyDatabase.Instance.Entries.Add(enemyDatabaseEntry);
            EnemyBuilder.Dictionary.Add(guid, prefab);
            //finalize
            GameObject.DontDestroyOnLoad(prefab);
            FakePrefab.MarkAsFakePrefab(prefab);
            prefab.SetActive(false);

            return(prefab);
        }