コード例 #1
0
ファイル: L2DModel.cs プロジェクト: linxscc/LoveGame
    public void SetExpression(string name, float interval = -1)
    {
        if (!expressions.ContainsKey(name))
        {
            return;
        }
        if (L2DConst.DEBUG_LOG)
        {
            Debug.Log("Setting expression : " + name);
        }
        AMotion motion = expressions[name];

        if (Time.realtimeSinceStartup < _setExpressionTime + _interval)
        {
            return;
        }

        if (L2DConst.DEBUG_LOG)
        {
            Debug.Log("Start expression : " + name);
        }
        _interval          = interval;
        _setExpressionTime = Time.realtimeSinceStartup;
        expressionManager.startMotionPrio(motion, L2DConst.PRIORITY_IDLE);
    }
コード例 #2
0
ファイル: LAppModel.cs プロジェクト: zhixu/live2DTest
 public void startVoiceMotion(AMotion motion, AudioClip acVoice, int priority)
 {
     mainMotionManager.startMotionPrio(motion, priority);
     asVoice.clip     = acVoice;
     asVoice.loop     = false;
     asVoice.panLevel = 0;
     asVoice.Play();
 }
コード例 #3
0
 public int startMotionPrio(AMotion motion, int priority)
 {
     if (priority == reservePriority)
     {
         reservePriority = 0;
     }
     currentPriority = priority;
     return(base.startMotion(motion, false));
 }
コード例 #4
0
ファイル: L2DMotionManager.cs プロジェクト: zhixu/live2DTest
 public int startMotionPrio(AMotion motion, int priority)
 {
     if (priority == reservePriority)
     {
         reservePriority = 0;                 //予約を解除
     }
     currentPriority = priority;              //再生中モーションの優先度を設定
     return(base.startMotion(motion, false)); //第二引数はモーションデータを自動で削除するかどうか。
 }
コード例 #5
0
 public int startMotionPrio(AMotion motion, int priority)
 {
     if (priority == reservePriority)
     {
         reservePriority = 0;
     }
     currentPriority = priority;
     return base.startMotion(motion, false);
 }
コード例 #6
0
 public int startMotionPrio(AMotion motion, int priority)
 {
     if (priority == reservePriority)
     {
         reservePriority = 0;                 // 예약 취소
     }
     currentPriority = priority;              // 재생 중 모션의 우선순위를 결정
     return(base.startMotion(motion, false)); // 두 번째 인수는 모션 데이터를 자동으로 삭제할지 여부
 }
コード例 #7
0
    public void SetExpression(string name)
    {
        if (!expressions.ContainsKey(name))
        {
            return;
        }
        AMotion motion = expressions[name];

        expressionManager.startMotion(motion, false);
    }
コード例 #8
0
ファイル: L2DModel.cs プロジェクト: linxscc/LoveGame
    public void StartMotion(string group, int no, int priority, bool loop)
    {
        _loop = loop;
        _currentMontionIndex = no;

        string motionName = modelSetting.GetMotionFile(group, no);

        if (motionName == null || motionName.Equals(""))
        {
            if (L2DConst.DEBUG_LOG)
            {
                Debug.Log("Motion name is invalid");
            }
            return;
        }


        if (priority == L2DConst.PRIORITY_FORCE)
        {
            mainMotionManager.setReservePriority(priority);
        }
        else if (!mainMotionManager.reserveMotion(priority))
        {
            if (L2DConst.DEBUG_LOG)
            {
                Debug.Log("Do not play because book already playing, or playing a motion already." + motionName);
            }

            return;
        }

        AMotion motion = null;
        string  name   = group + "_" + no;

        if (motions.ContainsKey(name))
        {
            motion = motions[name];
        }

        if (motion == null)
        {
            motion = loadMotion(name, _baseDir + motionName);
        }

        if (motion == null)
        {
            Debug.Log("Failed to read the motion." + motionName);
            mainMotionManager.setReservePriority(0);
            return;
        }

        motion.setFadeIn(modelSetting.GetMotionFadeIn(group, no));
        motion.setFadeOut(modelSetting.GetMotionFadeOut(group, no));
        mainMotionManager.startMotionPrio(motion, priority);
    }
コード例 #9
0
ファイル: L2DModel.cs プロジェクト: linxscc/LoveGame
    public void Update(LIVE2DVIEWTYPE viewType)
    {
        if (live2DModel == null)
        {
            Debug.Log("Can not update there is no model data");
            return;
        }

        if (mainMotionManager.isFinished())
        {
            if (viewType == LIVE2DVIEWTYPE.MAINPANLE)
            {
                EXPRESSIONTRIGERTYPE eType          = EXPRESSIONTRIGERTYPE.NORMAL;
                ExpressionInfo       expressionInfo = ClientData.GetRandomExpression(_modelId, eType);
                if (expressionInfo == null)
                {
                    return;
                }
                string  name   = ExpressionList[expressionInfo.Id];
                AMotion motion = expressions[name];

                int no = UnityEngine.Random.Range(0, MotionList.Count);
                StartMotion(L2DConst.MOTION_GROUP_IDLE, no, L2DConst.PRIORITY_IDLE, _loop);
                if (Time.realtimeSinceStartup > _setExpressionTime + _interval)
                {
                    SetExpression(name);
                }
            }
            else
            {
                StartMotion(L2DConst.MOTION_GROUP_IDLE, _currentMontionIndex, L2DConst.PRIORITY_IDLE, _loop);
            }
        }

        //-----------------------------------------------------------------
        live2DModel.loadParam();
        mainMotionManager.updateParam(live2DModel);


        //眨眼睛
        eyeBlink?.updateParam(live2DModel);
        live2DModel.saveParam();

        expressionManager.updateParam(live2DModel);

        if (physics != null)
        {
            physics.updateParam(live2DModel);
        }


        // live2DModel.update();
    }
コード例 #10
0
    /*
     * 表情を設定する
     * @param motion
     */
    public void SetExpression(string name)
    {
        if (!expressions.ContainsKey(name))
        {
            return;                                // 無効な指定ならなにもしない
        }
        if (LAppDefine.DEBUG_LOG)
        {
            Debug.Log("Setting expression : " + name);
        }
        AMotion motion = expressions[name];

        expressionManager.startMotion(motion, false);
    }
コード例 #11
0
ファイル: L2DModel.cs プロジェクト: skh02083/DatingLive2D
    public void SetExpression(string name, bool noFade)
    {
        if (!expressions.ContainsKey(name))
        {
            Debug.LogError("[L2DModel.InvalidExpresssion]" + name);
            return;
        }
        AMotion motion  = expressions[name];
        int     fadeIn  = (noFade) ? 0 : Define.L2D._expressionFadeDefault;
        int     fadeOut = (noFade) ? 0 : Define.L2D._expressionFadeDefault;

        motion.setFadeIn(fadeIn);
        motion.setFadeOut(fadeOut);
        expressionManager.startMotion(motion, false);
    }
コード例 #12
0
ファイル: L2DModel.cs プロジェクト: skh02083/DatingLive2D
    /// <summary>
    /// 지정한 모션 재생
    /// <para>우선순위, 동일 애니 재생여부 고려하지 않고 진행중인 애니메이션 덮어 씀</para>
    /// </summary>
    private void StartMotion(string group, bool noFade)
    {
        const int no         = 0;
        string    motionName = _modelSetting.GetMotionFile(group, no);

        if (string.IsNullOrEmpty(motionName))
        {
            Debug.LogError("Motion name is invalid. group:" + group + " no:" + no.ToString());
            return;
        }

        AMotion motion = null;
        string  name   = group + "_" + no;

        if (motions.ContainsKey(name))
        {
            motion = motions[name];
        }
        if (motion == null)
        {
            motion = loadMotion(name, _modelHomeDir + motionName);
        }
        if (motion == null)
        {
            Debug.LogError("Failed to read the motion." + motionName);
            return;
        }

        int fadeIn  = (noFade) ? 0 : _modelSetting.GetMotionFadeIn(group, no);
        int fadeOut = (noFade) ? 0 : _modelSetting.GetMotionFadeOut(group, no);

        motion.setFadeIn(fadeIn);
        motion.setFadeOut(fadeOut);

        mainMotionManager.startMotionPrio(motion, Define.L2D._priorityForce);
    }
コード例 #13
0
 public int startMotionPrio(AMotion motion, int priority)
 {
     if (priority == reservePriority)
     {
         reservePriority = 0;// 予約を解除
     }
     currentPriority = priority;// 再生中モーションの優先度を設定
     return base.startMotion(motion, false);// 第二引数はモーションデータを自動で削除するかどうか。
 }
コード例 #14
0
    /*
     *开始运动。
     *检查您是否可以播放,如果不能这样做,则无所事事。
     *如果您可以自动播放,请阅读文件并进行播放。
     *如果它有声音,它也会播放。
     *如果您有关于淡入和淡出的信息,请在此处设置。 如果没有初始值。
     */
    public void StartMotion(string group, int no, int priority)
    {
        string motionName = modelSetting.GetMotionFile(group, no);

        if (motionName == null || motionName.Equals(""))
        {
            if (LAppDefine.DEBUG_LOG)
            {
                Debug.Log("Motion name is invalid");
            }
            return;//
        }

        //将新动作的优先级与当前正在播放的动作,保留动作的优先级进行比较
        //如果可以预约(如果优先级高)则保留播放。
        //
        //在此帧中立即播放保留的新动作,或者如果需要加载声音等。
        //在以下帧开始播放。
        if (priority == LAppDefine.PRIORITY_FORCE)
        {
            mainMotionManager.setReservePriority(priority);
        }
        else if (!mainMotionManager.reserveMotion(priority))
        {
            if (LAppDefine.DEBUG_LOG)
            {
                Debug.Log("Do not play because book already playing, or playing a motion already." + motionName);
            }
            return;
        }

        AMotion motion = null;
        string  name   = group + "_" + no;

        if (motions.ContainsKey(name))
        {
            motion = motions[name];
        }
        if (motion == null)
        {
            motion = loadMotion(name, modelHomeDir + motionName);
        }
        if (motion == null)
        {
            Debug.Log("Failed to read the motion." + motionName);
            mainMotionManager.setReservePriority(0);
            return;
        }

        // フェードイン、フェードアウトの設定
        motion.setFadeIn(modelSetting.GetMotionFadeIn(group, no));
        motion.setFadeOut(modelSetting.GetMotionFadeOut(group, no));


        if ((modelSetting.GetMotionSound(group, no)) == null)
        {
            // 音声が無いモーションは即時再生を開始します。
            if (LAppDefine.DEBUG_LOG)
            {
                Debug.Log("Start motion : " + motionName);
            }
            mainMotionManager.startMotionPrio(motion, priority);
        }
        else
        {
            // 音声があるモーションは音声のロードを待ってから再生を開始します。
            string soundPath = modelSetting.GetMotionSound(group, no);
            soundPath = Regex.Replace(soundPath, ".mp3$", "");// 不要な拡張子を削除

            AudioClip acVoice = FileManager.LoadAssetsSound(modelHomeDir + soundPath);
            if (LAppDefine.DEBUG_LOG)
            {
                Debug.Log("Start motion : " + motionName + "  voice : " + soundPath);
            }
            StartVoice(acVoice);
            mainMotionManager.startMotionPrio(motion, priority);
        }
    }
コード例 #15
0
ファイル: LAppModel.cs プロジェクト: zhixu/live2DTest
    public void startMotion(string name, int no, int priority)
    {
        Debug.Log("starting motion name: " + name);

        string motionName = modelSetting.getMotionFile(name, no);

        if (motionName == null || motionName.Equals(""))
        {
            if (LAppDefine.DEBUG_LOG)
            {
                Debug.Log("Motion name is invalid");
            }
            return;            //
        }

        //overwrites the force priority

        /*if (priority == LAppDefine.PRIORITY_FORCE) {
         * mainMotionManager.setReservePriority(priority);
         * }
         * else*/if (!mainMotionManager.reserveMotion(priority))
        {
            Debug.Log("Do not play because book already playing, or playing a motion already");

            if (LAppDefine.DEBUG_LOG)
            {
                Debug.Log("Do not play because book already playing, or playing a motion already");
            }
            return;
        }

        AMotion motion = FileManager.loadAssetsMotion(motionName);

        if (motion == null)
        {
            Debug.Log("Failed to read the motion.");
            mainMotionManager.setReservePriority(0);
            return;
        }

        motion.setFadeIn(modelSetting.getMotionFadeIn(name, no));
        motion.setFadeOut(modelSetting.getMotionFadeOut(name, no));


        if ((modelSetting.getMotionSound(name, no)) == null)
        {
            if (LAppDefine.DEBUG_LOG)
            {
                Debug.Log("Start motion : " + motionName);
            }
            mainMotionManager.startMotionPrio(motion, priority);
        }
        else
        {
            string soundPath = modelSetting.getMotionSound(name, no);
            soundPath = Regex.Replace(soundPath, ".mp3$", "");//不要な拡張子を削除

            AudioClip acVoice = FileManager.loadAssetsSound(soundPath);
            if (LAppDefine.DEBUG_LOG)
            {
                Debug.Log("Start motion : " + motionName + "  voice : " + soundPath);
            }
            startVoiceMotion(motion, acVoice, priority);
        }
    }
コード例 #16
0
    /*
     * モーションの開始。
     * 再生できる状態かチェックして、できなければ何もしない。
     * 再生出来る場合は自動でファイルを読み込んで再生。
     * 音声付きならそれも再生。
     * フェードイン、フェードアウトの情報があればここで設定。なければ初期値。
     */
    public void StartMotion(string group, int no, int priority)
    {
        string motionName = modelSetting.GetMotionFile(group, no);

        if (motionName == null || motionName.Equals(""))
        {
            if (LAppDefine.DEBUG_LOG)
            {
                Debug.Log("Motion name is invalid");
            }
            return;//
        }

        // 新しいモーションのpriorityと、再生中のモーション、予約済みモーションのpriorityと比較して
        // 予約可能であれば(優先度が高ければ)再生を予約します。
        //
        // 予約した新モーションは、このフレームで即時再生されるか、もしくは音声のロード等が必要な場合は
        // 以降のフレームで再生開始されます。
        if (priority == LAppDefine.PRIORITY_FORCE)
        {
            mainMotionManager.setReservePriority(priority);
        }
        else if (!mainMotionManager.reserveMotion(priority))
        {
            if (LAppDefine.DEBUG_LOG)
            {
                Debug.Log("Do not play because book already playing, or playing a motion already." + motionName);
            }
            return;
        }

        AMotion motion = null;
        string  name   = group + "_" + no;

        if (motions.ContainsKey(name))
        {
            motion = motions[name];
        }
        if (motion == null)
        {
            motion = loadMotion(name, modelHomeDir + motionName);
        }
        if (motion == null)
        {
            Debug.Log("Failed to read the motion." + motionName);
            mainMotionManager.setReservePriority(0);
            return;
        }

        // フェードイン、フェードアウトの設定
        motion.setFadeIn(modelSetting.GetMotionFadeIn(group, no));
        motion.setFadeOut(modelSetting.GetMotionFadeOut(group, no));


        if ((modelSetting.GetMotionSound(group, no)) == null)
        {
            // 音声が無いモーションは即時再生を開始します。
            if (LAppDefine.DEBUG_LOG)
            {
                Debug.Log("Start motion : " + motionName);
            }
            mainMotionManager.startMotionPrio(motion, priority);
        }
        else
        {
            // 音声があるモーションは音声のロードを待ってから再生を開始します。
            string soundPath = modelSetting.GetMotionSound(group, no);
            soundPath = Regex.Replace(soundPath, ".mp3$", "");// 不要な拡張子を削除

            AudioClip acVoice = FileManager.LoadAssetsSound(modelHomeDir + soundPath);
            if (LAppDefine.DEBUG_LOG)
            {
                Debug.Log("Start motion : " + motionName + "  voice : " + soundPath);
            }
            StartVoice(acVoice);
            mainMotionManager.startMotionPrio(motion, priority);
        }
    }
コード例 #17
0
    public void StartMotion(string group, int no, int priority)
    {
        string motionName = modelSetting.GetMotionFile(group, no);

        if (motionName == null || motionName.Equals(""))
        {
            if (LAppDefine.DEBUG_LOG)
            {
                Debug.Log("Motion name is invalid");
            }
            return;//
        }



        //


        if (priority == LAppDefine.PRIORITY_FORCE)
        {
            mainMotionManager.setReservePriority(priority);
        }
        else if (!mainMotionManager.reserveMotion(priority))
        {
            if (LAppDefine.DEBUG_LOG)
            {
                Debug.Log("Do not play because book already playing, or playing a motion already." + motionName);
            }
            return;
        }

        AMotion motion = null;
        string  name   = group + "_" + no;

        if (motions.ContainsKey(name))
        {
            motion = motions[name];
        }
        if (motion == null)
        {
            motion = loadMotion(name, modelHomeDir + motionName);
        }
        if (motion == null)
        {
            Debug.Log("Failed to read the motion." + motionName);
            mainMotionManager.setReservePriority(0);
            return;
        }


        motion.setFadeIn(modelSetting.GetMotionFadeIn(group, no));
        motion.setFadeOut(modelSetting.GetMotionFadeOut(group, no));


        if ((modelSetting.GetMotionSound(group, no)) == null)
        {
            if (LAppDefine.DEBUG_LOG)
            {
                Debug.Log("Start motion : " + motionName);
            }
            mainMotionManager.startMotionPrio(motion, priority);
        }
        else
        {
            string soundPath = modelSetting.GetMotionSound(group, no);
            soundPath = Regex.Replace(soundPath, ".mp3$", "");

            AudioClip acVoice = FileManager.LoadAssetsSound(modelHomeDir + soundPath);
            if (LAppDefine.DEBUG_LOG)
            {
                Debug.Log("Start motion : " + motionName + "  voice : " + soundPath);
            }
            StartVoice(acVoice);
            mainMotionManager.startMotionPrio(motion, priority);
        }
    }
コード例 #18
0
    /*
     * モーションの開始。
     * 再生できる状態かチェックして、できなければ何もしない。
     * 再生出来る場合は自動でファイルを読み込んで再生。
     * 音声付きならそれも再生。
     * フェードイン、フェードアウトの情報があればここで設定。なければ初期値。
     */
    public void StartMotion(string group, int no, int priority)
    {
        string motionName = modelSetting.GetMotionFile(group, no);

        if (motionName == null || motionName.Equals(""))
        {
            if (LAppDefine.DEBUG_LOG)
            {
                Debug.Log("Motion name is invalid");
            }
            return;//
        }

        // 新しいモーションのpriorityと、再生中のモーション、予約済みモーションのpriorityと比較して
        // 予約可能であれば(優先度が高ければ)再生を予約します。
        //
        // 予約した新モーションは、このフレームで即時再生されるか、もしくは音声のロード等が必要な場合は
        // 以降のフレームで再生開始されます。
        if (priority == LAppDefine.PRIORITY_FORCE)
        {
            mainMotionManager.setReservePriority(priority);
        }
        else if (!mainMotionManager.reserveMotion(priority))
        {
            if (LAppDefine.DEBUG_LOG)
            {
                Debug.Log("Do not play because book already playing, or playing a motion already." + motionName);
            }
            return;
        }

        AMotion motion = null;
        string  name   = group + "_" + no;

        if (motions.ContainsKey(name))
        {
            motion = motions[name];
        }
        if (motion == null)
        {
            motion = loadMotion(name, modelHomeDir + motionName);
        }
        if (motion == null)
        {
            Debug.Log("Failed to read the motion." + motionName);
            mainMotionManager.setReservePriority(0);
            return;
        }

        // フェードイン、フェードアウトの設定
        motion.setFadeIn(modelSetting.GetMotionFadeIn(group, no));
        motion.setFadeOut(modelSetting.GetMotionFadeOut(group, no));


        if ((modelSetting.GetMotionSound(group, no)) == null)
        {
            // 音声が無いモーションは即時再生を開始します。
            if (LAppDefine.DEBUG_LOG)
            {
                Debug.Log("Start motion : " + motionName);
            }
            mainMotionManager.startMotionPrio(motion, priority);
            TextBoxManager.StartText(group, no);
        }
        else
        {
            // 音声があるモーションは音声のロードを待ってから再生を開始します。
            string soundPath = modelSetting.GetMotionSound(group, no);
            soundPath = Regex.Replace(soundPath, ".mp3$", "");// 不要な拡張子を削除

            AudioClip acVoice = FileManager.LoadAssetsSound(modelHomeDir + soundPath);
            if (LAppDefine.DEBUG_LOG)
            {
                Debug.Log("Start motion : " + motionName + "  voice : " + soundPath);
            }
            StartVoice(acVoice);
            mainMotionManager.startMotionPrio(motion, priority);
            TextBoxManager.StartText(group, no);
        }

        //追加 独自に音声再生
        if (LAppLive2DManager.sceneIndex == 1)
        {
            if (motionName == "motions/m_3.mtn")
            {
                AudioSource[] surval = GameObject.Find("Live2D_Canvas_Surval").GetComponents <AudioSource> ();
                surval [2].PlayOneShot(surval [2].clip);                 //うぎゃーーーー
            }
            else if (motionName == "motions/m_2.mtn")
            {
                AudioSource[] surval = GameObject.Find("Live2D_Canvas_Surval").GetComponents <AudioSource> ();
                System.Random r      = new System.Random();
                if (r.Next(0, 10) < 4)
                {
                    surval [3].PlayOneShot(surval [3].clip);                     //わーーい
                }
                else if (r.Next(0, 10) > 6)
                {
                    surval [0].PlayOneShot(surval [0].clip);                     //きもちーー
                }
                else
                {
                    surval [1].PlayOneShot(surval [1].clip);                     //たーのしー
                }
            }
        }
    }