示例#1
0
        public void MoveToIndex(int index, float delay)
        {
            if (index < 0 || index > Num - 1)
            {
                throw new Exception("需要定位的位置错误:" + index);
            }

            index = Math.Min(index, Num - GetShowCount() + 2);
            index = Math.Max(0, index);

            var     rect = Grid.GetComponent <RectTransform>();
            Vector2 pos  = rect.anchoredPosition;

            Vector2 V2Pos;

            if (Scroll.horizontal)
            {
                V2Pos = new Vector2(-GetPos(index), rect.anchoredPosition.y);
            }
            else
            {
                V2Pos = new Vector2(rect.anchoredPosition.x, -GetPos(index));
            }

            m_Coroutine = StartCoroutine(TweenMoveToPos(pos, V2Pos, delay));
        }
示例#2
0
    public void DisplayWeapons()
    {
        ClearItems();

        for (int i = 0; i < model.weaponList.Count; i++)
        {
            elementsList[i].SetActive(true);
            elementsList[i].GetComponent <ArmoryItemController>().DisplayArmoryItem(model.weaponList[i], "Weapon");
            elementsList[i].transform.SetParent(content.transform, false);
        }

        RectTransform rt = content.GetComponent <RectTransform>();

        rt.sizeDelta = new Vector2(rt.rect.width, elementHeight * Mathf.Ceil((float)model.weaponList.Count / 5) + content.padding.top + content.padding.bottom);
    }
示例#3
0
        public void RefreshWeaponBreakingView()
        {
            weaponNunText.text = string.Format("兵器匣:{0}/{1}", weaponBreakings.Count, DbManager.Instance.MaxWeaponNum);
            if (prefabBreakWeaponObj == null)
            {
                prefabBreakWeaponObj = Statics.GetPrefab("Prefabs/UI/GridItems/WorkshopWeaponBreakingContainer");
            }
            GameObject itemPrefab;
            WorkshopWeaponBreakingContainer container;
            WeaponData weapon;

            for (int i = 0; i < weaponBreakings.Count; i++)
            {
                weapon = weaponBreakings[i];
                if (weaponBreakingContainers.Count <= i)
                {
                    itemPrefab = Statics.GetPrefabClone(prefabBreakWeaponObj);
                    MakeToParent(weaponBreakingGrid.transform, itemPrefab.transform);
                    container = itemPrefab.GetComponent <WorkshopWeaponBreakingContainer>();
                    weaponBreakingContainers.Add(container);
                }
                else
                {
                    container = weaponBreakingContainers[i];
                }
                container.UpdateData(weapon);
                container.RefreshView();
            }
            RectTransform trans = weaponBreakingGrid.GetComponent <RectTransform>();

            trans.sizeDelta = new Vector2(trans.sizeDelta.x, (weaponBreakingGrid.cellSize.y + weaponBreakingGrid.spacing.y) * Mathf.Ceil(weaponBreakingContainers.Count * 0.5f) - weaponBreakingGrid.spacing.y);
        }
    // Use this for initialization
    void Start()
    {
        inventoryPanel = GameObject.Find("inventory Panel");

        slotPanel  = inventoryPanel.transform.FindChild("slot Panel").gameObject;
        slotPanel2 = inventoryPanel.transform.FindChild("slot In Game Panel").gameObject;

        gridLayoutGroup  = slotPanel.GetComponent <GridLayoutGroup> ();
        gridLayoutGroup2 = slotPanel2.GetComponent <GridLayoutGroup> ();

        rect = gridLayoutGroup2.GetComponent <RectTransform> ();

        gridLayoutGroup2.cellSize = new Vector2((float)(rect.rect.width * 0.3), (float)(rect.rect.width * 0.3));
//		gridLayoutGroup2.padding = new RectOffset((int)(rect.rect.width * 0.10),0,(int)(rect.rect.height * 0.1),0);
        float spacing2 = (slotPanel2.GetComponent <RectTransform> ().rect.width - (3 * gridLayoutGroup2.cellSize.x)) / 2;

        gridLayoutGroup2.spacing = new Vector2(spacing2, 0);

        int cellCont = 10;

        gridLayoutGroup.cellSize = new Vector2((float)(rect.rect.width * 0.3), (float)(rect.rect.width * 0.3));
        float spacing = (slotPanel.GetComponent <RectTransform> ().rect.width - ((cellCont / 2) * gridLayoutGroup.cellSize.x)) / ((cellCont / 2) - 1);

        gridLayoutGroup.spacing = new Vector2(spacing, (float)(rect.rect.height * 0.30));
//		gridLayoutGroup.padding = new RectOffset((int)(rect.rect.width * 0.10),0,(int)(rect.rect.height * 0.1),0);

        print(slotPanel2.GetComponent <RectTransform> ().rect.width);
    }
示例#5
0
    /// <summary>
    /// 设置Grid宽高
    /// </summary>
    /// <param name="count">数据总长度</param>
    private void SetScrollView(int count)
    {
        var rectTrans   = _grid.GetComponent <RectTransform>();
        var scrollTrans = _scrollView.GetComponent <RectTransform>();

        rectTrans.sizeDelta = scrollTrans.sizeDelta;

        //排列数量
        var constraint = _grid.constraintCount;
        //预制宽度
        var width = _grid.cellSize.x;
        //预制高度
        var heigth = _grid.cellSize.y;

        switch (_grid.constraint)
        {
        //纵向排列
        case GridLayoutGroup.Constraint.FixedColumnCount:
            // ReSharper disable once PossibleLossOfFraction
            rectTrans.sizeDelta = new Vector2(x: width * constraint, y: heigth * Mathf.Ceil((float)count / constraint));
            break;

        //横向排列排列
        case GridLayoutGroup.Constraint.FixedRowCount:
            // ReSharper disable once PossibleLossOfFraction
            rectTrans.sizeDelta = new Vector2(x: Mathf.Ceil((float)count / constraint), y: heigth * constraint);
            break;
        }
    }
示例#6
0
    static private GridLayoutGroup DrawGrid(PSDUI.Layer layer, GameObject parent)
    {
        GridLayoutGroup temp            = Resources.Load(PSDImporterConst.PREFAB_PATH_GRID, typeof(GridLayoutGroup)) as GridLayoutGroup;
        GridLayoutGroup gridLayoutGroup = GameObject.Instantiate(temp) as GridLayoutGroup;

        gridLayoutGroup.transform.parent = parent.transform;

        gridLayoutGroup.padding  = new RectOffset();
        gridLayoutGroup.cellSize = new Vector2(System.Convert.ToInt32(layer.arguments [2]), System.Convert.ToInt32(layer.arguments [3]));

        RectTransform rectTransform = gridLayoutGroup.GetComponent <RectTransform> ();

        rectTransform.sizeDelta        = new Vector2(layer.size.width, layer.size.height);
        rectTransform.anchoredPosition = new Vector2(layer.position.x, layer.position.y);

        int cellCount = System.Convert.ToInt32(layer.arguments [0]) * System.Convert.ToInt32(layer.arguments [1]);

        for (int cell = 0; cell < cellCount; cell++)
        {
            Image pic = Resources.Load(PSDImporterConst.PREFAB_PATH_IMAGE, typeof(Image)) as Image;
            pic.sprite = null;
//            Sprite sprite = Resources.Load (relativeResoucesDirectory + "normal_13", typeof(Sprite)) as Sprite;
//            pic.sprite = sprite;

            Image myImage = GameObject.Instantiate(pic) as Image;
            myImage.transform.parent = rectTransform;
        }

        return(gridLayoutGroup);
    }
示例#7
0
        public BaseModule(DollMaker dm)
        {
            this.dm = dm;
            atom    = dm.containingAtom;
            ui      = dm.ui;

            GameObject moduleLayerObject = new GameObject("module UI", typeof(RectTransform));

            moduleLayerObject.transform.SetParent(ui.canvas.transform, false);
            moduleUI = moduleLayerObject.transform;
            moduleUI.transform.localPosition              = Vector3.zero;
            moduleUI.transform.localScale                 = Vector3.one;
            moduleUI.transform.localEulerAngles           = Vector3.zero;
            moduleUI.transform.localPosition              = new Vector3(0, -300, 0);
            moduleUI.GetComponent <RectTransform>().pivot = new Vector2(0, 0);

            dm.modules.Add(this);

            oldContainerName = dm.containingAtom.uid;
            SuperController.singleton.onAtomUIDRenameHandlers += HandleRename;

            float buttonHeight = 60;

            moduleButtonsLayout          = ui.CreateGridLayout(1200, buttonHeight);
            moduleButtonsLayout.cellSize = new Vector2(300, buttonHeight);
            moduleButtonsLayout.GetComponent <RectTransform>().pivot = new Vector2(0, 0);
            moduleButtonsLayout.transform.SetParent(moduleUI, false);
            moduleButtonsLayout.transform.localPosition = new Vector3(0, 0, 0);
        }
示例#8
0
        private IEnumerator CacheValues()
        {
            yield return(new WaitForSeconds(0.5f));

            if (_ProxyContent != null)
            {
                mProxyRectTransform = _ProxyContent.GetComponent <RectTransform>();
                mChildCount         = _ProxyContent.transform.childCount;
                mDistancesToCenter  = new float[mChildCount];
                UIWidget[] childRectTransform = new UIWidget[mChildCount];
                for (int i = 0; i < mChildCount; i++)
                {
                    childRectTransform[i] = _ProxyContent.transform.GetChild(i).GetComponent <UIWidget>();

                    if (_ProxyContent.startAxis == GridLayoutGroup.Axis.Horizontal)
                    {
                        mDistancesToCenter[i] = _ProxyContent.cellSize.x * i;//Mathf.Abs (_CenterToCompare.transform.localPosition.x - _ProxyContent.transform.GetChild (i).transform.localPosition.x);
                    }
                    else
                    {
                        mDistancesToCenter[i] = Mathf.Abs(_CenterToCompare.transform.localPosition.y - childRectTransform[i].transform.localPosition.y);
                    }
                }

                EndDrag();
            }
        }
示例#9
0
 private void applyScaleProperty(GridLayoutScalerProperty scaleProperty)
 {
     GridLayout.cellSize        = scaleProperty.CellSize;
     GridLayout.spacing         = scaleProperty.Spacing;
     GridLayout.constraintCount = scaleProperty.ConstraintCount;
     LayoutRebuilder.MarkLayoutForRebuild(GridLayout.GetComponent <RectTransform>());
 }
示例#10
0
        public override void RefreshView()
        {
            if (prefabObj == null)
            {
                prefabObj = Statics.GetPrefab("Prefabs/UI/GridItems/SellItemContainer");
            }
            GameObject        itemPrefab;
            ItemData          item;
            SellItemContainer container;

            for (int i = 0; i < itemsData.Count; i++)
            {
                item = itemsData[i];
                if (itemContainers.Count <= i)
                {
                    itemPrefab = Statics.GetPrefabClone(prefabObj);
                    MakeToParent(grid.transform, itemPrefab.transform);
                    container = itemPrefab.GetComponent <SellItemContainer>();
                    itemContainers.Add(container);
                }
                else
                {
                    container = itemContainers[i];
                }
                container.UpdateData(item);
                container.RefreshView();
            }
            RectTransform trans = grid.GetComponent <RectTransform>();
            float         y     = (grid.cellSize.y + grid.spacing.y) * Mathf.Ceil(itemContainers.Count / 5) - grid.spacing.y;

            y = y < 0 ? 0 : y;
            trans.sizeDelta = new Vector2(trans.sizeDelta.x, y);
            MakeSelectedItem();
        }
示例#11
0
    protected virtual void Awake()
    {
        scrollRect  = scroll.GetComponent <RectTransform>();
        contentRect = gridLayout.GetComponent <RectTransform>();
        minSize     = contentRect.rect.size.y;

        SetupScrollingComponets();

        //set listener for end of list
        scroll.onValueChanged.AddListener(delegate(Vector2 v)
        {
            if (userInteraction && scroll.velocity.magnitude > scrollVelocityThreshold)
            {
                if (shouldAlingCoroutine != null)
                {
                    StopCoroutine(shouldAlingCoroutine);
                }
                shouldAlingCoroutine = StartCoroutine(ShouldAlingRoutine());
            }


            if (GetNormalizedPosition() <= 0.0f && onReachEndOfList != null)
            {
                onReachEndOfList();
            }
        });
    }
示例#12
0
    public static void ResizeForContent(GridLayoutGroup _this)
    {
        RectTransform t = _this.GetComponent <RectTransform>();
        float         h = ComputeContentHeight(_this);

        t.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, h);
    }
示例#13
0
 public override void RefreshView()
 {
     if (prefabObj == null)
     {
         prefabObj = Statics.GetPrefab("Prefabs/UI/GridItems/RecordItemContainer");
     }
     if (recordsData.Count > 0)
     {
         JArray              record;
         GameObject          itemPrefab;
         RecordItemContainer container;
         for (int i = 0; i < recordsData.Count; i++)
         {
             record = recordsData[i];
             if (recordContainers.Count <= i)
             {
                 itemPrefab = Statics.GetPrefabClone(prefabObj);
                 MakeToParent(grid.transform, itemPrefab.transform);
                 container = itemPrefab.GetComponent <RecordItemContainer>();
                 recordContainers.Add(container);
             }
             else
             {
                 container = recordContainers[i];
             }
             container.UpdateData(record);
             container.RefreshView();
         }
         RectTransform trans = grid.GetComponent <RectTransform>();
         trans.sizeDelta = new Vector2(trans.sizeDelta.x, (grid.cellSize.y + grid.spacing.y) * recordContainers.Count - grid.spacing.y);
     }
 }
示例#14
0
    void Start()
    {
        int progress = 0, i = 0;

        foreach (var v in AchieveConfiguration.achieveDictionary)
        {
            i++;
            AchieveItem item = SupportTools.AddChild <AchieveItem>(m_Root.gameObject, m_AchieveItemPrefab.gameObject);
            int         id   = v.Key;
            item.achieveName.text   = v.Value.name;
            item.description.text   = v.Value.DescriptionID.ToString();
            item.achieveIcon.sprite = Resources.Load <Sprite>("UI/LaunchScene/AchieveIcon/" + v.Value.IconName);
            if (ConstantData.achieveRecords[id] < v.Value.goal)
            {
                item.progress.gameObject.SetActive(true);
                item.finishFlag.gameObject.SetActive(false);
                item.progress.text = ConstantData.achieveRecords[id] + "/" + v.Value.goal;
                item.backGround    = Color.gray;
            }
            else
            {
                item.progress.gameObject.SetActive(false);
                item.finishFlag.gameObject.SetActive(true);
                item.backGround = Color.white;
                progress++;
            }
        }
        m_Progress.text = progress + "/" + AchieveConfiguration.achieveDictionary.Count;
        m_Root.GetComponent <RectTransform>().sizeDelta = new Vector2(m_Root.cellSize.x, i * m_Root.cellSize.y + (i - 1) * m_Root.spacing.y);
    }
示例#15
0
        private void SetListGridLayoutGroupCellSize()
        {
            var cellSizeX = _unitListGridLayoutGroup.GetComponent <RectTransform>().rect.width;
            var cellSizeY = cellSizeX / 4;

            _unitListGridLayoutGroup.cellSize = new Vector2(cellSizeX, cellSizeY);
        }
示例#16
0
        public void Adapt()
        {
            RectTransform t = m_GridLayout.GetComponent <RectTransform>();
            float         h = this.ComputeLayoutHeight(m_GridLayout);

            t.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, h);
        }
示例#17
0
    /// <summary> Scroll content size conrtrol </summary>
    void SizeControl()
    {
        if (battleHeroContentRect == null)
        {
            battleHeroContentRect = heroInventoryScrollViewContent.GetComponent <RectTransform>();
        }

        if (territoryHeroContentRect == null)
        {
            territoryHeroContentRect = territoryheroInventoryScrollViewContent.GetComponent <RectTransform>();
        }

        // 전투영웅
        float count = heroInventoryScrollViewContent.transform.childCount;

        count /= 4;
        double quotient = System.Math.Ceiling((double)count);

        float sizeDeltaY = (heroInventoryScrollViewContent.cellSize.y + heroInventoryScrollViewContent.spacing.y) * ((int)quotient);

        battleHeroContentRect.sizeDelta = new Vector2(battleHeroContentRect.sizeDelta.x, sizeDeltaY);

        // 내정 영웅
        count    = territoryheroInventoryScrollViewContent.transform.childCount;
        count   /= 4;
        quotient = System.Math.Ceiling((double)count);

        sizeDeltaY = (territoryheroInventoryScrollViewContent.cellSize.y + territoryheroInventoryScrollViewContent.spacing.y) * ((int)quotient);

        territoryHeroContentRect.sizeDelta = new Vector2(territoryHeroContentRect.sizeDelta.x, sizeDeltaY);
    }
示例#18
0
 //rebuilds the grid ui
 void Rebuild()
 {
     //turns off the contentSizeFitter before checking if the current resolution is landscape or portrait and setting the grid scale accordingly
     glg.GetComponent <ContentSizeFitter>().enabled = true;
     if (Screen.width < Screen.height)
     {
         container.transform.localScale = new Vector2(1.3f, 1.3f);
     }
     else
     {
         container.transform.localScale = new Vector2(1f, 1f);
     }
     //rebuilds the layout then re-enables the ContentSizeFitter
     LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)container.transform);
     glg.GetComponent <ContentSizeFitter>().enabled = false;
 }
    protected override void Awake()
    {
        base.Awake();
        m_toggleGroup = m_levelToggleGrid.GetComponent <ToggleGroup>();
        var childCount = m_levelToggleGrid.transform.childCount;

        for (int i = 0; i < childCount; i++)
        {
            DestroyImmediate(m_levelToggleGrid.transform.GetChild(0).gameObject);
        }
        var levels = Manager.Instance.LevelManager.Levels;

        m_levelToggles = new Toggle[levels.Length];
        for (int i = 0; i < m_levelToggles.Length; i++)
        {
            var obj = Instantiate(m_levelTogglePrefab, m_levelToggleGrid.transform);
            m_levelToggles[i]       = obj.GetComponentInChildren <Toggle>();
            m_levelToggles[i].group = m_toggleGroup;
            var index = i;
            m_levelToggles[i].onValueChanged.AddListener((v) =>
            {
                if (v)
                {
                    m_selectLevelIndex = index;
                }
            });
            var bg = obj.GetTargetInChildren <Image>("Background");
            bg.sprite = levels[i].m_sprite;
            var nameText = obj.GetTargetInChildren <Text>("Label");
            nameText.text = levels[i].m_levelName;
        }
    }
示例#20
0
        private void InitGoldPanel()
        {
            int num = 0;

            foreach (KeyValuePair <uint, tagFishRechargeInfo> map in FishConfig.Instance.m_FishRecharge.m_FishRechargeMap)
            {
                if (!map.Value.IsAddGlobel())
                {
                    continue;
                }
                if (map.Value.IsFirstAdd() && !PlayerRole.Instance.RoleInfo.RoleMe.GetIsFirstPayGlobel())
                {
                    continue;
                }
                ShopItem item = new ShopItem();
                item.Init(goldTemp);
                item.ShowGoodsInfo(map.Key, map.Value, PayType.Gold);
                item.m_BaseTrans.parent = gridGold.transform;
                num++;
                item.ResetLocalScale();
            }
            RectTransform rectTransform = gridGold.GetComponent <RectTransform>();

            rectTransform.sizeDelta     = new Vector2(1100, 240 * num);
            rectTransform.localPosition = Vector3.zero;
            goldTemp.SetActive(false);
            isInitGold = true;
        }
示例#21
0
文件: BagView.cs 项目: isoundy000/L3D
        //显示背包物品
        void ShowKnapsackItemInfo()
        {
            if (m_BaseWndObject == null || m_BaseWndObject.activeSelf != true)
            {
                return;
            }
            ClearKnapsackGird();
            int Idx = 0;

            if (PlayerRole.Instance.ItemManager.GetAllItemMap() == null)
            {
                //InitEmptyKnapsack(Idx, 14);
                return;
            }
            m_KnapList.Clear();
            foreach (KeyValuePair <uint, tagItemInfo> map in PlayerRole.Instance.ItemManager.GetAllItemMap())
            {
                if (FishConfig.Instance.m_ItemInfo.m_ItemMap.ContainsKey(map.Value.ItemID) == false)
                {
                    continue;
                }

                tagItemConfig pItemConfig = FishConfig.Instance.m_ItemInfo.m_ItemMap[map.Value.ItemID];
                if (pItemConfig.ItemTypeID == EItemType.IT_Cannon)
                {
                    continue;
                }

                KnapsackItem knapsack = new KnapsackItem();
                knapsack.Init(templateGoodItem);
                string IconName = "";
                IconName = pItemConfig.ItemIcon;
                knapsack.SetItemInfo(map.Value.ItemID, PlayerRole.Instance.ItemManager.GetItemSum(map.Value.ItemID, false), IconName,
                                     map.Value.ItemOnlyID, pItemConfig.ItemTypeID);
                m_KnapList.Add(knapsack);
            }
            templateGoodItem.SetActive(false);
            //m_KnapList.Sort(CompareItemByID);
            RectTransform rectTransform = gridGoods.GetComponent <RectTransform>();

            rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, m_KnapList.Count * 300 / 3);
            for (byte i = 0; i < m_KnapList.Count; ++i)
            {
                m_KnapList[i].m_BaseTrans.parent = gridGoods.transform;
                m_KnapList[i].ResetLoaclScale();
                ++Idx;
            }
            if (Idx < 14)
            {
                InitEmptyKnapsack(Idx, 14);
            }
            else
            {
                if ((Idx % 7) != 0)
                {
                    InitEmptyKnapsack(Idx, (Idx / 7 + 1) * 7);
                }
            }
            m_KnapList.Clear();
        }
示例#22
0
        private void InitItemPanel()
        {
            ClearGird();
            int  num        = 0;
            byte propertyID = (byte)(Shop_Type.Shop_Property + 1);

            if (FishConfig.Instance.m_ShopInfo.ShopMap.ContainsKey(propertyID) == false)
            {
                return;
            }
            tagShopConfig shopItemMap = FishConfig.Instance.m_ShopInfo.ShopMap[propertyID];

            if (shopItemMap == null)
            {
                return;
            }
            foreach (KeyValuePair <byte, tagShopItemConfig> map in shopItemMap.ShopItemMap)
            {
                PropertyItem item = new PropertyItem();
                item.Init(itemTemp);
                item.ShowGoodsInfo(map.Key, map.Value, shopItemMap.ShopItemStrMap[map.Key]);
                item.m_BaseTrans.parent = gridItem.transform;
                num++;
                item.ResetLocalScale();
            }
            RectTransform rectTransform = gridItem.GetComponent <RectTransform>();

            rectTransform.sizeDelta     = new Vector2(1100, 240 * num);
            rectTransform.localPosition = Vector3.zero;
            itemTemp.SetActive(false);
            isInitGoods = true;
        }
示例#23
0
    void Show()
    {
        if (rectContent == null)
        {
            rectContent = content.GetComponent <RectTransform>();
        }

        //if (TerritoryManager.Instance == null)
        //    return;
        //Building building = null;

        //if (TerritoryManager.Instance.placeDic[TerritoryManager.Instance.currentPlaceID].building != null)
        //    building = TerritoryManager.Instance.placeDic[TerritoryManager.Instance.currentPlaceID].building;


        //if (building is BuildingHeroGuild)
        //{
        //    currentHeroGuild = building as BuildingHeroGuild;
        //    currentHeroGuild.onAddVisitedHero += OnAddVisitedHero;
        //    currentHeroGuild.onRemoveVisitedHero += OnRemoveVisitedHero;
        //    //Debug.Log("길드 데이터 존재");

        //    InittradeDataList();
        //}
        MarketManager.Instance.onChangedTrade += OnChangedTrade;
        MarketManager.Instance.onRemoveTrade  += OnRemoveTrade;
        InitTradeDataList();
    }
示例#24
0
    /// <summary> Scroll content size conrtrol </summary>
    void SizeControl(int num)
    {
        if (battleHeroContentRect == null)
        {
            battleHeroContentRect = battleScrollViewContent.GetComponent <RectTransform>();
        }

        if (territoryHeroContentRect == null)
        {
            territoryHeroContentRect = territoryScrollViewContent.GetComponent <RectTransform>();
        }


        double count    = (double)num / 3;
        int    quotient = (int)System.Math.Ceiling(count);

        float sizeDeltaY = (battleScrollViewContent.cellSize.y + battleScrollViewContent.spacing.y) * (quotient);

        battleHeroContentRect.sizeDelta = new Vector2(battleHeroContentRect.sizeDelta.x, sizeDeltaY);

        scrollBattleHero.normalizedPosition = new Vector2(scrollBattleHero.normalizedPosition.x, 1f);

        count    = (double)num / 3;
        quotient = (int)System.Math.Ceiling(count);

        sizeDeltaY = (territoryScrollViewContent.cellSize.y + territoryScrollViewContent.spacing.y) * (quotient);

        territoryHeroContentRect.sizeDelta = new Vector2(territoryHeroContentRect.sizeDelta.x, sizeDeltaY);

        scrollterritoryHero.normalizedPosition = new Vector2(scrollterritoryHero.normalizedPosition.x, 1f);
    }
示例#25
0
        public UGUINode DrawLayer(GroupNode layer, UGUINode parent)
        {
            UGUINode node = PSDImportUtility.InstantiateItem(GroupType.GRID, layer.Name, parent);

            node.anchoType = AnchoType.Up | AnchoType.Left;
            GridLayoutGroup gridLayoutGroup = node.InitComponent <GridLayoutGroup>();

            PSDImportUtility.SetRectTransform(layer, gridLayoutGroup.GetComponent <RectTransform>());

            gridLayoutGroup.padding  = new RectOffset(1, 1, 1, 1);
            gridLayoutGroup.cellSize = new Vector2(layer.rect.width, layer.rect.height);

            switch (layer.direction)
            {
            case Direction.Horizontal:
                gridLayoutGroup.constraint = GridLayoutGroup.Constraint.FixedColumnCount;
                break;

            case Direction.Vertical:
                gridLayoutGroup.constraint = GridLayoutGroup.Constraint.FixedRowCount;
                break;

            default:
                gridLayoutGroup.constraint = GridLayoutGroup.Constraint.Flexible;
                break;
            }
            gridLayoutGroup.constraintCount = layer.constraintCount;

            ctrl.DrawImages(layer.images.ToArray(), node);
            ctrl.DrawLayers(layer.groups.ToArray() as GroupNode[], node);
            return(node);
        }
示例#26
0
 public static void ScrollToTop(this GridLayoutGroup gridLayoutGroup)
 {
     if (gridLayoutGroup != null)
     {
         ScrollToTop(gridLayoutGroup.GetComponent <RectTransform>());
     }
 }
示例#27
0
 public override void RefreshView()
 {
     if (prefabObj == null)
     {
         prefabObj = Statics.GetPrefab("Prefabs/UI/GridItems/DropItemContainer");
     }
     if (dropsData.Count > 0)
     {
         GameObject        itemPrefab;
         DropItemContainer container;
         DropData          drop;
         for (int i = 0; i < dropsData.Count; i++)
         {
             drop = dropsData[i];
             if (dropContainers.Count <= i)
             {
                 itemPrefab = Statics.GetPrefabClone(prefabObj);
                 MakeToParent(grid.transform, itemPrefab.transform);
                 container = itemPrefab.GetComponent <DropItemContainer>();
                 dropContainers.Add(container);
             }
             else
             {
                 container = dropContainers[i];
             }
             container.UpdateData(drop);
             container.RefreshView();
         }
         RectTransform trans = grid.GetComponent <RectTransform>();
         trans.sizeDelta = new Vector2(trans.sizeDelta.x, (grid.cellSize.y + grid.spacing.y) * dropContainers.Count - grid.spacing.y);
     }
 }
示例#28
0
        public override void RefreshView()
        {
            RefreshResultResourcesView();
            if (prefabObj == null)
            {
                prefabObj = Statics.GetPrefab("Prefabs/UI/GridItems/WorkshopResourceContainer");
            }
            GameObject itemPrefab;
            WorkshopResourceContainer container;
            ResourceData resource;

            for (int i = 0; i < resources.Count; i++)
            {
                resource = resources[i];
                if (resourceContainers.Count <= i)
                {
                    itemPrefab = Statics.GetPrefabClone(prefabObj);
                    MakeToParent(resourceGrid.transform, itemPrefab.transform);
                    container = itemPrefab.GetComponent <WorkshopResourceContainer>();
                    resourceContainers.Add(container);
                }
                else
                {
                    container = resourceContainers[i];
                }
                container.UpdateData(resource);
                container.RefreshView();
            }
            RectTransform trans = resourceGrid.GetComponent <RectTransform>();

            trans.sizeDelta = new Vector2(trans.sizeDelta.x, (resourceGrid.cellSize.y + resourceGrid.spacing.y) * Mathf.Ceil(resourceContainers.Count * 0.5f) - resourceGrid.spacing.y);
            Messenger.Broadcast(NotifyTypes.ModifyResources);
        }
示例#29
0
    public void SetRooms(SocketIOComponent socket, string uid, JSONObject data)
    {
        m_uid = uid;

        Transform grid_trans = grid.GetComponent <Transform>();

        RoomItem[] children = grid_trans.GetComponentsInChildren <RoomItem>();
        for (int i = 0; i < children.Length; ++i)
        {
            RoomItem item = children[i];
            Destroy(item.gameObject);
        }

        JSONObject room_info = data.GetField("room_info");

        for (int i = 0; i < room_info.Count; i++)
        {
            RoomItem item = (RoomItem)Instantiate(Resources.Load <RoomItem>("room_item"));

            JSONObject room_item = room_info[i];
            if (room_item.Count != 4)
            {
                continue;
            }

            int    no     = System.Convert.ToInt32(room_item[0].ToString());
            string name   = room_item[1].ToString();
            int    status = System.Convert.ToInt32(room_item[2].ToString());
            int    count  = System.Convert.ToInt32(room_item[3].ToString());
            item.SetInfo(m_uid, no, name, status, count);

            item.transform.parent     = grid_trans;
            item.transform.localScale = Vector3.one;
        }
    }
        public override void RefreshView()
        {
            if (prefabObj == null)
            {
                prefabObj = Statics.GetPrefab("Prefabs/UI/GridItems/BookOfForbiddenAreaContainer");
            }
            GameObject itemPrefab;
            BookData   book;
            BookOfForbiddenAreaContainer container;

            for (int i = 0; i < booksData.Count; i++)
            {
                book = booksData[i];
                book.MakeJsonToModel();
                if (bookContainers.Count <= i)
                {
                    itemPrefab = Statics.GetPrefabClone(prefabObj);
                    MakeToParent(grid.transform, itemPrefab.transform);
                    container = itemPrefab.GetComponent <BookOfForbiddenAreaContainer>();
                    bookContainers.Add(container);
                }
                else
                {
                    container = bookContainers[i];
                }
                container.UpdateData(book, hostRoleData);
                container.RefreshView();
            }
            RectTransform trans = grid.GetComponent <RectTransform>();
            float         y     = (grid.cellSize.y + grid.spacing.y) * Mathf.Ceil(bookContainers.Count / 3) - grid.spacing.y;

            y = y < 0 ? 0 : y;
            trans.sizeDelta = new Vector2(trans.sizeDelta.x, y);
        }