コード例 #1
0
ファイル: HomeController.cs プロジェクト: hanniiel/unityhome
    void InstantiatePainting(GameObject prefabCard)
    {
        for (int i = 0; i < 5; i++)
        {
            var card   = Instantiate(prefabCard);
            var script = card.GetComponent <CardUIControl>();
            script.button.onClick.AddListener(OnClick_Paint);
            script.gradient.EffectGradient.SetKeys(currentGradient.colorKeys, currentGradient.alphaKeys);
            projectCards[i.ToString()] = script;
            horizontalScrollSnap.AddChild(card);
        }

        infiniteScroll.Init();
    }
コード例 #2
0
ファイル: LevelSelectScript.cs プロジェクト: mwalden/mastrog
    void Start()
    {
        panels = new List <GameObject> ();

        levels = LevelManager.Instance.getLevels();

        foreach (LevelDetail level in levels)
        {
            GameObject panel = Instantiate(levelSelectPrefab, new Vector3(0, 0, 10), Quaternion.identity) as GameObject;
            panel.GetComponentInChildren <Text> ().text = level.title;
            Sprite sprite = Resources.Load <Sprite> ("images/" + level.backgroundImage);
            panel.GetComponent <Image> ().sprite = sprite;
            scroll.AddChild(panel);
        }
        PlayMusic(0);
    }
コード例 #3
0
    private new void Start()
    {
        base.Start();

        var list = GameObject.FindGameObjectsWithTag("Tracker Behaviour");

        foreach (var item in list)
        {
            _trackers.Add(item.GetComponent <TrackerBehaviour>());

            var trackerItem = Instantiate(itemPrefab);
            trackerItem.transform.GetChild(0).GetComponent <Text>().text = item.name;
            horizontalScrollSnap.AddChild(trackerItem);
        }

        CurrentTracker = 0;
    }
コード例 #4
0
    public void SetupObjectPool()
    {
        string[] videos      = App.GetProjects();
        int      allVideos   = videos.Length;
        int      totalVideos = videos.Length + 1;

        int requiredPages = Mathf.CeilToInt((float)totalVideos / (float)videosPerPage);

        Debug.Log("Required Pages is " + requiredPages);

        // Let's first setup the required pages
        for (int p = 0; p < requiredPages; p++)
        {
            var page = Instantiate(videoPageTemplate, transform, false);
            scrollSnap.AddChild(page, false);
            page.SetActive(true);
            videoPagePool.Add(page);
        }

        // Now it's time to instantiate our videos
        int videosHandled = 0;
        int currentPage   = 0;

        for (int i = 0; i < allVideos; i++)
        {
            // Everytime we enter, check to see if our last page is full.
            if (videosHandled == videosPerPage)
            {
                videosHandled = 0;
                currentPage++;
            }

            //Instantiate the current video under a given page starting at 0;
            var videoProject = Instantiate(videoProjectTemplate, videoPagePool[currentPage].transform, false);
            videoProject.gameObject.SetActive(false);
            videoProjectPool.Add(videoProject.GetComponent <VideoProjectButton>());

            // Increment the amount of videos we've put in the current page
            videosHandled++;
        }
    }
コード例 #5
0
    public void Initialize(Equipment equipment, CollectionPreviewer collectionPreviewer)
    {
        _equipment = equipment;

        CollectionItemSelectionHandler = new CollectionItemSelectionHandler(_inventory, _toggleGroup,
                                                                            _equipmentSlot, equipment, collectionPreviewer);
        CollectionPurchaseController = new CollectionPurchaseController();

        var idx = 0;

        foreach (var collectionPage in _collectionPages)
        {
            var p = idx;
            _scrollSnap.AddChild(collectionPage.gameObject);
            _scrollSnap.OnSelectionPageChangedEvent.AddListener((page) =>
            {
                if (_equipmentSlot != "Trail")
                {
                    if (page == p)
                    {
                        collectionPage.OnFocused();
                    }
                    else
                    {
                        collectionPage.OnUnfocused();
                    }
                }
            });
            collectionPage.Initialize(CollectionItemSelectionHandler, CollectionPurchaseController);
            idx++;
        }

        var equippedItem = _equipment.GetItem(_equipmentSlot);

        //CollectionItemSelectionHandler.SelectItem(equippedItem);

        for (int i = 0; i < _paginations.Count; i++)
        {
            _paginations[i].gameObject.SetActive(i < _collectionPages.Count);
        }
    }
コード例 #6
0
    public void ShowCardsInCementery(List <int> aIdCards)
    {
        if (showCementery.activeSelf)
        {
            GameObject[] a;
            scroll.RemoveAllChildren(out a);
        }
        if (aIdCards.Count > 0)
        {
            showCementery.SetActive(true);

            for (int i = 0; i < aIdCards.Count; i++)
            {
                Card       card         = MatchController.instance.playerController.cards[aIdCards[i]];
                GameObject cardInstance = Instantiate(MatchController.instance.playerController.prefabCard[card.TypeCard], HandController.instance.transform.position, Quaternion.identity);
                cardInstance.GetComponent <CardController>().card = card;
                cardInstance.GetComponent <CardController>().DontDestroyCard();
                cardInstance.GetComponent <Dragg>().enabled = false;
                scroll.AddChild(cardInstance);
            }
        }
    }
コード例 #7
0
    public void ShowCardsPlayer()
    {
        List <int> idCardsPlayer = GameController.instance.idCardsPlayer;

        for (int i = 0; i < idCardsPlayer.Count; i++)
        {
            Card       card         = GameController.instance.gameCards[idCardsPlayer[i]];
            GameObject cardInstance = Instantiate(GameController.instance.prefabCard[card.TypeCard], transform.position, Quaternion.identity);
            cardInstance.GetComponent <CardController>().card = card;
            cardInstance.GetComponent <CardController>().DontDestroyCard();
            cardInstance.GetComponent <Dragg>().enabled = false;
            scrollCards.AddChild(cardInstance);
        }
        if (scrollCards.ChildObjects.Length >= 6)
        {
            scrollCards.StartingScreen = 3;
        }
        else
        {
            scrollCards.StartingScreen = scrollCards.ChildObjects.Length;
        }
    }