コード例 #1
0
    private void LoadRoomItem(List <UserData> udList)//加载房间
    {
        RoomItem[] riArray = roomLayout.GetComponentsInChildren <RoomItem>();
        foreach (RoomItem ri in riArray)
        {
            ri.DestroySelf();
        }


        int count = udList.Count;

        for (int i = 0; i < count; i++)
        {
            GameObject roomItem = GameObject.Instantiate(roomItemPrefab);
            roomItem.transform.SetParent(roomLayout.transform);
            UserData ud = udList[i];

            roomItem.GetComponent <RoomItem>().SetRoomInfo(ud.Id, ud.Username, ud.TotalCount, ud.WinCount, this);
        }
        //计算多少个子

        /*
         * int roomCount = roomLayout.GetComponentsInChildren<RoomItem>().Length;
         * Vector2 size = roomLayout.GetComponent<RectTransform>().sizeDelta;
         * roomLayout.GetComponent<RectTransform>().sizeDelta = new Vector2(size.x,
         *  (roomItemPrefab.GetComponent<RectTransform>().sizeDelta.y * roomCount)
         + (roomCount * roomLayout.spacing) - 420.4f
         +  );*/
        int     roomCount = roomLayout.GetComponentsInChildren <RoomItem>().Length;
        Vector2 size      = roomLayout.GetComponent <RectTransform>().sizeDelta;

        roomLayout.GetComponent <RectTransform>().sizeDelta = new Vector2(size.x,
                                                                          roomCount * (roomItemPrefab.GetComponent <RectTransform>().sizeDelta.y + roomLayout.spacing) - 420.4f);
    }
コード例 #2
0
    public void LoadRoomItem(List <UserData> udList)
    {
        //  Debug.Log("--------loadRoomItem-------");

        RoomItem [] riArray = roomList.GetComponentsInChildren <RoomItem>();

        foreach (RoomItem ri in riArray)
        {
            ri.DestorySelf();
        }

        int count = udList.Count;

        for (int i = 0; i < count; i++)
        {
            GameObject roomItem = GameObject.Instantiate(roomItemPrefab);
            roomItem.transform.SetParent(roomList.transform);
            UserData ud = udList[i];
            roomItem.GetComponent <RoomItem>().SetRoomInfo(ud.NickName, ud.RoomId, this);
        }

        int     roomCount = GetComponentsInChildren <RoomItem>().Length;
        Vector2 size      = roomListContent.sizeDelta;

        roomListContent.sizeDelta = new Vector2(size.x, roomCount * roomItemPrefab.GetComponent <RectTransform>().sizeDelta.y);
    }
コード例 #3
0
ファイル: RoomListPanel.cs プロジェクト: amcp9/ForestShooter
 private void EmptyRoomItem()
 {
     //清空原有房间
     RoomItem[] roomItems = layoutGroup.GetComponentsInChildren <RoomItem>();
     foreach (RoomItem r in roomItems)
     {
         r.DestroyItem();
     }
 }
コード例 #4
0
 public void Choice(int choice)
 {
     currentNode = ((ChoiceNode)dialogtree.dialogTree[currentNode]).GetNextBasedOnChoice(choice);
     readyNext   = true;
     for (int i = buttonHolder.GetComponentsInChildren <Button>().Length - 1; i >= 0; i--)
     {
         Destroy(buttonHolder.GetComponentsInChildren <Button>()[i].gameObject);
     }
 }
コード例 #5
0
 public void revisarCompletadas()
 {
     Toggle[] estados       = colCriteriosT.GetComponentsInChildren <Toggle>();
     Text[]   descripciones = colCriteriosT.GetComponentsInChildren <Text>();
     for (int i = 0; i < estados.Length; i++)
     {
         if (estados[i].isOn)
         {
             controlador.eliminarCriterioMinijuego(descripciones[i].text);
         }
     }
 }
コード例 #6
0
 public void ClearPanel()
 {
     foreach (Button button in buttonParent.GetComponentsInChildren <Button>())
     {
         Destroy(button.gameObject);
     }
 }
コード例 #7
0
    public void Setup()
    {
        ConstructionSiteUI[] children = ConstructionsContainer.GetComponentsInChildren <ConstructionSiteUI> ();

        foreach (ConstructionSiteUI child in children)
        {
            if (child != ConstructionsContainer.transform)
            {
                Destroy(child.gameObject);
            }
        }


        foreach (ConstructionSite site in BuildingManager.Instance.ReadySites)
        {
            ConstructionSiteUI siteUI = Instantiate(ConstructionSiteUI, ConstructionsContainer.transform);
            //site.ItemIcon.sprite = site.Building
            siteUI.NameText.text = site.Building.name + " - " + site.LevelName;
            siteUI.Site          = site;
            siteUI.ConfirmButton.onClick.AddListener(delegate {
                SelectConstructionSite(siteUI);
            });
        }

        GetComponent <WindowToggle> ().Toggle();
    }
コード例 #8
0
 private void ClearButtonLayout()
 {
     foreach (AbilityButton btn in abilityListLayout.GetComponentsInChildren <AbilityButton>())
     {
         Destroy(btn.gameObject);
     }
 }
コード例 #9
0
 public void ShowPersons(List <Personnel> personnelsT)
 {
     //如果在播放就让它终止
     ExecuteEvents.Execute <IPointerClickHandler>(StopBtn.gameObject, new PointerEventData(EventSystem.current), ExecuteEvents.pointerClickHandler);
     CreatePersons(personnelsT);
     items = new List <HistoryPersonUIItem>(personsGrid.GetComponentsInChildren <HistoryPersonUIItem>());
 }
コード例 #10
0
ファイル: RoomListPanel.cs プロジェクト: fctony/ForestWar
    /// <summary>
    /// 加载房间列表
    /// </summary>
    private void LoadRoomList(List <UserData> userDataList)
    {
        //在加载房间列表之前先清空列表,防止重复加载
        RoomItem[] roomItems = roomLayout.GetComponentsInChildren <RoomItem>();
        //逐个调用销毁自身的方法
        foreach (RoomItem roomItem in roomItems)
        {
            roomItem.DestorySelf();
        }

        foreach (UserData userData in userDataList) //逐个创建房间信息对象,并添加到房间列表布局中
        {
            GameObject roomItem = GameObject.Instantiate(roomItemPrefab);
            roomItem.transform.SetParent(roomLayout.transform);
            //逐个设置房间信息
            roomItem.GetComponent <RoomItem>().SetRoomItemInfo(userData.Id, userData.Username, userData.TotalCount, userData.WinCount, this);
        }

        //获取所有子物体中RoomItem对象的个数,即房间个数
        int roomCount = GetComponentsInChildren <RoomItem>().Length;
        //房间列表原来的大小
        Vector2 size = roomLayout.GetComponent <RectTransform>().sizeDelta;
        //单个房间信息框的高度
        float roomItemHeight = roomItemPrefab.GetComponent <RectTransform>().sizeDelta.y;

        //重新设置房间列表的长度,新的长度等于所有房间信息的个数×(一个roomItem的高度+两个roomItem之间的间隙)
        roomLayout.GetComponent <RectTransform>().sizeDelta = new Vector2(size.x, roomCount * (roomItemHeight + roomLayout.spacing));
    }
コード例 #11
0
    public void Setup(List <BuildingMaterial> pMaterials, ConstructionSite pSite)
    {
        Site = pSite;
        ConfirmButton.interactable = true;

        SupplySlotUI[] children = ItemsContainer.GetComponentsInChildren <SupplySlotUI>();

        foreach (SupplySlotUI child in children)
        {
            if (child != ItemsContainer.transform)
            {
                Destroy(child.gameObject);
            }
        }

        foreach (BuildingMaterial material in pMaterials)
        {
            InventoryItemStack boxStack = Site.Box.FindItemStack(material.ContainedItem);
            int amount = 0;
            if (boxStack != null)
            {
                amount = boxStack.Amount;
            }
            SupplySlotUI slot = Instantiate(SlotUI, ItemsContainer.transform);
            slot.ItemIcon.sprite = material.ContainedItem.Icon;
            slot.NameText.text   = material.ContainedItem.Name;
            slot.AmountText.text = amount + "/" + material.TargetAmount;
            if (boxStack == null || boxStack.Amount < material.TargetAmount)
            {
                ConfirmButton.interactable = false;
            }
        }

        GetComponent <WindowToggle>().Toggle();
    }
コード例 #12
0
    private void LoadRoomItem(List <UserData> udList)
    {
        // 加载之前先进行清空操作 防止重复加载 得到roomLayout下的所有子物体
        RoomItem[] riArray = roomLayout.GetComponentsInChildren <RoomItem>();
        foreach (RoomItem ri in riArray)
        {
            ri.DestroySelf(); // 所有roomItem现存的物体销毁掉
        }

        int count = udList.Count;

        for (int i = 0; i < count; i++)
        {
            // 实例化后放在布局下
            GameObject roomItem = GameObject.Instantiate(roomItemPrefab);
            roomItem.transform.SetParent(roomLayout.transform);
            UserData ud = udList[i];
            roomItem.GetComponent <RoomItem>().SetRoomInfo(ud.Id, ud.Username,
                                                           ud.TotalCount, ud.WinCount, this);
        }

        // 设置房间列表高度
        // 得到子物体的个数
        int roomCount = GetComponentsInChildren <RoomItem>().Length;
        // 得到原有的size
        Vector2 size = roomLayout.GetComponent <RectTransform>().sizeDelta;

        // 房间个数乘以房间自身高度 需要加上房间与房间之间的间隔
        roomLayout.GetComponent <RectTransform>().sizeDelta = new Vector2(size.x,
                                                                          roomCount * (roomItemPrefab.GetComponent <RectTransform>().sizeDelta.y + roomLayout.spacing));
    }
コード例 #13
0
    private void DisplayChoices()
    {
        // check if choices are already being displayed
        if (_choiceButtonContainer.GetComponentsInChildren <Button>().Length > 0)
        {
            return;
        }

        for (int i = 0; i < _story.currentChoices.Count; i++)
        {
            var choice = _story.currentChoices[i];
            var button = CreateChoiceButton(choice.text);

            button.onClick.AddListener(() => OnClickChoiceButton(choice));
        }
    }
コード例 #14
0
 private void ClearCurrentRoomItems()
 {
     RoomItem[] riArray = roomLayout.GetComponentsInChildren <RoomItem>();
     foreach (RoomItem ri in riArray)
     {
         ri.DestroySelf();
     }
 }
コード例 #15
0
 void Start()
 {
     GameController.OnGameStart += OnGameStart;
     GameController.OnGameOver  += OnGameOver;
     GameController.OnPause     += OnPause;
     GameController.OnMainMenu  += OnMainMenu;
     _buttons = buttonsLayoutGroup.GetComponentsInChildren <Button>();
 }
コード例 #16
0
        private void OnScoreUpdate(object sender, IGameEvent gameEvent)
        {
            try {
                // since the score update is made by the player, the sender of this event should be the player
                Player player = (Player)sender;

                PlayerUIController[] playerUIControllers = _playerGridGroup.GetComponentsInChildren <PlayerUIController>();
                if (playerUIControllers != null && playerUIControllers.Length > 0)
                {
                    PlayerUIController playerUIController = playerUIControllers.FirstOrDefault(p => p.name.Equals(player.Name));
                    playerUIController.NameNScore.text = player.Name + " " + player.Score;
                }
            }
            catch (Exception)
            {
            }
        }
コード例 #17
0
        public void FreeTemporaryUiElements()
        {
            IEnumerable <GameObject> statusesToFree = _statusesGroup.GetComponentsInChildren <Image>().Select(i => i.gameObject);

            foreach (GameObject statusObject in statusesToFree)
            {
                PoolingManager.Free(PoolingManager.StatusImage, statusObject);
            }
        }
コード例 #18
0
    private void RemoveCurrentButtons()
    {
        var existingButtons = responseOptionWrapper.GetComponentsInChildren <ResponseButton>();

        foreach (var button in existingButtons)
        {
            Destroy(button.gameObject);
        }

        this.responseButtons = new List <Button>();
    }
コード例 #19
0
        public void Enable(City city, Building building, GUIMaster gui)
        {
            //this.city = city;
            this.building = building;
            this.gui      = gui;

            // Clear lists
            foreach (VerticalLayoutGroup districtPanel in districtList.GetComponentsInChildren <VerticalLayoutGroup>())
            {
                if (districtPanel.gameObject.name != "District List")
                {
                    Destroy(districtPanel.gameObject);
                }
            }

            // Load all districts
            // Foreach instantiate district panel prefab
            for (int i = 0; i < city.Districts.Count; i++)
            {
                District            district      = city.Districts[i];
                VerticalLayoutGroup districtPanel = Instantiate(districtPanelPrefab);
                districtPanel.transform.SetParent(districtList.transform);
                districtPanel.GetComponentInChildren <Text>().text = district.Name;
                Button districtButton = districtPanel.GetComponentInChildren <Button>();
                districtButton.onClick.AddListener(() => SelectDistrict(district, districtButton));

                // Load building slots
                // Foreach instantiate building slot prefab
                VerticalLayoutGroup slotList = districtPanel.GetComponentsInChildren <VerticalLayoutGroup>()[1];
                slotList.gameObject.SetActive(true);
                foreach (Building b in district.Buildings)
                {
                    RectTransform slot = Instantiate(buildingSlotPrefab);
                    string        name = "Empty";
                    if (b != null)
                    {
                        name = b.ID; // TODO: Change to building.Name
                    }
                    slot.GetComponentInChildren <Text>().text = name;
                    slot.SetParent(slotList.transform);
                }

                if (district.Buildings.Count == 0)
                {
                    slotList.gameObject.SetActive(false);
                }
            }

            confirmButton.interactable = false;
            gameObject.SetActive(true);
        }
コード例 #20
0
    private void FillHigscore()
    {
        List <Highscore> highscores = HighscoreFacade.FindBest10();

        //Debug.Log(Facade<Highscore>.ToStringAll());

        int count = highscores.Count <= 10 ? highscores.Count : 10;

        for (int i = 0; i < count; i++)
        {
            Names.GetComponentsInChildren <Text>()[i].text  = highscores[i].Name;
            Scores.GetComponentsInChildren <Text>()[i].text = highscores[i].Score.ToString();
        }
    }
コード例 #21
0
    public void Clear()
    {
        if (!content)
        {
            return;
        }

        ComboboxEntry[] entries = content.GetComponentsInChildren <ComboboxEntry>();

        foreach (ComboboxEntry entry in entries)
        {
            Destroy(entry.gameObject);
        }
    }
コード例 #22
0
    public void cambiarAltura()
    {
        float altura = 0;

        Text[] hijos = alturaACopiar.GetComponentsInChildren <Text>(false);
        foreach (Text hijo in hijos)
        {
            altura += hijo.gameObject.transform.localScale.y;
        }
        contenidoAModificar.transform.localScale = new Vector3
                                                       (contenidoAModificar.transform.localScale.x,
                                                       altura,
                                                       contenidoAModificar.transform.localScale.z);
    }
コード例 #23
0
        public IEnumerator DrawOnLockedMenu()
        {
            var gatherInfoButton = CreateButtonInLayout("gatherInfo");
            var hackButton       = CreateButtonInLayout("hack");

            gatherInfoButton.onClick.AddListener(() => StartCoroutine(DrawText($"key {Context.key} model {Context.model}")));

            yield return(new WaitForSeconds(0.5f));

            yield return(new WaitUntil(() => _playerInstance.State != PlayerState.DoingNothing));

            var btns = buttonsLayout.GetComponentsInChildren <Button>();

            foreach (var btn in btns)
            {
                Destroy(btn.gameObject);
            }
        }
コード例 #24
0
    public void UpdateShow(List <KeyValuePair <float, float> > personalList, List <float> allPersonList)
    {
        var deleteList = _layout.GetComponentsInChildren <Transform>();

        for (int i = 0; i < deleteList.Count(); i++)
        {
            if (deleteList[i] == _layout.transform)
            {
                continue;
            }

            GameObject.Destroy(deleteList[i].gameObject);
        }

        UpdatePersonal(personalList);
        UpdatePublic(allPersonList);

        StartCoroutine(UpadteHeight());
    }
コード例 #25
0
    private void LoadRoomItem(List <Room> roomList)
    {
        RoomItem[] riArray = roomLayout.GetComponentsInChildren <RoomItem>();
        foreach (RoomItem ri in riArray)
        {
            ri.DestroySelf();
        }
        int count = roomList.Count;

        for (int i = 0; i < count; i++)
        {
            GameObject roomItem = Instantiate(roomItemPrefab);
            roomItem.transform.SetParent(roomLayout.transform);
            Room room = roomList[i];
            roomItem.GetComponent <RoomItem>().SetRoomInfo(room, this);
        }
        //int roomCount = GetComponentsInChildren<RoomItem>().Length;
        //Vector2 size = roomLayout.GetComponent<RectTransform>().sizeDelta;
        //roomLayout.GetComponent<RectTransform>().sizeDelta = new Vector2(size.x, roomCount * roomItemPrefab.GetComponent<RectTransform>().sizeDelta.y + roomLayout.spacing * Mathf.Max(0, roomCount - 1));
    }
コード例 #26
0
    public void LoadRoomItem(List <UserData> userdata)
    {
        RoomItem[] riArray = Layout.GetComponentsInChildren <RoomItem>();
        foreach (RoomItem ri in riArray)
        {
            ri.DestroySelf();
        }
        for (int i = 0; i < userdata.Count; i++)
        {
            GameObject roomitem = Instantiate(roomItem);

            roomitem.transform.parent = Layout.transform;
            RoomItemList.Add(roomitem.GetComponent <RoomItem>());
            roomitem.GetComponent <RoomItem>().SetRoomInfo(userdata[i], this);
            roomitem.transform.localScale = Vector3.one;
        }
        int     roomcount = GetComponentsInChildren <RoomItem>().Length;
        Vector2 size      = Layout.GetComponent <RectTransform>().sizeDelta;

        Layout.GetComponent <RectTransform>().sizeDelta = new Vector2(size.x, roomcount * (roomItem.GetComponent <RectTransform>().sizeDelta.y + Layout.spacing));
    }
コード例 #27
0
    private void SetInstalledComponents(IDictionary <Components.ItemName, int> installedItems, IDictionary <Components.ItemName, GameObject> itemPrefabs)
    {
        ItemInstallSlot[] leftList  = leftWeaponPanel.GetComponentsInChildren <ItemInstallSlot>();
        ItemInstallSlot[] rightList = rightWeaponPanel.GetComponentsInChildren <ItemInstallSlot>();

        int leftCounter  = 0;
        int rightCounter = 0;
        int bodyCounter  = 0;

        foreach (KeyValuePair <Components.ItemName, int> item in installedItems)
        {
            if (availableWeapon.Contains(item.Key))
            {
                for (int i = 0; i < item.Value; ++i)
                {
                    Transform weaponSlot = null;
                    if (leftCounter < leftList.Length)
                    {
                        weaponSlot = leftList[leftCounter].transform;
                        leftCounter++;
                    }
                    else if (rightCounter < rightList.Length)
                    {
                        weaponSlot = rightList[rightCounter].transform;
                        rightCounter++;
                    }
                    Instantiate(itemPrefabs[item.Key], weaponSlot);
                }
            }
            else if (availableBody.Contains(item.Key))
            {
                for (int i = 0; i < item.Value; ++i)
                {
                    Transform bodySlot = bodyPanel.transform.GetChild(bodyCounter).transform;
                    Instantiate(itemPrefabs[item.Key], bodySlot);
                    bodyCounter++;
                }
            }
        }
    }
コード例 #28
0
ファイル: RoomListPanel.cs プロジェクト: yleen/Penny
    private void LoadRoomItem(List <UserData> userList)
    {
        RoomItem[] ri = layoutGroup.GetComponentsInChildren <RoomItem>();
        foreach (RoomItem item in ri)
        {
            item.ChangeColor();
        }

        int count = userList.Count;

        for (int i = 0; i < count; i++)
        {
            GameObject roomItem = GameObject.Instantiate(roomItemPrefab);
            roomItem.transform.SetParent(layoutGroup.transform);
            UserData ud = userList[i];
            roomItem.GetComponent <RoomItem>().SetRoomInfor(ud.UserId, ud.UserName, ud.TotalCount, ud.WinCount, this);
        }
        int     roomCount = GetComponentsInChildren <RoomItem>().Length;
        Vector2 group     = layoutGroup.GetComponent <RectTransform>().sizeDelta;

        layoutGroup.GetComponent <RectTransform>().sizeDelta = new Vector2(group.x, roomCount * (roomItemPrefab.GetComponent <RectTransform>().sizeDelta.y + layoutGroup.spacing));
    }
コード例 #29
0
        public void DisplayActions()
        {
            // Clear action menu
            foreach (Button btn in actionMenu.GetComponentsInChildren <Button>())
            {
                Destroy(btn.gameObject);
            }

            // Fill action menu
            foreach (ItemAction action in item.GetItemActions())
            {
                Button btn = Instantiate(actionButtonPrefab);
                btn.transform.SetParent(actionMenu.transform);
                btn.GetComponentInChildren <Text>().text = action.Name;
                btn.interactable = action.Enabled;
                btn.onClick.AddListener(() => action.Action(actor));
                btn.onClick.AddListener(() => actionMenu.gameObject.SetActive(false));
                btn.onClick.AddListener(() => inventoryPanel.SetActive(false));
            }
            actionMenu.transform.position = Input.mousePosition;
            actionMenu.gameObject.SetActive(true);
        }
コード例 #30
0
    private void LoadRoomItem(List <UserData> udList)                         //列每個房間RoomItem到列表上,同時載入UserData
    {
        RoomItem[] riArray = roomLayout.GetComponentsInChildren <RoomItem>(); //抓到垂直的Layout下的子層(RoomItem)
        foreach (RoomItem ri in riArray)
        {
            ri.DestroySelf();     //陣列內每個項目都摧毀
        }
        int count = udList.Count; //依據udList.Count數量,重新載入

        for (int i = 0; i < count; i++)
        {
            GameObject roomItem = GameObject.Instantiate(roomItemPrefab);                                                                                                //載入房間的Prefab
            roomItem.transform.SetParent(roomLayout.transform);                                                                                                          //設置房間的父層,父層是垂直的Layout
            UserData ud = udList[i];
            roomItem.GetComponent <RoomItem>().SetRoomInfo(ud.Id, ud.Username, ud.TotalCount, ud.WinCount, this);                                                        //設置房間資訊
        }
        int     roomCount = GetComponentsInChildren <RoomItem>().Length;                                                                                                 //抓到RoomItem數目
        Vector2 size      = roomLayout.GetComponent <RectTransform>().sizeDelta;                                                                                         //抓取垂直Layout的長度

        roomLayout.GetComponent <RectTransform>().sizeDelta = new Vector2(size.x,                                                                                        //重新設置roomLayout長度,因為多增加房間項目,Layout也得變長
                                                                          roomCount * (roomItemPrefab.GetComponent <RectTransform>().sizeDelta.y + roomLayout.spacing)); //RoomItem數目 * (一個房間在列表所需的長度+spacing)
    }