Exemplo n.º 1
0
        protected ScrollElement InitScrollElement(ScrollElement scrollElement, int idx)
        {
            scrollElement.idx = idx;

            scrollElement = m_ElementsInfoAgent.SetItemInfo(scrollElement);
            return(scrollElement);
        }
Exemplo n.º 2
0
    public void OnDrag(PointerEventData eventData)
    {
        if (!_onDrag)
        {
            return;
        }

        transform.position = new Vector2(transform.position.x + eventData.delta.x, transform.position.y + eventData.delta.y);
        if (eventData.pointerEnter && eventData.pointerEnter.name == "ScrollSlot")
        {
            ScrollSlot sSlot = eventData.pointerEnter.gameObject.GetComponent <ScrollSlot>();
            if (sSlot)
            {
                _newScrollSlot = sSlot;
            }
        }
        else if (eventData.pointerEnter && eventData.pointerEnter.name == "ScrollImage")
        {
            ScrollElement sRlement = eventData.pointerEnter.GetComponentInParent <ScrollElement>();
            ScrollSlot    sSlot    = null;
            if (sRlement)
            {
                sSlot = sRlement.GetScrollSlot();
            }

            if (sSlot)
            {
                _newScrollSlot = sSlot;
            }
        }
        else
        {
            _newScrollSlot = null;
        }
    }
Exemplo n.º 3
0
        /// <summary>
        /// 消息展示窗体中的每一条消息
        /// </summary>
        void IMessageDisplayer.Display(string id, string title, string content, DateTime?time)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                throw new ArgumentNullException("id");
            }
            if (string.IsNullOrWhiteSpace(title))
            {
                throw new ArgumentNullException("title");
            }
            if (!time.HasValue)
            {
                time = DateTime.Now;
            }

            ScrollElement msgItemElement = new ScrollElement(id, title, content, time.Value, MsgStatus.Unread.ToString(), this.scrollingText);

            msgItemElement.ImageClick += new EventHandler <HSControls.Scroll.ScrollEventArgs>(msgItemElement_DoubleClick);
            msgItemElement.TextClick  += new EventHandler <HSControls.Scroll.ScrollEventArgs>(msgItemElement_DoubleClick);
            scrollingText.AddScrollElement(msgItemElement);

            //如果当前滚动窗体为显示,但是有消息就显示该消息
            if (scrollingText.Message.Count > 0)
            {
                if (!this.Visible)
                {
                    this.Show();
                }
            }
        }
Exemplo n.º 4
0
 public void SetElement(int id, Sprite icon, ScrollElement elem)
 {
     elem.SetUP(id, icon, mInfoArr[id].Title,
                mInfoArr[id].Level.ToString(),
                mInfoArr[id].Contents,
                mInfoArr[id].Cost.ToString());
 }
Exemplo n.º 5
0
        public ScrollElement SetItemInfo(ScrollElement element)
        {
            BuffElement elementForm = element.script as BuffElement;

            elementForm.SetBuff(m_BuffList[element.idx]);
            return(element);
        }
Exemplo n.º 6
0
 internal void AddToSlot(ScrollElement scrollElement)
 {
     if (ScrollElement != null)
     {
         ScrollElement.RemoveFromSlot();
     }
     ScrollElement = scrollElement;
 }
Exemplo n.º 7
0
        ScrollElement IAgentScrollElemetInfos.SetItemInfo(ScrollElement element)
        {
            DragForm form = element.script as DragForm;

            form.id = element.idx;
            form.Init(m_Chips[element.idx], m_Mainform, form.id);
            return(element);
        }
Exemplo n.º 8
0
 protected ScrollElement InitScrollElement(ScrollElement scrollElement, int idx)
 {
     scrollElement.idx = idx;
     if (m_ElementContainer != null)
     {
         scrollElement.rect.SetParent(m_ElementContainer, false);
     }
     scrollElement = m_ElementsAgent.SetItemInfo(scrollElement);
     return(scrollElement);
 }
Exemplo n.º 9
0
    private const float SCALE_ERR_FORGIVENESS = .5f;  // in scale units

    public float CalcError(ScrollElement other)
    {
        var rotDiff = Quaternion.Angle(transform.rotation, other.transform.rotation);
        var error   = Mathf.Clamp(rotDiff / ROT_ERR_FORGIVENESS, 0, 1);

        var scaleDiff = Mathf.Abs(Scale - other.Scale);

        error += Mathf.Clamp(scaleDiff / SCALE_ERR_FORGIVENESS, 0, 1);
        return(error / 2f);
    }
Exemplo n.º 10
0
        public ScrollElement SetItemInfo(ScrollElement element)
        {
            DefaultScrollElement elementScript = element.script as DefaultScrollElement;

            if (element.idx < 0 || element.idx > m_Infos.Length)
            {
                Debug.Log(element.idx);
            }
            elementScript.Init(m_Infos[element.idx]);
            return(element);
        }
Exemplo n.º 11
0
 public void Detach(ScrollElement scrollElement)
 {
     if (scrollElement != null)
     {
         scrollableItems.Remove(scrollElement);
         ResetScroll();
     }
     else
     {
         Debug.LogError("ScrollController.Detach. ScrollElement is null");
     }
 }
Exemplo n.º 12
0
    public void LearnSpell(SpellDescriptor spellD)
    {
        ScrollReserchSlot.ClearSlot();
        GameObject go = Instantiate(ScrollPrefab, SpellBookParent);

        go.SetActive(true);
        ScrollElement se = go.GetComponent <ScrollElement>();

        if (se)
        {
            spellD.Learned = true;
            se.Init(spellD);
        }
    }
Exemplo n.º 13
0
 protected override void OnExecute(GameObject player)
 {
     if (pause)
     {
         ScrollElement.PauseScrolling();
     }
     else if (speed >= 0f)
     {
         ScrollElement.SetScrollSpeed = speed;
     }
     else if (reset)
     {
         ScrollElement.ResetScrolling();
     }
 }
Exemplo n.º 14
0
    private void Start()
    {
        scrollController = GetComponentInParent <ScrollController>();

        if (scrollController != null)
        {
            scrollElement = new ScrollElement {
                bt = buttonStart, transform = gameObject.transform
            };
            scrollController.Attach(scrollElement);
        }
        else
        {
            Debug.LogError("ScrollElement.Start. ScrollController is null");
        }
    }
Exemplo n.º 15
0
    private IEnumerator Timer()
    {
        yield return(new WaitForSeconds(timer));

        if (pause)
        {
            ScrollElement.PauseScrolling();
        }
        else if (reset)
        {
            ScrollElement.ResetScrolling();
        }
        else if (scrollSpeed >= 0f)
        {
            ScrollElement.SetScrollSpeed = scrollSpeed;
        }
    }
Exemplo n.º 16
0
        protected virtual ScrollElement SpawnElement()
        {
            ScrollElement element;

            if (m_PoolOfElements.Count > 0)
            {
                element = m_PoolOfElements.First.Value;
                m_PoolOfElements.RemoveFirst();
            }
            else
            {
                RectTransform         newElementRect = GameObject.Instantiate <RectTransform>(m_SampleElement);
                BaseScrollFormElement elementScript  = newElementRect.GetComponent <BaseScrollFormElement>();
                element = new ScrollElement(newElementRect, elementScript);
            }
            element.rect.gameObject.active = true;
            return(element);
        }
Exemplo n.º 17
0
        protected bool Scroll()
        {
            if (showingElementsNum <= 0)
            {
                if (m_ElementsInfoAgent.GetInfoCount() <= 0)
                {
                    return(false);
                }
            }

            if (showingElementsNum > 0)
            {
                if (IsOutHeadBounce())
                {
                    ScrollElement headElement = RemoveElementFromShoing(0);
                    DisPawnElement(headElement);
                    return(true);
                }

                if (IsOutTailBounce())
                {
                    ScrollElement tailElement = RemoveElementFromShoing(showingElementsNum - 1);
                    DisPawnElement(tailElement);
                    return(true);
                }
            }

            if (IsNeedAddHead())
            {
                ScrollElement headElement = SpawnElement();
                AddHead(headElement);
                return(true);
            }

            if (IsNeedAddTail())
            {
                ScrollElement tailElement = SpawnElement();
                AddTail(tailElement);
                return(true);
            }
            return(false);
        }
    protected override void CalculateSize(int startIndex = 0)
    {
        base.CalculateSize();

        scrollElement.ReadSize();
        elemReuse = datas.Count * scrollElement.size.y > viewPort.rect.height * 2;

        float edge = 0;
        int   flag = 1;

        if (direction == VerticalScrollDirection.TopToBottom)
        {
            flag            = -1;
            edge            = padding.top;
            container.pivot = new Vector2(0.5f, 1);
        }
        else if (direction == VerticalScrollDirection.BottomToTop)
        {
            flag            = 1;
            edge            = padding.bottom;
            container.pivot = new Vector2(0.5f, 0);
        }
        container.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, viewPort.rect.width - padding.horizontal);
        container.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, datas.Count * scrollElement.size.y - padding.vertical);
        for (int i = 0, max = datas.Count; i < max; ++i)
        {
            datas[i].size = scrollElement.size;
            datas[i].pos  = new Vector2(padding.left + scrollElement.size.x / 2, edge + scrollElement.size.y * (i + 0.5f) * flag);
            if (!elemReuse)
            {
                ScrollElement elem = PoolManager.GetObject(prefabStoreKey).GetComponent <ScrollElement>();
                if (null != onItemUpdate && null != elem)
                {
                    onItemUpdate(elem, i, datas[i]);
                }
            }
        }
    }
Exemplo n.º 19
0
 protected abstract void AddTail(ScrollElement tailElement);
Exemplo n.º 20
0
    // Update is called once per frame
    void Update()
    {
        //var mouseX = Input.mousePosition.x / Screen.width;
        //mouseX = Mathf.Clamp(mouseX, 0, 1);
        ////Debug.Log(mouseX);

        //var scrollVisPos = scrollVis.position;
        //scrollVisPos.x = mouseX * _uiWidth;
        //scrollVis.position = scrollVisPos;

        //UpdateScrollables(mouseX);
        var mouseState = GetMouseState();

        //if(mouseState != MouseState.None)
        //    Debug.Log(mouseState.ToString());

        switch (mouseState)
        {
        case MouseState.MouseDown:
            _mouseDownPos = Input.mousePosition;
            Ray ray = Camera.main.ScreenPointToRay(_mouseDownPos);
            foreach (var hit in Physics.RaycastAll(ray))
            {
                ScrollElement scrEl = hit.transform.parent.gameObject.GetComponent <ScrollElement>();
                if (scrEl != null && scrEl.Interactable)
                {
                    _mouseScr = scrEl;
                    _mouseScr.StartScroll();
                    MAIN.uiCont.ShowDragHelper(_mouseDownPos);
                    Debug.Log("Hit ScrollElement! on " + hit.transform.name);
                    break;
                }
            }

            break;

        case MouseState.MouseHold:
            if (_mouseScr == null)     // if the user didn't click a scrollable
            {
                break;
            }

            var mousePos = Input.mousePosition;
            if (_dragMode == DragMode.None)
            {
                CheckForDragMode(mousePos);     //only check if a mode hasn't been determined yet
            }
            if (_dragMode == DragMode.Horiz)
            {
                HandleHorizScroll(mousePos);
            }
            else if (_dragMode == DragMode.Vert)
            {
                HandleVertScroll(mousePos);
            }

            break;

        case MouseState.MouseUp:
            if (_mouseScr != null)
            {
                _mouseScr = null;
                MAIN.uiCont.HideDragHelper();
            }
            _dragMode = DragMode.None;
            break;

        case MouseState.None:
            break;
        }
    }
Exemplo n.º 21
0
 public void RemoveFromSlot()
 {
     ScrollElement = null;
 }
Exemplo n.º 22
0
 public void RenewElement(int id, ScrollElement elem)
 {
     elem.Renew(mInfoArr[id].Level.ToString(), mInfoArr[id].Contents, mInfoArr[id].Cost.ToString());
 }
Exemplo n.º 23
0
 protected virtual void DisPawnElement(ScrollElement element)
 {
     element.rect.gameObject.active = false;
     element.script.Despawn();
     m_PoolOfElements.AddLast(element);
 }
Exemplo n.º 24
0
 protected abstract void AddHead(ScrollElement headElement);