Exemplo n.º 1
0
        public Live2dPlay(Live2dPlayableVo playableVo, L2DView l2DView, Action onNextStep)
        {
            _onNextStep = onNextStep;
            _l2DView    = l2DView;
            _playableVo = playableVo;

            if (playableVo.motionName.Contains(L2DConst.MOTION_EYEBLINK))
            {
                _playType = Live2dPlayableVo.Live2dPlayType.EyeBlink;
            }
            else if (playableVo.motionName.Contains(L2DConst.MOTION_MOTIONLESS))
            {
                _playType = Live2dPlayableVo.Live2dPlayType.MontionLess;
            }
            else
            {
                _playType = Live2dPlayableVo.Live2dPlayType.Motion;
            }

            if (playableVo.delay <= 0)
            {
                Play();
            }
            else
            {
                _isDelayState = true;
            }
        }
Exemplo n.º 2
0
        private void OnNextStep()
        {
            _currentIndex++;

            if (_currentIndex >= _playableList.Count)
            {
                //End
                return;
            }

            int playIndex = _playableList[_currentIndex].playIndex;

            List <Live2dPlayableVo> currentPlayableList = new List <Live2dPlayableVo>();

            //找到同一个播放序列的Playable
            for (int i = 0; i < _playableList.Count; i++)
            {
                Live2dPlayableVo playableVo = _playableList[i];

                if (playableVo.playIndex == playIndex)
                {
                    currentPlayableList.Add(playableVo);
                    _currentIndex = i;
                }
            }

            if (currentPlayableList.Count == 0)
            {
                _endCallback?.Invoke();
            }
            else
            {
                PlaySequence(currentPlayableList);
            }
        }
Exemplo n.º 3
0
        public void Play(bool continuePlay = false)
        {
            _currentIndex  = 0;
            _lastPlayIndex = -1;

            List <Live2dPlayableVo> currentPlayableList = new List <Live2dPlayableVo>();

            //找到同一个播放序列的Playable
            for (int i = 0; i < _playableList.Count; i++)
            {
                Live2dPlayableVo playableVo = _playableList[i];

                if (_lastPlayIndex == -1)
                {
                    _lastPlayIndex = playableVo.playIndex;
                }

                if (playableVo.playIndex != _lastPlayIndex)
                {
                    break;
                }

                currentPlayableList.Add(playableVo);
                _currentIndex = i;
            }

            PlaySequence(currentPlayableList, continuePlay);
        }
Exemplo n.º 4
0
        public void UpdatePlayData(Live2dPlayableVo vo)
        {
            if (_playableVo.expressionName != vo.expressionName)
            {
                _l2DView.Model.SetExpression(vo.expressionName);
            }

            if (_playableVo.motionName != vo.motionName)
            {
                int no = _l2DView.Model.MotionList.IndexOf(_playableVo.motionName);
                _l2DView.Model.StartMotion(L2DConst.MOTION_GROUP_IDLE, no, L2DConst.PRIORITY_IDLE, false);
            }

            _playableVo = vo;
        }
Exemplo n.º 5
0
        private void PlaySequence(List <Live2dPlayableVo> list, bool continuePlay = false)
        {
            if (continuePlay == false)
            {
                Reset();
            }

            _sequence = new List <Live2dPlay>();

            for (int i = 0; i < list.Count; i++)
            {
                Live2dPlayableVo playableVo = list[i];
                Live2dPlay       play       = new Live2dPlay(playableVo, _l2DView, OnNextStep);
                _sequence.Add(play);
            }
        }