コード例 #1
0
    public void SpawnCocktails(Cocktail[] drinkToDisplay, Transform[] exceptionsInHorizontalMenu,
                               GameObject scrollContentHolder)
    {
        List <Transform> destroyExceptions = new List <Transform>();

        destroyExceptions.Clear();
        destroyExceptions.AddRange(exceptionsInHorizontalMenu.ToList());
        UtilsUI.DestroyContentsOf(scrollContentHolder.transform, destroyExceptions);

        for (int c = 0; c < drinkToDisplay.Length; c++)
        {
            // OPTION A Keeping the prefab connection
            GameObject drink = null;

#if UNITY_EDITOR
            drink = PrefabUtility.InstantiatePrefab(mainMenuCocktailPrefab) as GameObject;
            drink.transform.SetParent(scrollContentHolder.transform);
            drink.transform.localScale = Vector3.one;
#else
            // OPTION A Destroying the prefab connectioz
            drink = Instantiate(mainMenuCocktailPrefab, scrollContentHolder.transform);
#endif

            drink.transform.SetSiblingIndex(c + 1);
            drink.GetComponent <MainMenuCoctel>().Setup(drinkToDisplay[c]);
        }
    }
コード例 #2
0
ファイル: PlayersMenu.cs プロジェクト: guplem/DrinkAndPlay
    public void BuildPlayerList()
    {
        UtilsUI.DestroyContentsOf(contentsObject, elementsNotInPlayerList.ToList());

        bool allowRemoval = true;

        if (SectionManager.instance.section.minNumberOfPlayers > 0)
        {
            allowRemoval = CanAPlayerBeDisabledOrRemoved();
        }

        for (int p = 0; p < GameManager.instance.dataManager.GetPlayers().Count; p++)
        {
            List <Player> players  = GameManager.instance.dataManager.GetPlayers();
            Player        player   = players[p];
            GameObject    playerGo = Instantiate(playerPrefab, contentsObject);
            playerGo.transform.SetSiblingIndex(p + 5);



            playerGo.GetComponent <PlayerUI>().Setup(player, this, allowRemoval);
        }

        if (GameManager.instance.dataManager.lastSelectedSection != null)
        {
            playButton.interactable = GameManager.instance.dataManager.HaveEnoughEnabledPlayersFor(GameManager.instance.dataManager.lastSelectedSection);
            ShowPlayersDescription(GameManager.instance.dataManager.lastSelectedSection.minNumberOfPlayers);
        }
        else
        {
            ShowPlayersDescription(allowRemoval? -1 : SectionManager.instance.section.minNumberOfPlayers);
        }
    }
コード例 #3
0
    public void BuildModesListFor(Section section)
    {
        if (currentSection == section)
        {
            return;
        }

        modeStates = new bool[section.localizationFiles.Length];
        for (int modeState = 0; modeState < modeStates.Length; modeState++)
        {
            modeStates[modeState] = true;
        }


        UtilsUI.DestroyContentsOf(contentsObject, elementsNotInModeList.ToList());

        for (int m = 0; m < section.localizationFiles.Length; m++)
        {
            GameObject modeGo = Instantiate(modeMixModePrefab, contentsObject);
            modeGo.transform.SetSiblingIndex(m + 2);
            modeGo.GetComponent <LocalizationFileToggle>().Setup(this, section.localizationFiles[m], modeStates[m]);
        }

        currentSection = section;
    }
コード例 #4
0
ファイル: PlayersMenu.cs プロジェクト: guplem/DrinkAndPlay
    public void AddPlayer(string newPlayerName)
    {
        Player newPlayer = new Player(newPlayerName);

        if (!GameManager.instance.dataManager.CanAddPlayer(newPlayer))
        {
            return;
        }

        GameManager.instance.dataManager.AddPlayer(newPlayer);
        BuildPlayerList();

        addPlayerInputField.text = "";
        UtilsUI.ClearSelectedElement();
    }
コード例 #5
0
    public void GenerateMenu()
    {
        List <Transform> destroyExceptions = new List <Transform>();

        #region GAMES

        //Games
        //destroyExceptions.Add(horizontalMenuCocktails.transform);
        destroyExceptions.AddRange(exceptionsInVerticalMenu.ToList());
        UtilsUI.DestroyContentsOf(verticalScrollContentHolder.transform, destroyExceptions);

        GameObject doubleSection = null;
        for (int s = 0; s < sectionsToDisplay.Length; s++)
        {
            int childIndex = Math.Abs(((float)s) % 2f) < 0.01f ? 0 : 1;

            if (childIndex == 0)
            {
                // OPTION A Keeping the prefab connection
#if UNITY_EDITOR
                doubleSection = PrefabUtility.InstantiatePrefab(mainMenuSectionDoublePrefab) as GameObject;
                doubleSection.transform.SetParent(verticalScrollContentHolder.transform);
                doubleSection.transform.localScale = Vector3.one;
#else
                // OPTION B Destroying the prefab connection
                doubleSection = Instantiate(mainMenuSectionDoublePrefab, verticalScrollContentHolder.transform);
                doubleSection.transform.localScale = Vector3.one;
#endif
                doubleSection.transform.SetSiblingIndex(s / 2 + 1);
            }

            GameObject game = doubleSection.transform.GetChild(childIndex).gameObject;
            game.GetComponent <MainMenuSection>().Setup(sectionsToDisplay[s]);
        }

        if (sectionsToDisplay.Length % 2 != 0)
        {
            doubleSection.transform.GetChild(1).gameObject.SetActive(false);
        }

        #endregion


        //Cocktails
        SpawnCocktails(cocktailsToDisplay, exceptionsInHorizontalMenuCocktails, horizontalScrollContentHolderCocktails);
        SpawnCocktails(cubatasToDisplay, exceptionsInHorizontalMenuCubatas, horizontalScrollContentHolderCubatas);
    }