/// <summary>
    ///
    /// </summary>
    /// <param name="_comName"></param>
    /// <param name="_numItems">这个值不为空,会执行一次 numItems</param>
    /// <param name="_isVirtual">false 不复用列表</param>
    /// <param name="_selectedIndex">指定显示的下标,滚动显示并且至底层</param>
    public void SetFairyListNumItems(string _comName, int _numItems, bool _isVirtual, int _selectedIndex)
    {
        GObject tempCom = GetFairyObject(_comName);

        if (tempCom == null)
        {
            LogError("_asCom value nil");
            return;
        }

        GList tempList = tempCom.asList;

        if (tempList == null)
        {
            LogError("tempList value nil");
            return;
        }

        if (_isVirtual)
        {
            tempList.SetVirtual();
        }

        tempList.numItems = _numItems;
        if (_numItems > 0 && _selectedIndex != -1)
        {
            tempList.AddSelection(_selectedIndex, true);
        }
        else
        {
            tempList.ClearSelection();
        }
    }
    public void SetFairyItemSelected(string _comName, int _selectedIndex)
    {
        GObject tempCom = GetFairyObject(_comName);

        if (tempCom == null)
        {
            LogError("_asCom value nil");
            return;
        }

        GList tempList = tempCom.asList;

        if (tempList == null)
        {
            LogError("tempList value nil");
            return;
        }

        if (_selectedIndex != -1)
        {
            tempList.AddSelection(_selectedIndex, true);
        }
        else
        {
            tempList.ClearSelection();
        }
    }
Beispiel #3
0
    void Start()
    {
        Application.targetFrameRate = 60;
        GRoot.inst.SetContentScaleFactor(1136, 640);
        Stage.inst.onKeyDown.Add(OnKeyDown);

        UIPackage.AddPackage("UI/VirtualList");
        UIObjectFactory.SetPackageItemExtension(UIPackage.GetItemURL("VirtualList", "mailItem"), typeof(MailItem));

        _mainView = UIPackage.CreateObject("VirtualList", "Main").asCom;
        _mainView.fairyBatching = true;
        _mainView.SetSize(GRoot.inst.width, GRoot.inst.height);
        _mainView.AddRelation(GRoot.inst, RelationType.Size);
        GRoot.inst.AddChild(_mainView);

        _mainView.GetChild("n6").onClick.Add(() => { _list.AddSelection(500, true); });
        _mainView.GetChild("n7").onClick.Add(() => { _list.scrollPane.ScrollTop(); });
        _mainView.GetChild("n8").onClick.Add(() => { _list.scrollPane.ScrollBottom(); });

        _list = _mainView.GetChild("mailList").asList;
        _list.SetVirtual();

        _list.itemRenderer = RenderListItem;
        _list.numItems     = 1000;
    }
Beispiel #4
0
    void select_nums_click(EventContext context)
    {
        _list.AddSelection(3, true);

        MailItem item = (MailItem)_list.GetChildAt(9);

        Debug.Log(item.title);
    }
Beispiel #5
0
    public void ShowText(int damage, string damageType, string skillName)
    {
        int     index = _list.ItemIndexToChildIndex(TurnControl.instance._index);
        GObject obj   = _list.GetChildAt((index + 11) % 50);

        //Debug.Log(index);
        if (damageType != "True1")
        {
            if (damage == -1)
            {
                string str = "你使用了" + skillName + ",但是被" + EnemyStatus.instance.BaseStatus.EnemyName + "闪避了!";
                _list.AddSelection(TurnControl.instance._index, true);
                MailItem item = (MailItem)obj;
                item.setText(str);
            }
            else if (damage == -2)
            {
                string str = "你打败了" + EnemyStatus.instance.BaseStatus.EnemyName;
                _list.AddSelection(TurnControl.instance._index, true);
                MailItem item = (MailItem)obj;
                item.setText(str);
            }
            else
            {
                string str = "你使用了" + skillName + ",对" + EnemyStatus.instance.BaseStatus.EnemyName + "造成了" + damage + "点" + damageType + "伤害";
                _list.AddSelection(TurnControl.instance._index, true);
                MailItem item = (MailItem)obj;
                item.setText(str);
            }
        }
        else
        {
            string str = EnemyStatus.instance.BaseStatus.EnemyName + "使用了" + skillName + ",回复了" + damage + "点生命";
            _list.AddSelection(TurnControl.instance._index, true);
            MailItem item = (MailItem)obj;
            item.setText(str);
        }
        TurnControl.instance._index = (TurnControl.instance._index + 1) % 50;
    }
Beispiel #6
0
    void Start()
    {
        Application.targetFrameRate = 60;
        Stage.inst.onKeyDown.Add(OnKeyDown);

        _mainView = this.GetComponent <UIPanel>().ui;
        _mainView.GetChild("n6").onClick.Add(() => { _list.AddSelection(500, true); });
        _mainView.GetChild("n7").onClick.Add(() => { _list.scrollPane.ScrollTop(); });
        _mainView.GetChild("n8").onClick.Add(() => { _list.scrollPane.ScrollBottom(); });

        _list = _mainView.GetChild("mailList").asList;
        _list.SetVirtual();

        _list.itemRenderer = RenderListItem;
        _list.numItems     = 1000;
    }
        public VirtualListScene()
        {
            UIPackage.AddPackage("UI/VirtualList");
            UIObjectFactory.SetPackageItemExtension("ui://VirtualList/mailItem", typeof(MailItem));

            _mainView = UIPackage.CreateObject("VirtualList", "Main").asCom;
            _mainView.GetChild("n6").onClick.Add(() => { _list.AddSelection(500, true); });
            _mainView.GetChild("n7").onClick.Add(() => { _list.scrollPane.ScrollTop(); });
            _mainView.GetChild("n8").onClick.Add(() => { _list.scrollPane.ScrollBottom(); });
            _mainView.MakeFullScreen();
            _mainView.AddRelation(GRoot.inst, RelationType.Size);
            AddChild(_mainView);

            _list = _mainView.GetChild("mailList").asList;
            _list.SetVirtual();

            _list.itemRenderer = RenderListItem;
            _list.numItems     = 1000;
        }
    /// <summary>
    /// 设置列表点击
    /// </summary>
    /// <param name="_comName">对象查找路径</param>
    /// <param name="_callback">点击回调的函数</param>
    /// <param name="_selectedIndex">触发的事件索引</param>
    /// <param name="_activeReturnIndex">激活函数会返回单选列表的点击下标</param>
    public void SetFairyListClickItem(string _comName, LuaFunction _callback, int _selectedIndex, bool _activeReturnIndex)
    {
        GObject tempCom = GetFairyObject(_comName);

        if (tempCom == null)
        {
            LogError("_asCom value nil");
            return;
        }

        GList tempList = tempCom.asList;

        if (tempList == null)
        {
            LogError("tempList value nil");
            return;
        }

        if (_selectedIndex != -1)
        {
            tempList.AddSelection(_selectedIndex, true);
        }

        if (_activeReturnIndex)
        {
            tempList.onClickItem.Add(() => { if (_callback != null)
                                             {
                                                 _callback.Call(tempList.selectedIndex);
                                             }
                                     });
        }
        else
        {
            tempList.onClickItem.Add((EventContext _context) => { if (_callback != null)
                                                                  {
                                                                      _callback.Call(_context);
                                                                  }
                                     });
        }
    }