Ejemplo n.º 1
0
    public void InitPage()
    {
        if (m_pageNumber < 1)
        {
            return;
        }

        if (!isInitPageCell)
        {
            for (int i = 0; i < 2; i++)
            {
                GameObject cell = NGUITools.AddChildNotLoseAnything(gameObject, m_pageCellPrefab);
                cell.SetActive(false);

                m_cachedCellsDic.Add(i, cell);
            }

            isInitPageCell = true;
        }

        FillCellDataByIndex(ShowCellAtPage(m_currentPage), m_currentPage);

        if (m_pageViewBar != null)
        {
            m_pageViewBar.OnBarSelectedAtIndex(m_currentPage);
        }

        SetPageUpDownState();

        m_leftRange  = GetTargetPagePos(0);
        m_rightRange = GetTargetPagePos(m_pageNumber - 1);
    }
Ejemplo n.º 2
0
    public static int AddChildByResourcesPathNoBehaviour(IntPtr l)
    {
        GameObject parent = lua_.ToUserDataObject(1) as GameObject;
        string     path   = lua_.ToString(2);
        GameObject prefab = (GameObject)ResLoader.Load(path, typeof(GameObject));
        GameObject obj    = NGUITools.AddChildNotLoseAnything(parent, prefab);

        lua_.NewClassUserData(obj);
        return(1);
    }
Ejemplo n.º 3
0
    public static void PlayGemCombineEffect(GameObject parent, Vector2 scale)
    {
        GameObject gPrefab = (GameObject)ResLoader.Load("Prefab/UI/GemMergeUIAnim", typeof(GameObject));
        GameObject gObject = NGUITools.AddChildNotLoseAnything(parent, gPrefab);

        gObject.transform.localPosition = Vector3.zero;
        gObject.transform.localScale    = Vector3.one;
        UISpriteAnimation animation = gObject.GetComponentInChildren <UISpriteAnimation>();

        animation.transform.localScale = scale;
        animation.Scale = scale;
    }
Ejemplo n.º 4
0
    private GameObject GetCell(int cellNum)
    {
        float   space         = cellNum == 0? 0:LineFlowLayout.space;
        Vector3 finalLocalPos = new Vector3(0, cellNum * (space - mCellHeight), 0);

        CellPrefab.transform.position = finalLocalPos;
        GameObject cell = NGUITools.AddChildNotLoseAnything(gameObject, CellPrefab);

        cell.name = CellPreName + "Cell" + cellNum;
        cell.SetActive(true);
        AddLuaCellToCtr(cell);

        return(cell);
    }
Ejemplo n.º 5
0
    public static int AddChildNotLose(IntPtr l)
    {
        GameObject   parent = lua_.ToUserDataObject(1) as GameObject;
        string       path   = lua_.ToString(2);
        GameObject   prefab = (GameObject)ResLoader.Load(UIPrefabDummy.GetUIPrefabPath(path), typeof(GameObject));
        GameObject   obj    = NGUITools.AddChildNotLoseAnything(parent, prefab);
        LuaBehaviour luaB   = obj.GetComponent <LuaBehaviour>();

        if (luaB == null)
        {
            Debug.Log("There is No LuaBehaviour on new GameObj." + prefab.name);
            return(0);
        }
        lua_.RawGetI(LuaAPI.LUA_REGISTRYINDEX, luaB.Object_ref);
        return(1);
    }
    private GameObject DequeueItemInPool()
    {
        GameObject obj = null;

        if (cellPool.Count > 0)
        {
            obj = cellPool.Dequeue();
        }
        else
        {
            obj = NGUITools.AddChildNotLoseAnything(gameObject, cellPrefab);
        }

        obj.SetActive(true);
        return(obj);
    }
Ejemplo n.º 7
0
    T GetWidget <T>(List <T> pool, GameObject prefab) where T : MonoBehaviour
    {
        int poolsize = pool.Count;

        if (poolsize > 0)
        {
            T widget = pool[poolsize - 1];
            pool.RemoveAt(poolsize - 1);
            widget.gameObject.SetActive(true);
            mUsingWidgetPool.Add(widget);
            return(widget);
        }
        else
        {
            GameObject obj    = NGUITools.AddChildNotLoseAnything(gameObject, prefab.gameObject);
            T          widget = obj.GetComponent <T>();
            mUsingWidgetPool.Add(widget);
            return(widget);
        }
    }
Ejemplo n.º 8
0
    public static int AddChildWithLocalPosition(IntPtr l)
    {
        GameObject parent       = lua_.ToUserDataObject(1) as GameObject;
        string     path         = lua_.ToString(2);
        Vector3    localPositon = (Vector3)lua_.ToUserDataObject(3);

        GameObject prefab = (GameObject)ResLoader.Load(path, typeof(GameObject));

        prefab.transform.position = localPositon;
        GameObject   obj  = NGUITools.AddChildNotLoseAnything(parent, prefab);
        LuaBehaviour luaB = obj.GetComponent <LuaBehaviour>();

        if (luaB == null)
        {
            Debug.Log("There is No LuaBehaviour on new GameObj." + prefab.name);
            return(0);
        }
        lua_.RawGetI(LuaAPI.LUA_REGISTRYINDEX, luaB.Object_ref);
        return(1);
    }