public void PopulateLevels(LevelGroupingSettings LevelGroup)
        {
            levelGroup = LevelGroup;

            for (int i = 0; i < levelGroup.Levels.Count; i++)
            {
                LevelCardScript activeLevelCard = levelCards[i].GetComponent <LevelCardScript>();
                activeLevelCard.PopulateLevelInformation(levelGroup.Levels[i], int.Parse(levelGroup.Id), levelGroup.boardBackgroundImage);
                uniqueIDs.Add(levelGroup.Levels[i].UniqueID);
                cardScripts.Add(activeLevelCard);
            }

            if (levelGroup.GoldLevels.Count > 0 && goldLevelCards.Count > 0)
            {
                for (int i = 0; i < levelGroup.GoldLevels.Count; i++)
                {
                    GoldLevelCardScript activeGoldLevelCard = goldLevelCards[i].GetComponent <GoldLevelCardScript>();
                    activeGoldLevelCard.PopulateLevelInformation(levelGroup.GoldLevels[i], int.Parse(levelGroup.Id), levelGroup.boardBackgroundImage);
                    uniqueGoldIDs.Add(levelGroup.GoldLevels[i].UniqueID);
                    goldCardScripts.Add(activeGoldLevelCard);
                }
            }
            else
            {
                return;
            }
        }
Пример #2
0
        public static void CreateLevelGroups()
        {
            List <int> collectionSizes = new List <int> {
                6, 9, 12, 15, 18, 18, 21, 18, 21, 21, 21, 21, 21, 24, 27, 27, 27, 27, 24, 27, 27, 27, 30, 30, 30, 30, 39, 39, 39, 39, 39, 39
            };

            LevelOrderSettings levelOrder = (LevelOrderSettings)AssetDatabase.LoadAssetAtPath("Assets/" + GameConstants.GameName.NameOfGame + "/Settings/LevelOrder/LevelOrder.asset", typeof(LevelOrderSettings));
            int levelNumber = 0;

            // make level group assets
            for (int i = 1; i < (collectionSizes.Count + 1); i++) // needs to be one more than number of collections
            {
                string name = "Assets/" + GameConstants.GameName.NameOfGame + "/Settings/LevelGroupings/LevelGroup" + i + ".asset";

                Sprite levelCard      = (Sprite)AssetDatabase.LoadAssetAtPath("Assets/" + GameConstants.GameName.NameOfGame + "/Textures/Icons/Level card icons/QXALUIBlurredPhoto" + i + ".png", typeof(Sprite));
                Sprite background     = (Sprite)AssetDatabase.LoadAssetAtPath("Assets/" + GameConstants.GameName.NameOfGame + "/Textures/Backgrounds/QXALUIBackground" + i + ".png", typeof(Sprite));
                Sprite backgroundMain = (Sprite)AssetDatabase.LoadAssetAtPath("Assets/" + GameConstants.GameName.NameOfGame + "/Textures/Backgrounds/QXALUIBackgroundMain" + i + ".png", typeof(Sprite));

                AssertExistingAsset(name);

                LevelGroupingSettings newLevelGroupSettings = ScriptableObject.CreateInstance("LevelGroupingSettings") as LevelGroupingSettings;
                newLevelGroupSettings.Init(i.ToString(), false, levelCard, background, backgroundMain);

                for (int j = 0; j < collectionSizes[i - 1]; j++)
                {
                    if (!levelOrder.RuleSettings[levelNumber + j].IsGold)
                    {
                        newLevelGroupSettings.Levels.Add(levelOrder.RuleSettings[levelNumber + j]);
                    }
                    else
                    {
                        newLevelGroupSettings.GoldLevels.Add(levelOrder.RuleSettings[levelNumber + j]);
                    }
                }

                string     suffix = GetPrefabSuffix(newLevelGroupSettings.Levels.Count, newLevelGroupSettings.GoldLevels.Count);
                GameObject prefab = (GameObject)AssetDatabase.LoadAssetAtPath("Assets/" + GameConstants.GameName.NameOfGame + "/Prefabs/CollectionWindows/Collection-" + suffix + ".prefab", typeof(GameObject));
                newLevelGroupSettings.CollectionPrefab = prefab;

                levelNumber += collectionSizes[i - 1];

                AssetDatabase.CreateAsset(newLevelGroupSettings, name);
                AssetDatabase.SaveAssets();
            }
        }
Пример #3
0
        // called immediately when puzzle is solved
        public void RecordLevelCompletion(MainGameData gameData)
        {
            if (!gameData.Replay)
            {
                player.MainPuzzleIndex++;
                LevelGroupingSettings levelGroupingSettings = globalSettings.levelGroupingSettings[player.GroupIndex];

                int nextLevelID = player.CurrentLevelInGroupIndex + 1;

                if (levelGroupingSettings.Levels.ElementAtOrDefault(nextLevelID) == null)
                {
                    // collection complete - move group on
                    if (player.GroupIndex < globalSettings.levelGroupingSettings.Length - 1)
                    {
                        if (levelGroupingSettings.GoldLevels.Count > 0)
                        {
                            player.MainPuzzleIndex += levelGroupingSettings.GoldLevels.Count;
                        }

                        player.GroupIndex++;
                        player.CurrentLevelInGroupIndex = 0;
                        player.NewLocation = true;
                        globalSettings.levelGroupingSettings[player.GroupIndex].Locked = false;

                        SceneActivationBehaviour <CollectionScreenActivator> .Instance.ShowCollectionEvent(CollectionScreenActivator.CollectionEvent.NewLocationUnlocked, player);

                        InterfaceController.Instance.Show(GameWindow.PostGameScene);
                        SceneActivationBehaviour <PostGameSceneActivator> .Instance.ShowBoardPostGame(gameData, nextCollectionUnlocked : true);
                    }
                    else
                    {
                        player.GameComplete     = true;
                        player.MainPuzzleIndex += levelGroupingSettings.GoldLevels.Count;

                        SceneActivationBehaviour <CollectionScreenActivator> .Instance.ShowCollectionEvent(CollectionScreenActivator.CollectionEvent.GameComplete);

                        InterfaceController.Instance.Show(GameWindow.PostGameScene);
                        SceneActivationBehaviour <PostGameSceneActivator> .Instance.ShowBoardPostGame(gameData);
                    }
                }
                else
                {
                    player.CurrentLevelInGroupIndex++;

                    if (player.GroupIndex > 0)
                    {
                        SceneActivationBehaviour <CollectionScreenActivator> .Instance.ShowCollectionEvent(CollectionScreenActivator.CollectionEvent.NextLevelInOrderComplete);
                    }

                    InterfaceController.Instance.Show(GameWindow.PostGameScene);
                    SceneActivationBehaviour <PostGameSceneActivator> .Instance.ShowBoardPostGame(gameData);
                }
            }
            else
            {
                InterfaceController.Instance.Show(GameWindow.PostGameScene);
                SceneActivationBehaviour <PostGameSceneActivator> .Instance.ShowBoardPostGame(gameData);
            }

            PlayerProgressStringBuilder.Instance.RemakePlayerProgressString(gameData);

            ReviewRequestScript.TryRequestReview(player, gameData.StarScore.Equals(3));
        }