Ejemplo n.º 1
0
    private void EditLevelInfo(string levelName, bool levelLocked, Level.LevelStars rating, Level.LevelGems gems, int gemsAcquired)
    {
        if (levelText.text != levelName)
        {
            levelText.text = levelName;
        }

        if (levelLock.activeSelf != levelLocked)
        {
            levelLock.SetActive(levelLocked);
        }

        switch (rating)
        {
        case Level.LevelStars.ZERO:
            for (int i = 0; i < levelStarIMGs.Length; i++)
            {
                if (levelStarIMGs[i].enabled)
                {
                    levelStarIMGs[i].enabled = false;
                }
            }
            break;

        case Level.LevelStars.Star1:
            for (int i = 0; i < levelStarIMGs.Length; i++)
            {
                if (i < levelStarIMGs.Length - 2)
                {
                    if (!levelStarIMGs[i].enabled)
                    {
                        levelStarIMGs[i].enabled = true;
                    }
                }
                else
                {
                    if (levelStarIMGs[i].enabled)
                    {
                        levelStarIMGs[i].enabled = false;
                    }
                }
            }
            break;

        case Level.LevelStars.Star2:
            for (int i = 0; i < levelStarIMGs.Length; i++)
            {
                if (i < levelStarIMGs.Length - 1)
                {
                    if (!levelStarIMGs[i].enabled)
                    {
                        levelStarIMGs[i].enabled = true;
                    }
                }
                else
                {
                    if (levelStarIMGs[i].enabled)
                    {
                        levelStarIMGs[i].enabled = false;
                    }
                }
            }
            break;

        case Level.LevelStars.Star3:
            for (int i = 0; i < levelStarIMGs.Length; i++)
            {
                if (!levelStarIMGs[i].enabled)
                {
                    levelStarIMGs[i].enabled = true;
                }
            }
            break;
        }

        switch (gems)
        {
        case Level.LevelGems.NONE:
            if (levelGems.activeSelf)
            {
                levelGems.SetActive(false);
            }
            break;

        case Level.LevelGems.Gem1:
            if (!levelGems.activeSelf)
            {
                levelGems.SetActive(true);
            }

            for (int i = 0; i < levelGemIMGs.Length; i++)
            {
                if (i == 0)
                {
                    if (!levelGemIMGs[i].gameObject.activeSelf)
                    {
                        levelGemIMGs[i].gameObject.SetActive(true);
                    }

                    levelGemIMGs[i].enabled = gemsAcquired > 0;
                }
                else
                {
                    if (levelGemIMGs[i].gameObject.activeSelf)
                    {
                        levelGemIMGs[i].gameObject.SetActive(false);
                    }
                }
            }
            break;

        case Level.LevelGems.Gem2:
            if (!levelGems.activeSelf)
            {
                levelGems.SetActive(true);
            }

            for (int i = 0; i < levelGemIMGs.Length; i++)
            {
                if (i < levelGemIMGs.Length - 1)
                {
                    if (!levelGemIMGs[i].gameObject.activeSelf)
                    {
                        levelGemIMGs[i].gameObject.SetActive(true);
                    }

                    levelGemIMGs[i].enabled = gemsAcquired > i;
                }
                else
                {
                    if (levelGemIMGs[i].gameObject.activeSelf)
                    {
                        levelGemIMGs[i].gameObject.SetActive(false);
                    }
                }
            }
            break;

        case Level.LevelGems.Gem3:
            if (!levelGems.activeSelf)
            {
                levelGems.SetActive(true);
            }

            for (int i = 0; i < levelGemIMGs.Length; i++)
            {
                if (!levelGemIMGs[i].gameObject.activeSelf)
                {
                    levelGemIMGs[i].gameObject.SetActive(true);
                }
                levelGemIMGs[i].enabled = gemsAcquired > i;
            }
            break;
        }

        if (Preview != null)
        {
            if (Preview.LevelImage != LevelImages[levelIndex - 1])
            {
                Preview.LevelImage = LevelImages[levelIndex - 1];
            }

            if (LevelInformation.Levels[levelIndex].levelLocked)
            {
                if (!Preview.LevelPreviewLock.activeSelf)
                {
                    Preview.LevelPreviewLock.SetActive(true);
                }
            }
            else
            {
                if (Preview.LevelPreviewLock.activeSelf)
                {
                    Preview.LevelPreviewLock.SetActive(false);
                }
            }
        }
        else
        {
            string response = Preview.LevelImage ? "Level img is NOT null" : "Level img is null";
            Debug.Log($"CurrentLevelImage = {response}. --- LevelImage = Level{levelIndex}.");
        }

        for (int i = 0; i < SmallLVLButtons.Length; i++)
        {
            if (i != levelIndex - 1)
            {
                SmallLVLButtons[i].ButtonOutline.enabled = false;
            }
            else
            {
                if (!SmallLVLButtons[i].ButtonOutline.enabled)
                {
                    SmallLVLButtons[i].ButtonOutline.enabled = true;
                }
            }

            SmallLVLButtons[i].ButtonLockIcon.enabled = LevelInformation.Levels[i + 1].levelLocked;
            //CurrentLevelImage.gameObject.
        }
    }
Ejemplo n.º 2
0
    private void AdjustGems(Level.LevelGems gems, GameObject lvlGems, Image[] gemImages)
    {
        switch (gems)
        {
        case Level.LevelGems.NONE:
            if (lvlGems.activeSelf)
            {
                lvlGems.SetActive(false);
            }
            break;

        case Level.LevelGems.Gem1:
            if (!lvlGems.activeSelf)
            {
                lvlGems.SetActive(true);
            }

            for (int i = 0; i < gemImages.Length; i++)
            {
                if (i == 0)
                {
                    if (!gemImages[i].gameObject.activeSelf)
                    {
                        gemImages[i].gameObject.SetActive(true);
                    }

                    gemImages[i].enabled = GameManager.GemsAcquired > i;
                }
                else
                {
                    if (gemImages[i].gameObject.activeSelf)
                    {
                        gemImages[i].gameObject.SetActive(false);
                    }
                }
            }
            break;

        case Level.LevelGems.Gem2:
            if (!lvlGems.activeSelf)
            {
                lvlGems.SetActive(true);
            }

            for (int i = 0; i < gemImages.Length; i++)
            {
                if (i < gemImages.Length - 1)
                {
                    if (!gemImages[i].gameObject.activeSelf)
                    {
                        gemImages[i].gameObject.SetActive(true);
                    }

                    gemImages[i].enabled = GameManager.GemsAcquired > i;
                }
                else
                {
                    if (gemImages[i].gameObject.activeSelf)
                    {
                        gemImages[i].gameObject.SetActive(false);
                    }
                }
            }
            break;

        case Level.LevelGems.Gem3:
            if (!lvlGems.activeSelf)
            {
                lvlGems.SetActive(true);
            }

            for (int i = 0; i < gemImages.Length; i++)
            {
                if (!gemImages[i].gameObject.activeSelf)
                {
                    gemImages[i].gameObject.SetActive(true);
                }

                gemImages[i].enabled = GameManager.GemsAcquired > i;
            }
            break;
        }
    }