コード例 #1
0
    /// <summary>
    /// 创建房子
    /// </summary>
    /// <param name="houseNodeIdx">节点索引</param>
    /// <param name="floor">层数,第一层是0</param>
    private void CreateHouse(int houseNodeIdx, int floor)
    {
        curHouseNodeIdx = houseNodeIdx;
        curFloor        = floor;

        //GridMgr.Inst.RefreshPos();
        MeshDraw.Inst.RefreshPos();

        MapUtil.ResetMapStartPosY();

        //回到上一次的房子
        if (houses[curHouseNodeIdx] != null &&
            houses[curHouseNodeIdx].floor == curFloor)
        {
            //Debug.LogWarning(curFloor);
            return;
        }

        MapUtil.ResetMapFlag();
        //新房子
        houses[curHouseNodeIdx] = JerryUtil.CloneGo <House>(new JerryUtil.CloneGoData()
        {
            parant = houseNode[curHouseNodeIdx],
            prefab = housePrefab.gameObject,
            active = true,
            clean  = true,
        });
        houseNode[curHouseNodeIdx].position = new Vector3(0, GetHouseYOffset, 0);
        houses[curHouseNodeIdx].Init(curFloor);
    }
コード例 #2
0
    void Awake()
    {
        grid   = this.transform.FindChild("Grid");
        prefab = this.transform.FindChild("Prefab");
        prefab.gameObject.SetActive(false);

        grids = new Grid[Width, Height];
        for (int j = 0; j < Height; j++)
        {
            for (int i = 0; i < Width; i++)
            {
                grids[i, j] = JerryUtil.CloneGo <Grid>(new JerryUtil.CloneGoData()
                {
                    parant = grid,
                    prefab = prefab.gameObject,
                    clean  = false,
                    active = true,
                    name   = string.Format("{0}_{1}", j, i),
                });
                grids[i, j].Init(new Grid.GridData()
                {
                    x     = i,
                    y     = j,
                    state = GetState(i, j),
                });
            }
        }
    }
コード例 #3
0
    public static Furniture LoadFurnitureByType(FurnitureType type, Transform parent)
    {
        GameObject obj = Resources.Load <GameObject>("Prefabs/Furnitures/" + type.ToString());
        Furniture  t   = JerryUtil.CloneGo <Furniture>(new JerryUtil.CloneGoData()
        {
            active = true,
            clean  = false,
            parant = parent,
            prefab = obj,
        });

        return(t);
    }
コード例 #4
0
        public void DoModify()
        {
            if (Application.isPlaying)
            {
                return;
            }

            TryWork();

            if (config.prefab == null)
            {
                return;
            }

            for (int i = 0; i < editorCreateCnt; i++)
            {
                GameObject go = JerryUtil.CloneGo(new JerryUtil.CloneGoData()
                {
                    name   = i.ToString(),
                    parant = this.transform,
                    prefab = config.prefab.gameObject,
                    active = true,
                });

                switch (config.dir)
                {
                case GridLayoutGroup.Axis.Horizontal:
                {
                    (go.transform as RectTransform).anchorMin = new Vector2(0.5f, 0.5f);
                    (go.transform as RectTransform).anchorMax = new Vector2(0.5f, 0.5f);
                }
                break;

                case GridLayoutGroup.Axis.Vertical:
                {
                    (go.transform as RectTransform).anchorMin = new Vector2(0.5f, 0.5f);
                    (go.transform as RectTransform).anchorMax = new Vector2(0.5f, 0.5f);
                }
                break;
                }
                (go.transform as RectTransform).pivot     = new Vector2(0, 1);
                (go.transform as RectTransform).sizeDelta = config.cellSize;
                go.transform.localPosition = Idx2LocalPos(i);
            }
        }
コード例 #5
0
    private void AddOneCtr(object[] args)
    {
        if (!m_Inited)
        {
            return;
        }
        if (args == null || args.Length != 1)
        {
            return;
        }
        CtrConfig  ctr     = (CtrConfig)args[0];
        CtrBtnItem ctrItem = JerryUtil.CloneGo <CtrBtnItem>(new JerryUtil.CloneGoData()
        {
            parant = m_Content,
            prefab = m_BtnPrefab.gameObject,
            active = true,
        });

        ctrItem.Init(ctr);
    }
コード例 #6
0
ファイル: SampleItem.cs プロジェクト: laijingfeng/JerryScroll
    private void TryFillData()
    {
        if (!_awaked ||
            !isDataDirty)
        {
            return;
        }
        isDataDirty = false;
        curData     = dataChange.Diff(curData, newData);

        if (dataChange.headChanged)
        {
            JerryUtil.CloneGo(new JerryUtil.CloneGoData()
            {
                active = true,
                clean  = true,
                parant = head,
                prefab = Resources.Load <GameObject>(curData.head),
            });
        }

        id.text  = curData.id.ToString();
        num.text = curData.num.ToString();
    }
コード例 #7
0
        private void RefreshData(bool forceUpdate = false)
        {
            updateWork  = 0;
            updateDirty = false;

            curLastIdx = curFirstIdx + (fiexdDirViewCount + config.bufHalfCnt * 2) * config.dirCellWidth - 1;
            if (curLastIdx >= TotalCount)
            {
                curLastIdx = TotalCount - 1;
            }

            foreach (T item in itemList)
            {
                if (!forceUpdate &&
                    item.GetGridIdx() >= curFirstIdx &&
                    item.GetGridIdx() <= curLastIdx)
                {
                    item.SetGridState(true);
                }
                else
                {
                    item.SetGridState(false);
                }
            }

            for (int i = curFirstIdx; i <= curLastIdx; i++)
            {
                if (!forceUpdate &&
                    itemList.Exists((x) => x.GetGridIdx() == i))
                {
                    continue;
                }

                //还有新的任务
                if (!forceUpdate &&
                    config.frameWorkCnt > 0 &&
                    updateWork > config.frameWorkCnt)
                {
                    updateDirty = true;
                    break;
                }

                tmpLayoutItem = itemList.Find((x) => x.GetGridState() == false);
                if (tmpLayoutItem == null)
                {
                    tmpLayoutItem = JerryUtil.CloneGo <T>(new JerryUtil.CloneGoData()
                    {
                        name   = i.ToString(),
                        parant = this.transform,
                        prefab = config.prefab.gameObject,
                        active = true,
                    });
                    switch (config.dir)
                    {
                    case GridLayoutGroup.Axis.Horizontal:
                    {
                        (tmpLayoutItem.transform as RectTransform).anchorMin = new Vector2(0.5f, 0.5f);
                        (tmpLayoutItem.transform as RectTransform).anchorMax = new Vector2(0.5f, 0.5f);
                    }
                    break;

                    case GridLayoutGroup.Axis.Vertical:
                    {
                        (tmpLayoutItem.transform as RectTransform).anchorMin = new Vector2(0.5f, 0.5f);
                        (tmpLayoutItem.transform as RectTransform).anchorMax = new Vector2(0.5f, 0.5f);
                    }
                    break;
                    }
                    (tmpLayoutItem.transform as RectTransform).pivot     = new Vector2(0, 1);
                    (tmpLayoutItem.transform as RectTransform).sizeDelta = config.cellSize;
                    itemList.Add(tmpLayoutItem);
                }
                tmpLayoutItem.SetGridState(true);
                tmpLayoutItem.SetGridIdx(i, Idx2LocalPos(i), datas[i]);

                updateWork++;
            }

            if (!updateDirty)
            {
                for (int i = 0, imax = itemList.Count; i < imax; i++)
                {
                    if (itemList[i].GetGridState() == false)
                    {
                        itemList[i].SetGridHide();
                    }
                }
            }
        }