コード例 #1
0
ファイル: UI_LevelList.cs プロジェクト: Tezza48/DiscoKitty
    private void Start()
    {
        GameSaveData data = GameData.LoadData();

        for (int id = 0; id < LevelManager.Instance.levels.levels.Length; id++)
        {
            if (id > data.highestLevel + 1)
            {
                Instantiate(DummyButtonPrefab, transform);
                continue;
            }

            string levelName = LevelManager.Instance.levels.levels[id];

            UI_LevelButton newButton = Instantiate(LevelButtonPrefab, transform).GetComponent <UI_LevelButton>();
            newButton.parentElement = this;

            float completionTime = 0.0f;

            // get player's progress data
            if (data.levelData.ContainsKey(levelName))
            {
                completionTime = data.levelData[levelName].completionTime;
            }

            // Initialize the button with player's data too
            newButton.Init(id, completionTime);
            //newButton.transform.GetChild(0).GetComponent<Text>().text = (id+1).ToString();
        }
    }
コード例 #2
0
    private void Start()
    {
        timeSlider.value  = gameData.GetTimeLimit();
        scoreSlider.value = gameData.GetScoreLimit();

        List <BuildIndex> levels = LevelSelect.glitchBallClassicLevels;
        // TODO: Switch statement here that looks at GameData for game type enum and sets the appropriate levels

        bool defaultFound = false;

        foreach (Button b in levelButtons)
        {
            UI_LevelButton script = b.GetComponent <UI_LevelButton>();
            script.SetManager(this);
            if (!defaultFound)
            {
                defaultSelectedLevelButton = b.gameObject;
                defaultFound = true;
            }
        }

        EventSystem.current.SetSelectedGameObject(defaultSelectedLevelButton);

        players = ReInput.players.AllPlayers;
        P1      = players[1]; // System is player 0
    }
コード例 #3
0
ファイル: MainMenu.cs プロジェクト: torybash/PainterMan
    private void InitLevelSelectPanel()
    {
        foreach (var item in levelButtonList)
        {
            if (item)
            {
                Destroy(item.gameObject);
            }
        }
        levelButtonList.Clear();

        for (int i = 0; i < LevelLibrary.I.GetLevelCount(); i++)
        {
            UI_LevelButton lvlBtn = Instantiate <UI_LevelButton>(levelButtonTemplate);
            lvlBtn.transform.SetParent(levelSelectGroup);
            lvlBtn.transform.localScale    = Vector3.one;
            lvlBtn.transform.localPosition = Vector3.zero;
            lvlBtn.gameObject.SetActive(true);

            int lvlIdx = i;
            lvlBtn.GetComponent <Button>().onClick.AddListener(() => ClickLevel(lvlIdx));
            lvlBtn.Init(i);
            levelButtonList.Add(lvlBtn);
        }
    }
コード例 #4
0
ファイル: UIManager.cs プロジェクト: pixelblue/paintMagic
    /// <summary>
    /// Creates all the level cards.
    /// </summary>
    public void createAllLevelCards()
    {
        //only create all the level cards if the level select panel is visible
        if (levelSelectPanelObj.activeInHierarchy == false)
        {
            return;
        }

        //first we make sure that there are no levelcards any more
        UI_LevelButton[] allExistingLevelButtons = levelCardContainer.GetComponentsInChildren <UI_LevelButton>(true);
        foreach (UI_LevelButton lb in allExistingLevelButtons)
        {
            Destroy(lb.gameObject);
        }

        //now create a level button for each level
        for (int i = 0; i < GameManager.Instance.allLevelSettings.Length; i++)
        {
            //instantiate the new card
            GameObject newLevelCard = Instantiate(levelCardPrefab, Vector3.zero, Quaternion.identity) as GameObject;

            //parent the new card to the container
            newLevelCard.transform.SetParent(levelCardContainer.transform);
            newLevelCard.transform.localScale    = Vector3.one;
            newLevelCard.transform.localPosition = new Vector3(newLevelCard.transform.position.x, newLevelCard.transform.position.y, 0.0f);

            //get the ui_levelButton script from it
            UI_LevelButton levelCardScript = newLevelCard.GetComponent <UI_LevelButton>();

            //set the settings
            levelCardScript.levelIndex = i;

            //set the container size
            GridLayoutGroup gridLayout      = levelCardContainer.GetComponent <GridLayoutGroup>();
            RectTransform   gridLayoutTrans = gridLayout.GetComponent <RectTransform>();
            float           scrollSize      = (gridLayout.cellSize.x + gridLayout.spacing.x) * GameManager.Instance.allLevelSettings.Length;
            gridLayoutTrans.sizeDelta = new Vector2(scrollSize, gridLayoutTrans.sizeDelta.y);

            //set the Container postition
            levelCardContainer.transform.localPosition = new Vector3(scrollSize / 2.0f, levelCardContainer.transform.localPosition.y, levelCardContainer.transform.localPosition.z);


            //set the locked if locked
            if (GameManager.Instance.allLevelSettings[i].isLocked)
            {
                levelCardScript.setToLocked();
            }
            else
            {
                //set the playable with collectible visible or not
                if (GameManager.Instance.allLevelSettings[i].hasCollectibleAchieved)
                {
                    levelCardScript.setToPlayable(true);
                }
                else
                {
                    levelCardScript.setToPlayable(false);
                }
            }
        }
    }