Пример #1
0
        protected override void DoEffect(PlayerController user)
        {
            float            roomPosX         = user.transform.position.x - user.CurrentRoom.area.basePosition.x;
            float            roomPosY         = user.transform.position.y - user.CurrentRoom.area.basePosition.y;
            float            xOffSet          = 1;
            float            yOffSet          = 0;
            Vector2          posInCurrentRoom = new Vector2(roomPosX + xOffSet, roomPosY + yOffSet);
            GameObject       regularbarrel    = sharedAssets2.LoadAsset <GameObject>("Barrel_collection");
            GameObject       barrelPrefab     = FakePrefab.Clone(regularbarrel);
            DungeonPlaceable woodbox          = sharedAssets2.LoadAsset <DungeonPlaceable>("Barrel_collection");

            woodbox.InstantiateObject(user.CurrentRoom, posInCurrentRoom.ToIntVector2());
            bool flag = woodbox != null;

            if (flag)
            {
                woodbox.InstantiateObject(user.CurrentRoom, posInCurrentRoom.ToIntVector2());
            }
        }
Пример #2
0
        private void Start()
        {
            RoomHandler currentRoom = GameManager.Instance.PrimaryPlayer.CurrentRoom;
            int         num         = MinBoxes;
            int         i           = currentRoom.Cells.Count;

            for (i -= ExtraBoxAboveArea; i > 0; i -= ExtraBoxEveryArea)
            {
                num++;
            }
            num           = Mathf.Clamp(num, MinBoxes, 11);
            m_instanceBox = new FlippableCover[num];
            CellValidator cellValidator = delegate(IntVector2 c) {
                CellData cellData = GameManager.Instance.Dungeon.data[c];
                if (cellData == null || cellData.containsTrap || cellData.isOccupied)
                {
                    return(false);
                }
                for (int k = 0; k < m_instanceBox.Length; k++)
                {
                    if (m_instanceBox[k] != null && Vector2.Distance(m_instanceBox[k].specRigidbody.UnitCenter, c.ToCenterVector2()) < 5f)
                    {
                        return(false);
                    }
                }
                return(true);
            };

            for (int j = 0; j < num; j++)
            {
                IntVector2?randomAvailableCell = currentRoom.GetRandomAvailableCell(new IntVector2?(new IntVector2(4, 4)), new CellTypes?(CellTypes.FLOOR), false, cellValidator);
                if (randomAvailableCell != null)
                {
                    GameObject gameObject = BoxPlaceable.InstantiateObject(currentRoom, randomAvailableCell.Value + IntVector2.One - currentRoom.area.basePosition, false, false);
                    m_instanceBox[j] = gameObject.GetComponent <FlippableCover>();
                    m_instanceBox[j].GetComponentInChildren <tk2dSpriteAnimator>().Play("moving_box_in");
                    PhysicsEngine.Instance.RegisterOverlappingGhostCollisionExceptions(m_instanceBox[j].specRigidbody, null, false);
                }
            }
        }
        private void HandleChestRoomSetup()
        {
            AssetBundle          sharedAssets1  = ResourceManager.LoadAssetBundle("shared_auto_001");
            AssetBundle          sharedAssets2  = ResourceManager.LoadAssetBundle("shared_auto_002");
            ExpandObjectDatabase objectDatabase = new ExpandObjectDatabase();

            try {
                DungeonPlaceable ChestPlatform = sharedAssets2.LoadAsset <DungeonPlaceable>("Treasure_Dais_Stone_Carpet");
                GameObject       Chest_Black   = sharedAssets1.LoadAsset <GameObject>("Chest_Black");
                GameObject       Chest_Rainbow = sharedAssets1.LoadAsset <GameObject>("Chest_Rainbow");
                GameObject       Chest_Rat     = sharedAssets1.LoadAsset <GameObject>("Chest_Rat");

                IntVector2 TreasureChestCarpetPosition1 = new IntVector2(8, 29);
                IntVector2 TreasureChestCarpetPosition2 = new IntVector2(8, 54);
                IntVector2 SecretChestPosition1         = new IntVector2(8, 31);
                IntVector2 SecretChestPosition2         = new IntVector2(8, 56);
                GameObject TreasureChestStoneCarpet1    = ChestPlatform.InstantiateObject(m_ParentRoom, TreasureChestCarpetPosition1);
                GameObject TreasureChestStoneCarpet2    = ChestPlatform.InstantiateObject(m_ParentRoom, TreasureChestCarpetPosition2);
                TreasureChestStoneCarpet1.transform.position -= new Vector3(0.55f, 0);
                TreasureChestStoneCarpet2.transform.position -= new Vector3(0.55f, 0);
                TreasureChestStoneCarpet1.transform.SetParent(m_ParentRoom.hierarchyParent, true);
                TreasureChestStoneCarpet2.transform.SetParent(m_ParentRoom.hierarchyParent, true);

                GameObject PlacedBlackChestObject   = ExpandUtility.GenerateDungeonPlacable(Chest_Black, false, true).InstantiateObject(m_ParentRoom, SecretChestPosition1);
                GameObject PlacedRainbowChestObject = ExpandUtility.GenerateDungeonPlacable(Chest_Rainbow, false, true).InstantiateObject(m_ParentRoom, SecretChestPosition2);
                PlacedBlackChestObject.transform.position    += new Vector3(0.5f, 0);
                PlacedRainbowChestObject.transform.position  += new Vector3(0.5f, 0);
                TreasureChestStoneCarpet1.transform.position += new Vector3(0.5f, 0);
                TreasureChestStoneCarpet2.transform.position += new Vector3(0.5f, 0);
                PlacedBlackChestObject.transform.SetParent(m_ParentRoom.hierarchyParent, true);
                PlacedRainbowChestObject.transform.SetParent(m_ParentRoom.hierarchyParent, true);

                tk2dBaseSprite PlacedBlackChestSprite = PlacedBlackChestObject.GetComponentInChildren <tk2dBaseSprite>();

                GenericLootTable BlackChestLootTable = GameManager.Instance.RewardManager.ItemsLootTable;

                Chest PlacedBlackChestComponent   = PlacedBlackChestObject.GetComponent <Chest>();
                Chest PlacedRainbowChestComponent = PlacedRainbowChestObject.GetComponent <Chest>();
                PlacedBlackChestComponent.ChestType           = Chest.GeneralChestType.ITEM;
                PlacedBlackChestComponent.lootTable.lootTable = BlackChestLootTable;
                bool LootTableCheck = PlacedBlackChestComponent.lootTable.canDropMultipleItems && PlacedBlackChestComponent.lootTable.overrideItemLootTables != null && PlacedBlackChestComponent.lootTable.overrideItemLootTables.Count > 0;
                if (LootTableCheck)
                {
                    PlacedBlackChestComponent.lootTable.overrideItemLootTables[0] = BlackChestLootTable;
                }
                PlacedBlackChestComponent.overrideMimicChance = 0f;
                PlacedBlackChestComponent.ForceUnlock();
                PlacedBlackChestComponent.PreventFuse = true;
                PlacedRainbowChestComponent.ForceUnlock();
                PlacedRainbowChestComponent.PreventFuse = true;
                m_ParentRoom.RegisterInteractable(PlacedBlackChestComponent);
                m_ParentRoom.RegisterInteractable(PlacedRainbowChestComponent);

                Vector3    SpecialLockedDoorPosition = (new Vector3(9, 52.25f) + m_ParentRoom.area.basePosition.ToVector3());
                GameObject SpecialLockedDoor         = Instantiate(objectDatabase.LockedJailDoor, SpecialLockedDoorPosition, Quaternion.identity);
                SpecialLockedDoor.transform.SetParent(m_ParentRoom.hierarchyParent, true);
                InteractableLock SpecialLockedDoorComponent = SpecialLockedDoor.GetComponentInChildren <InteractableLock>();
                SpecialLockedDoorComponent.lockMode      = InteractableLock.InteractableLockMode.RESOURCEFUL_RAT;
                SpecialLockedDoorComponent.JailCellKeyId = 0;
                tk2dBaseSprite RainbowLockSprite = SpecialLockedDoorComponent.GetComponentInChildren <tk2dBaseSprite>();
                if (RainbowLockSprite != null)
                {
                    ExpandShaders.Instance.ApplyRainbowShader(RainbowLockSprite);
                }

                IntVector2 PuzzleChestPosition1       = new IntVector2(4, 19);
                IntVector2 PuzzleChestPosition2       = new IntVector2(12, 19);
                IntVector2 PuzzleChestPosition3       = new IntVector2(4, 40);
                IntVector2 PuzzleChestPosition4       = new IntVector2(12, 40);
                IntVector2 PuzzleChestPosition5       = new IntVector2(4, 50);
                IntVector2 PuzzleChestPosition6       = new IntVector2(12, 50);
                IntVector2 PuzzleChestCarpetPosition1 = (PuzzleChestPosition1 - new IntVector2(0, 1));
                IntVector2 PuzzleChestCarpetPosition2 = (PuzzleChestPosition2 - new IntVector2(0, 1));
                IntVector2 PuzzleChestCarpetPosition3 = (PuzzleChestPosition3 - new IntVector2(0, 1));
                IntVector2 PuzzleChestCarpetPosition4 = (PuzzleChestPosition4 - new IntVector2(0, 1));
                IntVector2 PuzzleChestCarpetPosition5 = (PuzzleChestPosition5 - new IntVector2(0, 1));
                IntVector2 PuzzleChestCarpetPosition6 = (PuzzleChestPosition6 - new IntVector2(0, 1));

                GameObject PlacedPuzzleRatChest1   = ExpandUtility.GenerateDungeonPlacable(Chest_Rat, false, true).InstantiateObject(m_ParentRoom, PuzzleChestPosition1, false, true);
                GameObject PlacedPuzzleRatChest2   = ExpandUtility.GenerateDungeonPlacable(Chest_Rat, false, true).InstantiateObject(m_ParentRoom, PuzzleChestPosition2, false, true);
                GameObject PlacedPuzzleRatChest3   = ExpandUtility.GenerateDungeonPlacable(Chest_Rat, false, true).InstantiateObject(m_ParentRoom, PuzzleChestPosition3, false, true);
                GameObject PlacedPuzzleRatChest4   = ExpandUtility.GenerateDungeonPlacable(Chest_Rat, false, true).InstantiateObject(m_ParentRoom, PuzzleChestPosition4, false, true);
                GameObject PlacedPuzzleRatChest5   = ExpandUtility.GenerateDungeonPlacable(Chest_Rat, false, true).InstantiateObject(m_ParentRoom, PuzzleChestPosition5, false, true);
                GameObject PlacedPuzzleRatChest6   = ExpandUtility.GenerateDungeonPlacable(Chest_Rat, false, true).InstantiateObject(m_ParentRoom, PuzzleChestPosition6, false, true);
                GameObject PuzzleChestStoneCarpet1 = ChestPlatform.InstantiateObject(m_ParentRoom, PuzzleChestCarpetPosition1);
                GameObject PuzzleChestStoneCarpet2 = ChestPlatform.InstantiateObject(m_ParentRoom, PuzzleChestCarpetPosition2);
                GameObject PuzzleChestStoneCarpet3 = ChestPlatform.InstantiateObject(m_ParentRoom, PuzzleChestCarpetPosition3);
                GameObject PuzzleChestStoneCarpet4 = ChestPlatform.InstantiateObject(m_ParentRoom, PuzzleChestCarpetPosition4);
                GameObject PuzzleChestStoneCarpet5 = ChestPlatform.InstantiateObject(m_ParentRoom, PuzzleChestCarpetPosition5);
                GameObject PuzzleChestStoneCarpet6 = ChestPlatform.InstantiateObject(m_ParentRoom, PuzzleChestCarpetPosition6);
                PlacedPuzzleRatChest1.transform.SetParent(m_ParentRoom.hierarchyParent, true);
                PlacedPuzzleRatChest2.transform.SetParent(m_ParentRoom.hierarchyParent, true);
                PlacedPuzzleRatChest3.transform.SetParent(m_ParentRoom.hierarchyParent, true);
                PlacedPuzzleRatChest4.transform.SetParent(m_ParentRoom.hierarchyParent, true);
                PlacedPuzzleRatChest5.transform.SetParent(m_ParentRoom.hierarchyParent, true);
                PlacedPuzzleRatChest6.transform.SetParent(m_ParentRoom.hierarchyParent, true);
                PuzzleChestStoneCarpet1.transform.SetParent(m_ParentRoom.hierarchyParent, true);
                PuzzleChestStoneCarpet2.transform.SetParent(m_ParentRoom.hierarchyParent, true);
                PuzzleChestStoneCarpet3.transform.SetParent(m_ParentRoom.hierarchyParent, true);
                PuzzleChestStoneCarpet4.transform.SetParent(m_ParentRoom.hierarchyParent, true);
                PuzzleChestStoneCarpet5.transform.SetParent(m_ParentRoom.hierarchyParent, true);
                PuzzleChestStoneCarpet6.transform.SetParent(m_ParentRoom.hierarchyParent, true);

                Chest PuzzleRatChest1Component = PlacedPuzzleRatChest1.GetComponent <Chest>();
                Chest PuzzleRatChest2Component = PlacedPuzzleRatChest2.GetComponent <Chest>();
                Chest PuzzleRatChest3Component = PlacedPuzzleRatChest3.GetComponent <Chest>();
                Chest PuzzleRatChest4Component = PlacedPuzzleRatChest4.GetComponent <Chest>();
                Chest PuzzleRatChest5Component = PlacedPuzzleRatChest5.GetComponent <Chest>();
                Chest PuzzleRatChest6Component = PlacedPuzzleRatChest6.GetComponent <Chest>();
                PuzzleRatChest1Component.PreventFuse         = true;
                PuzzleRatChest2Component.PreventFuse         = true;
                PuzzleRatChest3Component.PreventFuse         = true;
                PuzzleRatChest4Component.PreventFuse         = true;
                PuzzleRatChest5Component.PreventFuse         = true;
                PuzzleRatChest6Component.PreventFuse         = true;
                PuzzleRatChest1Component.overrideMimicChance = 0f;
                PuzzleRatChest2Component.overrideMimicChance = 0f;
                PuzzleRatChest3Component.overrideMimicChance = 0f;
                PuzzleRatChest4Component.overrideMimicChance = 0f;
                PuzzleRatChest5Component.overrideMimicChance = 0f;
                PuzzleRatChest6Component.overrideMimicChance = 0f;

                float Seed = UnityEngine.Random.value;

                if (Seed <= 0.5f)
                {
                    PuzzleRatChest1Component.forceContentIds = new List <int> {
                        68
                    };
                    PuzzleRatChest2Component.forceContentIds = new List <int> {
                        727, 727
                    };
                }
                else
                {
                    PuzzleRatChest1Component.forceContentIds = new List <int> {
                        727, 727
                    };
                    PuzzleRatChest2Component.forceContentIds = new List <int> {
                        68
                    };
                }
                if (BraveUtility.RandomBool())
                {
                    PuzzleRatChest3Component.forceContentIds = new List <int> {
                        70, 70, 70, 70
                    };
                    PuzzleRatChest4Component.forceContentIds = new List <int> {
                        727, 727
                    };
                }
                else
                {
                    PuzzleRatChest3Component.forceContentIds = new List <int> {
                        727, 727
                    };
                    PuzzleRatChest4Component.forceContentIds = new List <int> {
                        70, 70, 70, 70
                    };
                }
                if (BraveUtility.RandomBool())
                {
                    PuzzleRatChest5Component.forceContentIds = new List <int> {
                        74
                    };
                    PuzzleRatChest6Component.forceContentIds = new List <int> {
                        316
                    };
                }
                else
                {
                    PuzzleRatChest5Component.forceContentIds = new List <int> {
                        316
                    };
                    PuzzleRatChest6Component.forceContentIds = new List <int> {
                        74
                    };
                }

                PuzzleRatChest1Component.ConfigureOnPlacement(m_ParentRoom);
                PuzzleRatChest2Component.ConfigureOnPlacement(m_ParentRoom);
                PuzzleRatChest3Component.ConfigureOnPlacement(m_ParentRoom);
                PuzzleRatChest4Component.ConfigureOnPlacement(m_ParentRoom);
                PuzzleRatChest5Component.ConfigureOnPlacement(m_ParentRoom);
                PuzzleRatChest6Component.ConfigureOnPlacement(m_ParentRoom);
                m_ParentRoom.RegisterInteractable(PuzzleRatChest1Component);
                m_ParentRoom.RegisterInteractable(PuzzleRatChest2Component);
                m_ParentRoom.RegisterInteractable(PuzzleRatChest3Component);
                m_ParentRoom.RegisterInteractable(PuzzleRatChest4Component);
                m_ParentRoom.RegisterInteractable(PuzzleRatChest5Component);
                m_ParentRoom.RegisterInteractable(PuzzleRatChest6Component);

                Vector3 InfoSignPosition = (new Vector3(6, 4) + m_ParentRoom.area.basePosition.ToVector3());

                GameObject ChestPuzzleInfoSign = Instantiate(ExpandPrefabs.Jungle_BlobLostSign, InfoSignPosition, Quaternion.identity);
                ChestPuzzleInfoSign.name = "Lunk's Minigame Sign";
                ChestPuzzleInfoSign.GetComponent <ExpandNoteDoer>().stringKey = "A minigame Lunk created based on a game he used to play in a land far away.\nGuess the right chest to continue forward.\n If you can guess the correct chest 3 times, the ultimate prize shall be gained!";
                m_ParentRoom.RegisterInteractable(ChestPuzzleInfoSign.GetComponent <ExpandNoteDoer>());
            } catch (Exception ex) {
                if (ExpandStats.debugMode)
                {
                    string Message = "[ExpandTheGungeon] Warning: Exception caught in ExpandWestPuzzleRoomController.HandleChestRoomSetup!";
                    ETGModConsole.Log(Message);
                    Debug.Log(Message);
                    Debug.LogException(ex);
                }
            }
            sharedAssets1  = null;
            sharedAssets2  = null;
            objectDatabase = null;
        }
Пример #4
0
        protected override void DoEffect(PlayerController user)
        {
            base.DoEffect(user);
            AkSoundEngine.PostEvent("m_ENM_amulet_conjure_01", base.gameObject);
            if (user.CurrentRoom != null)
            {
                float roomPosX        = user.transform.position.x - user.CurrentRoom.area.basePosition.x;
                float roomPosY        = user.transform.position.y - user.CurrentRoom.area.basePosition.y;
                float xOffSet         = 0;
                float yOffSet         = 0;
                float thexOffSet      = 0;
                float theyOffSet      = 0;
                float offsetAmount    = 2f;
                float gunCurrentAngle = BraveMathCollege.Atan2Degrees(this.LastOwner.unadjustedAimPoint.XY() - this.LastOwner.CenterPosition);
                if (gunCurrentAngle > 45f && gunCurrentAngle <= 135f)
                {
                    yOffSet = offsetAmount;                    //up
                }
                else if ((gunCurrentAngle > 0 && gunCurrentAngle > 135f) || (gunCurrentAngle < 0 && gunCurrentAngle <= -135f))
                {
                    xOffSet = -offsetAmount;                    //left
                }
                else if (gunCurrentAngle > -135f && gunCurrentAngle <= -45f)
                {
                    yOffSet = -offsetAmount;                    //bottom
                }
                else
                {
                    xOffSet = offsetAmount;                    //right
                }

                if (gunCurrentAngle > 45f && gunCurrentAngle <= 135f)
                {
                    theyOffSet = -offsetAmount;                    //up
                }
                else if ((gunCurrentAngle > 0 && gunCurrentAngle > 135f) || (gunCurrentAngle < 0 && gunCurrentAngle <= -135f))
                {
                    thexOffSet = offsetAmount;                    //left
                }
                else if (gunCurrentAngle > -135f && gunCurrentAngle <= -45f)
                {
                    theyOffSet = offsetAmount;                    //bottom
                }
                else
                {
                    thexOffSet = -offsetAmount;                    //right
                }


                Vector2 posInCurrentRoom  = new Vector2(roomPosX + xOffSet, roomPosY + yOffSet);
                Vector2 posInCurrentRoom2 = new Vector2(roomPosX + thexOffSet, roomPosY + theyOffSet);
                Vector2 posInMap          = new Vector2(user.transform.position.x + xOffSet, user.transform.position.y + yOffSet).ToIntVector2().ToVector2();
                Vector2 posInMap2         = new Vector2(user.transform.position.x + thexOffSet, user.transform.position.y + theyOffSet).ToIntVector2().ToVector2();
                if (user.IsValidPlayerPosition(posInMap))
                {
                    AssetBundle sharedAssets2d = ResourceManager.LoadAssetBundle("shared_auto_002");
                    AssetBundle sharedAssets2  = ResourceManager.LoadAssetBundle("shared_auto_001");
                    if (user.HasPickupID(332))
                    {
                        DungeonPlaceable ExplodyBarreld = sharedAssets2d.LoadAsset <DungeonPlaceable>("ExplodyBarrel_Maybe");
                        GameObject       spawnedDrumd   = ExplodyBarreld.InstantiateObject(user.CurrentRoom, posInCurrentRoom2.ToIntVector2());
                    }
                    ;

                    DungeonPlaceable ExplodyBarrel = sharedAssets2.LoadAsset <DungeonPlaceable>("Barrel_collection");
                    GameObject       spawnedDrum   = ExplodyBarrel.InstantiateObject(user.CurrentRoom, posInCurrentRoom.ToIntVector2());
                }
            }
        }