Exemple #1
0
        public MsgTopic CreateGreet()
        {
            //トピックを生成する
            MsgTopic topic = new MsgTopic();

            //各キャラクターの挨拶を取得する
            List <MsgTopic> lst = LiplisModels.Instance.GetGreet();

            //センテンスを入れなおす
            foreach (var charGreet in lst)
            {
                foreach (var sentence in charGreet.TalkSentenceList)
                {
                    topic.TalkSentenceList.Add(sentence);
                }
            }

            //アニバーサリーセンテンスセット
            SetAnniversarySentence(topic);

            //お天気センテンスセット
            SetWetherSentence(topic);

            return(topic);
        }
        /// <summary>
        /// 音声おしゃべり
        /// </summary>
        /// <returns></returns>
        public static IEnumerator GetAudioClip(MsgTopic NowLoadTopic, int AllocationId, int SubId)
        {
            if (AllocationId < 0 || AllocationId > 3)
            {
                //何もしない
            }
            else
            {
                //ソース指定し音楽流す
                //音楽ファイルロード
                using (WWW www = new WWW(UtilVoiceByOS.GetVoiceApiUrl(), CreateRequest(NowLoadTopic, SubId)))
                {
                    ////読み込み完了まで待機
                    //yield return www;

                    // 画像ダウンロード完了を待機
                    while (www.MoveNext())
                    {// コルーチンの終了を待つ
                        yield return(null);
                    }

                    //ダウンロードサイズが5kb以下ならエラーと判断
                    if (www.bytesDownloaded > 5000)
                    {
                        yield return(www.GetAudioClip(true, true, UtilVoiceByOS.GetVoiceFileTypeByOs()));
                    }
                    else
                    {
                        yield return(null);
                    }
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// 特定の話題をおしゃべり
        /// </summary>
        /// <param name="DataKey"></param>
        public void SetTopicTalkFromLastNewsList(string DataKey, ContentCategoly NewsSource)
        {
            //次の話題をロードする
            MsgTopic topic = LiplisStatus.Instance.NewTopic.SearchTopic(DataKey, LiplisModels.Instance.GetModelList());

            //Topicが取得できたら、なうろーどに入れて終了
            if (topic != null)
            {
                //対象リストを洗い替えする
                LiplisStatus.Instance.NewsList.DequeueKeyNewsList(NewsSource, DataKey);

                //カテゴリ修正
                topic.TopicClassification = ((int)NewsSource).ToString();

                //ナウロードセット
                this.NowLoadTopic = topic;

                //ログ追加
                LiplisTalkLog.Instance.AddLog(this.NowLoadTopic.Clone());

                //話題のセット、移動
                StartCoroutine(SetToipcEnd());

                return;
            }

            //Clalisサーバーから対象データ取得
            StartCoroutine(SetTopicTalkFromClalis(DataKey, NewsSource));
        }
Exemple #4
0
    private IEnumerator SetTopicTalkFromClalis(string DataKey, ContentCategoly NewsSource)
    {
        //トピックをランダムで取得する
        var Async = ClalisForLiplisGetNewTopicOne.GetNewTopicAsync(LiplisStatus.Instance.NewTopic.ToneUrlList, DataKey, ((int)NewsSource).ToString());

        //非同期実行
        yield return(Async);

        //取得結果取得
        ResLpsTopicList resTopic = (ResLpsTopicList)Async.Current;

        //現在ロード中の話題をおしゃべり済みに入れる
        if (resTopic != null)
        {
            //話題取得
            this.NowLoadTopic = resTopic.topicList[0];

            //カテゴリセット
            this.NowLoadTopic.TopicClassification = ((int)NewsSource).ToString();

            //おしゃべり済みに追加
            LiplisStatus.Instance.NewTopic.ChattedKeyList.AddToNotDuplicate(this.NowLoadTopic.Clone());

            //話題のセット、移動
            StartCoroutine(SetToipcEnd());

            //ログ追加
            StartCoroutine(NewsLog.AddLog(this.NowLoadTopic.Clone()));
        }
        else
        {
            //だめなら、デフォルト処理
            SetTopicTalkTopicList();
        }
    }
Exemple #5
0
        public MsgTopic TopicListDequeue(List <LiplisModel> ModelList, int retryCnt)
        {
            //次の話題をロードする
            MsgTopic result = LiplisStatus.Instance.NewTopic.TalkTopicList.Dequeue();

            TopicUtil.SetAllocationIdAndTone(result, ModelList);

            //現在ロード中の話題をおしゃべり済みに入れる
            if (!result.FlgNotAddChatted)
            {
                LiplisStatus.Instance.NewTopic.ChattedKeyList.AddToNotDuplicate(result.Clone());
            }

            //話題一致ならそのまま帰す
            if (LiplisSetting.Instance.Setting.CatCheck(result.TopicClassification))
            {
                return(result);
            }
            else
            {
                if (retryCnt > 10)
                {
                    //10回やってダメならそのまま帰す
                    return(result);
                }
                else
                {
                    retryCnt++;
                    return(TopicListDequeue(ModelList, retryCnt));
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// 天気文章をセットする
        ///
        /// TODO CtrlTalk:SetWetherSentence アロケーションIDの付け方再考
        /// </summary>
        /// <param name="topic"></param>
        public void SetWetherSentence(MsgTopic topic)
        {
            //NULLチェック
            if (LiplisStatus.Instance.InfoWether.WetherDtlList == null)
            {
                return;
            }

            if (LiplisStatus.Instance.InfoWether.WetherDtlList.Count < 1)
            {
                return;
            }

            if (topic.TalkSentenceList.Count < 1)
            {
                return;
            }

            //最終センテンス取得
            MsgSentence lastSentence = topic.TalkSentenceList[topic.TalkSentenceList.Count - 1];

            //現在時刻取得
            DateTime dt = DateTime.Now;

            //天気コード取得
            MsgDayWether todayWether = LiplisStatus.Instance.InfoWether.GetWetherSentenceToday(dt);

            //0~12 今日 午前、午後、夜の天気
            if (dt.Hour >= 0 && dt.Hour <= 18)
            {
                //次モデル取得
                LiplisModel model = LiplisModels.Instance.GetCharacterModelNext(lastSentence.AllocationId);

                //センテンス生成
                LiplisWeather.CreateWetherMessage("今日の天気は", todayWether, topic.TalkSentenceList, model.Tone, model.AllocationId);
            }

            //19~23 明日の天気
            else if (dt.Hour >= 19 && dt.Hour <= 23)
            {
                //明日の天気も取得
                MsgDayWether tomorrowWether = LiplisStatus.Instance.InfoWether.GetWetherSentenceTommorow(dt);

                //次モデル取得
                LiplisModel model1 = LiplisModels.Instance.GetCharacterModelNext(lastSentence.AllocationId);

                //1文目追加
                LiplisWeather.CreateWetherMessage("", todayWether, topic.TalkSentenceList, model1.Tone, model1.AllocationId);

                //次モデル取得
                LiplisModel model2 = LiplisModels.Instance.GetCharacterModelNext(model1.AllocationId);

                //2文目追加
                LiplisWeather.CreateWetherMessage("明日の天気は", tomorrowWether, topic.TalkSentenceList, model2.Tone, model2.AllocationId);
            }
        }
Exemple #7
0
        /// <summary>
        /// 天気の話題セット
        /// </summary>
        /// <returns></returns>
        public MsgTopic GetWether()
        {
            //トピックを生成する
            MsgTopic topic = new MsgTopic();

            //今日は~の日です~
            LiplisWeather.SetWetherSentence(topic.TalkSentenceList, Tone, AllocationId);

            return(topic);
        }
Exemple #8
0
        /// <summary>
        /// 今日はなんの日の話題取得
        /// </summary>
        /// <returns></returns>
        public MsgTopic GetAnniversary()
        {
            //トピックを生成する
            MsgTopic topic = new MsgTopic();

            //今日は~の日です~
            SetAnniversarySentence(topic.TalkSentenceList);

            return(topic);
        }
        /// <summary>
        /// ログデータ追加
        /// 過去100件のログを記録する
        /// </summary>
        public void AddLog(MsgTopic topic)
        {
            //ログを追加する
            LogList.Enqueue(topic);

            //100件以上になったら古いものを捨てる
            if (LogList.Count > 100)
            {
                LogList.Dequeue();
            }
        }
Exemple #10
0
    /// <summary>
    /// 割り込み話題リストから取得する
    /// </summary>
    private void SetTopicInterruptTopicList()
    {
        //割り込み話題があれば、そちらから取得する
        this.NowLoadTopic = LiplisStatus.Instance.NewTopic.InterruptTopicList.Dequeue();

        //ログ追加
        StartCoroutine(NewsLog.AddLog(this.NowLoadTopic.Clone()));

        //話題のセット、移動
        StartCoroutine(SetToipcEndInterrupt());
    }
Exemple #11
0
    /// <summary>
    /// トピックリストから取得する
    /// </summary>
    private void SetTopicTalkTopicList()
    {
        //次の話題をロードする
        this.NowLoadTopic = LiplisStatus.Instance.NewTopic.TopicListDequeue(modelController.GetModelList());

        //ログ追加
        StartCoroutine(NewsLog.AddLog(this.NowLoadTopic.Clone()));

        //話題のセット、移動
        StartCoroutine(SetToipcEnd());
    }
Exemple #12
0
        /// <summary>
        /// 降水確率の話題セット
        /// </summary>
        /// <returns></returns>
        public MsgTopic GetChanceOfRain()
        {
            //トピックを生成する
            MsgTopic topic = new MsgTopic();

            //今日は~の日です~
            SetChanceOfRainSentenceToday(topic.TalkSentenceList, DateTime.Now);

            //
            return(topic);
        }
Exemple #13
0
        /// <summary>
        /// トピックリストから取得する
        /// </summary>
        private void SetTopicTalkTopicList()
        {
            //次の話題をロードする
            this.NowLoadTopic = LiplisStatus.Instance.NewTopic.TopicListDequeue(LiplisModels.Instance.GetModelList());

            //ログを記録した後、あらたらなトピックを生成する
            RegisterLogAndCreateLogLoadTopic();

            //話題のセット、移動
            StartCoroutine(SetToipcEnd());
        }
Exemple #14
0
        /// <summary>
        /// 気温の話題セット
        /// </summary>
        /// <returns></returns>
        public MsgTopic GetTemperature()
        {
            //トピックを生成する
            MsgTopic topic = new MsgTopic();

            //今日の気温に対するコメント
            SetTemperatureSentenceToday(topic.TalkSentenceList, DateTime.Now);

            //
            return(topic);
        }
Exemple #15
0
        /// <summary>
        /// キャラクター位置をシャッフルする
        /// </summary>
        public void ShuffleCharPosition(MsgTopic topic)
        {
            //位置リストを取得
            Dictionary <int, Vector3> locationList = SearchLocationList();

            //キャラクターロケーションYリスト
            Dictionary <int, float> CharLocationYList = SearchCharLocationYList();

            //前回キャラクター位置
            List <LiplisModel> PrvCharList = new List <LiplisModel>(ModelList);

            //トピックカウントチェック
            if (topic.TalkSentenceList.Count < 1)
            {
                return;
            }

            //先頭アロケーションID取得
            int allocationId = topic.TalkSentenceList[0].AllocationId;

            //位置リスト
            Queue <int> PosList = new Queue <int>(CreatePosList());

            foreach (LiplisModel model in ModelList)
            {
                model.Position = (PosList.Dequeue());
            }

            //Y座標の補正 身長差の分、位置がずれてしまうため補正
            int idx = 0;

            foreach (LiplisModel model in ModelList)
            {
                //身長差を算出
                float diff = model.LocationY - CharLocationYList[model.Position];

                //移動後Y座標
                float afterMovementY = locationList[model.Position].y + diff;

                //位置リストのY座標を更新
                locationList[model.Position] = new Vector3(locationList[model.Position].x, afterMovementY, locationList[model.Position].z);

                //インデックスインクリメント
                idx++;
            }

            //移動
            foreach (LiplisModel model in ModelList)
            {
                model.ModelLocation = locationList[model.Position];
                model.MoveTarget(locationList[model.Position]);
            }
        }
Exemple #16
0
 /// <summary>
 /// 話題を直接セットする
 /// </summary>
 private void SetTopicDirect()
 {
     try
     {
         //トピックをセット
         StartCoroutine(SetTopicDirectTopic());
     }
     catch
     {
         this.NowLoadTopic = LiplisModels.Instance.CreateTopicFromShortNews();
     }
 }
Exemple #17
0
 /// <summary>
 /// 話題を直接セットする
 /// </summary>
 private void SetTopicDirect()
 {
     try
     {
         //トピックをセット
         StartCoroutine(SetTopicDirectTopic());
     }
     catch
     {
         this.NowLoadTopic = modelController.CreateTopicFromShortNews();
     }
 }
        /// <summary>
        /// リクエストを生成する
        /// </summary>
        /// <param name="NowLoadTopic"></param>
        /// <param name="SubId"></param>
        /// <returns></returns>
        public static WWWForm CreateRequest(MsgTopic NowLoadTopic, int SubId)
        {
            WWWForm ps = new WWWForm();

            //レックトピック生成
            string json = JsonConvert.SerializeObject(TopicUtil.CreateReqTopicVoice(NowLoadTopic.DataKey, SubId, NowLoadTopic.TopicClassification));

            //パラメータ生成
            ps.AddField("reqmsg", json); //トーンURL

            //結果を返す
            return(ps);
        }
Exemple #19
0
        public IEnumerator SetVoiceData(MsgTopic NowLoadTopic, MsgSentence sentence)
        {
            //トーンコンバート
            //sentence.ToneConvert();

            var Async = ClalisForLiplisGetVoiceMp3Ondemand.GetAudioClip(sentence, LiplisModels.Instance.GetModelCount());

            //非同期実行
            yield return(Async);

            //データ取得
            sentence.VoiceData = (AudioClip)Async.Current;
        }
Exemple #20
0
        /// <summary>
        /// 対象データをリストから削除し、おしゃべり済みに移行する
        /// </summary>
        /// <param name="topic"></param>
        /// <returns></returns>
        public MsgTopic TopicListDequeueTargetTopic(MsgTopic topic)
        {
            //次の話題をロードする
            LiplisStatus.Instance.NewTopic.TalkTopicList.Remove(topic);

            //現在ロード中の話題をおしゃべり済みに入れる
            if (!topic.FlgNotAddChatted)
            {
                LiplisStatus.Instance.NewTopic.ChattedKeyList.AddToNotDuplicate(topic.Clone());
            }

            return(topic);
        }
Exemple #21
0
        /// <summary>
        /// アニバーサリーセンテンスをセットする。
        /// </summary>
        /// <param name="topic"></param>
        public void SetAnniversarySentence(MsgTopic topic)
        {
            //データ取得
            ResWhatDayIsToday DataList = LiplisStatus.Instance.InfoAnniversary.DataList;

            if (DataList == null)
            {
                return;
            }

            int sentenceIdx  = 0;
            int AllocationId = 0;

            foreach (var data in DataList.AnniversaryDaysList)
            {
                foreach (MsgSentence talkSentence in data.TalkSentenceList)
                {
                    MsgSentence sentence = talkSentence.Clone();

                    //キャラデータ取得
                    LiplisModel cahrData = LiplisModels.Instance.TableModelId[AllocationId];

                    if (sentenceIdx == 0)
                    {
                        sentence.BaseSentence = "今日は" + sentence.BaseSentence + "みたいです~♪";
                        sentence.ToneConvert();
                        //sentence.TalkSentence = sentence.BaseSentence;
                    }
                    else
                    {
                        sentence.ToneConvert();
                    }

                    //アロケーションID設定
                    sentence.AllocationId = AllocationId;

                    //インデックスインクリメント
                    sentenceIdx++;
                    AllocationId++;

                    //アロケーションIDコントロール
                    if (AllocationId > LiplisModels.Instance.GetMaxAllocationId())
                    {
                        AllocationId = 0;
                    }

                    //センテンスを追加
                    topic.TalkSentenceList.Add(sentence);
                }
            }
        }
Exemple #22
0
    public IEnumerator SetVoiceData(MsgTopic NowLoadTopic, MsgSentence sentence)
    {
        //トーンコンバート
        sentence.ToneConvert();

        //var Async = ClalisForLiplisGetVoiceMp3.GetAudioClip(NowLoadTopic, sentence.AllocationId, sentence.SubId);
        var Async = ClalisForLiplisGetVoiceMp3Ondemand.GetAudioClip(sentence, modelController.GetModelCount());

        //非同期実行
        yield return(Async);

        //データ取得
        sentence.VoiceData = (AudioClip)Async.Current;
    }
Exemple #23
0
        /// <summary>
        /// 適当なニュースを取得する
        /// </summary>
        /// <returns></returns>
        public MsgTopic CreateTopicFromShortNews()
        {
            //一人のデータを取得する
            LiplisModel charData = GetCharacterRandam();

            //おしゃべりメッセージを取得
            MsgTalkMessage msg = ClalisShortNews.getShortNews("", "", "");

            //トピックを生成
            MsgTopic topic = new MsgTopic(charData.Tone, msg.sorce, msg.sorce, 0, 0, false, charData.AllocationId);

            //ショートニュースからトピックを生成する
            return(topic);
        }
Exemple #24
0
        /// <summary>
        /// 割り込み話題リストから取得する
        /// </summary>
        private void SetTopicInterruptTopicList()
        {
            //割り込み話題があれば、そちらから取得する
            this.NowLoadTopic = LiplisStatus.Instance.NewTopic.InterruptTopicList.Dequeue();

            //割り込み次は、即ログに記録するので次回記録されないようにNULLを設定しておく
            this.LogLoadTopic = null;

            //ログ追加
            LiplisTalkLog.Instance.AddLog(this.LogLoadTopic);

            //話題のセット、移動
            SetToipcEndInterrupt();
        }
Exemple #25
0
        /// <summary>
        /// ログトピックを生成する
        /// </summary>
        /// <returns></returns>
        private void RegisterLogAndCreateLogLoadTopic()
        {
            //ログを登録する
            if (this.LogLoadTopic != null)
            {
                LiplisTalkLog.Instance.AddLog(this.LogLoadTopic);
            }

            //ログトピックを生成する
            this.LogLoadTopic = this.NowLoadTopic.Clone();

            //センテンスリストを初期化する
            this.LogLoadTopic.TalkSentenceList.Clear();
        }
Exemple #26
0
        //====================================================================
        //
        //                             パブリックメソッド
        //
        //====================================================================
        #region パブリックメソッド
        /// <summary>
        /// 時間、季節、条件から適切なあいさつを取得する
        /// </summary>
        public MsgTopic GetGreet(LiplisTone Tone)
        {
            //現在時刻取得
            DateTime dt = DateTime.Now;

            //トピックを生成する
            MsgTopic topic = CreateGreetTopic(dt, Tone);

            //今日は~の日です~
            //SetAnniversarySentence(topic.TalkSentenceList);

            //今日の天気は~です
            //SetWetherSentence(topic.TalkSentenceList);

            //生成したトピックを返す
            return(topic);
        }
Exemple #27
0
    /// <summary>
    /// ログを追加する
    /// </summary>
    /// <param name="topic"></param>
    /// <returns></returns>
    public IEnumerator AddLog(MsgTopic topic)
    {
        //クラスの初期化チェック
        InitClass();

        //ログメッセージ生成
        MsgTalkLog log = new MsgTalkLog();

        //データ生成
        log.CREATE_TIME   = topic.CreateTime;
        log.DATA_TYPE     = topic.TopicClassification;
        log.DATAKEY       = topic.DataKey;
        log.TITLE         = topic.Title;
        log.URL           = topic.Url;
        log.THUMBNAIL_URL = topic.ThumbnailUrl;
        log.PANEL_KEY     = log.DATAKEY + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");

        log.TalkSentenceList = topic.TalkSentenceList;

        if (log.TalkSentenceList.Count < 1)
        {
            Debug.Log("明細0件!");
        }

        //スクロール
        MoveAndClean();

        yield return(null);

        //UI生成
        IEnumerator Async = CreateLogUi(log);

        //待ち
        yield return(Async);

        //パネル生成
        GameObject panel = (GameObject)Async.Current;

        //親パネルにセット
        panel.transform.SetParent(Content.transform, false);

        panel.transform.SetAsFirstSibling();

        //パネルリストに追加
        this.PanelList.Add(panel);
    }
Exemple #28
0
        /// <summary>
        /// トピックリストから取得する
        /// </summary>
        private void SetTopicFromResLpsTopicList()
        {
            //次の話題をロードする
            this.NowLoadTopic = LiplisStatus.Instance.NewTopic.GetTopicFromResLpsTopicList(LiplisModels.Instance.GetModelList());


            if (NowLoadTopic.TalkSentenceList.Count < 2)
            {
                Debug.Log("2件以下!");
            }

            //ログ追加
            LiplisTalkLog.Instance.AddLog(this.LogLoadTopic.Clone());

            //話題のセット、移動
            StartCoroutine(SetToipcEnd());
        }
        /// <summary>
        /// 初期のボイスデータをセットする
        /// </summary>
        /// <param name="NowLoadTopic"></param>
        /// <returns></returns>
        public static IEnumerator SetVoiceDataStart(MsgTopic NowLoadTopic, int ModelCount)
        {
            if (NowLoadTopic.TalkSentenceList.Count < 1)
            {
                goto End;
            }

            //センテンス状態チェック
            if (NowLoadTopic.TalkSentenceList[0].VoiceData != null)
            {
                //すでにデータがあれば何もしない
            }
            else if (NowLoadTopic.TalkSentenceList[0].AllocationId < 0 || NowLoadTopic.TalkSentenceList[0].AllocationId >= ModelCount)
            {
                //何もしない
            }
            else
            {
                //ソース指定し音楽流す
                //音楽ファイルロード
                using (WWW www = new WWW(UtilVoiceByOS.GetOndemandVoiceApiUrl(), CreateRequest(NowLoadTopic.TalkSentenceList[0])))
                {
                    // 画像ダウンロード完了を待機
                    while (www.MoveNext())
                    {// コルーチンの終了を待つ
                        yield return(null);
                    }

                    //ダウンロードサイズが5kb以下ならエラーと判断
                    if (www.bytesDownloaded > 5000)
                    {
                        NowLoadTopic.TalkSentenceList[0].VoiceData = www.GetAudioClip(false, false, UtilVoiceByOS.GetVoiceFileTypeByOs());
                    }
                    else
                    {
                        NowLoadTopic.TalkSentenceList[0].VoiceData = null;
                    }
                }
            }

            //終了ラベル
            End :;
        }
Exemple #30
0
 /// <summary>
 /// ボイスデータを取得する
 /// </summary>
 /// <param name="NowLoadTopic"></param>
 /// <returns></returns>
 public void SetVoiceData(MsgTopic NowLoadTopic)
 {
     foreach (MsgSentence sentence in NowLoadTopic.TalkSentenceList)
     {
         //センテンス状態チェック
         if (sentence.VoiceData != null)
         {
             //すでにデータがあれば何もしない
         }
         else if (sentence.AllocationId < 0 || sentence.AllocationId >= LiplisModels.Instance.GetModelCount())
         {
             //何もしない
         }
         else
         {
             StartCoroutine(SetVoiceData(NowLoadTopic, sentence));
         }
     }
 }