//更新行弹幕信息
    public void RefreshElementInfo(BulletElementInfo info)
    {
        int index = info.lineIndex;

        _lineArray[index].informedCount++;
        _lineArray[index].lastSpeed = info.speed;
    }
Esempio n. 2
0
    private void Update()
    {
        if (!_availableToMove)
        {
            return;
        }
        Vector2 oldPos = _rect.anchoredPosition;
        float   deltaX = -(_speed * Time.deltaTime);

        _rect.anchoredPosition = new Vector2(oldPos.x + deltaX, oldPos.y);

        Vector2 position = new Vector2(_rect.anchoredPosition.x + _rect.rect.width, startPos.y);

        //右边界进入屏幕内,右侧可以显示弹幕
        if (position.x < startPos.x && _informed == false)
        {
            BulletElementInfo info = new BulletElementInfo(position.x, lineIndex, _speed);
            BulletScreenArranger.Instance.RefreshElementInfo(info);
            _informed = true;
        }
        //右边界出屏幕边缘,隐藏弹幕,回复初始位置
        if (_rect.anchoredPosition.x + _rect.rect.width < 0)
        {
            SetAvailableToMove(false);
        }
    }