/// <summary>
        /// 最新データをダウンロードする
        /// </summary>
        /// <returns></returns>
        private IEnumerator SetLastNews()
        {
            //最新ニュースデータ取得
            var Async = ClalisForLiplisGetNewsList.GetNewsList();

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

            //データ取得
            ResLpsBaseNewsList DataList = (ResLpsBaseNewsList)Async.Current;

            //データセット
            LiplisStatus.Instance.NewsList.SetData(DataList);

            //取得ニュースデータ保存
            CoroutineHandler.StartStaticCoroutine(Save());

            //最終更新時刻設定
            LiplisStatus.Instance.NewsList.LastUpdateTime = LpsDatetimeUtil.Now;

            //要求データセット
            LiplisCache.Instance.ImagePath.SetRequestUrlQ();

            yield return(null);
        }
Exemple #2
0
        private IEnumerator setRemoteDesc(RTCSdpType type, string sdp)
        {
            var desc = new RTCSessionDescription
            {
                type = type,
                sdp  = sdp
            };

            OnLogEvent.Invoke($"SetRemoteDescription {type}", "");
            var opSetDesc = peer.SetRemoteDescription(ref desc);

            yield return(opSetDesc);

            if (opSetDesc.IsError)
            {
                OnErrorEvent.Invoke($"SetRemoteDescription {type}", opSetDesc.Error.message);
                yield break;
            }

            if (type == RTCSdpType.Offer)
            {
                yield return(CoroutineHandler.StartStaticCoroutine(sendDesc(RTCSdpType.Answer)));
            }
            else
            {
                OnOpen.Invoke();
            }
        }
        public override void ChangePhase(Phase changedPhase)
        {
            if (!Initialized)
            {
                return;
            }
            switch (changedPhase)
            {
            case Phase.P2D:
                vcams[1].SetActive(false);
                vcams[2].SetActive(false);
                switch (LastAttackPlayerNum)
                {
                case 0:
                    CoroutineHandler.StartStaticCoroutine(LerpCamView(0, new Rect(0, 0, 1, 1), 0.25f));
                    CoroutineHandler.StartStaticCoroutine(LerpCamView(1, new Rect(1, 0, 0, 1), 0.25f));
                    break;

                case 1:
                    CoroutineHandler.StartStaticCoroutine(LerpCamView(0, new Rect(0, 0, 0, 1), 0.25f));
                    CoroutineHandler.StartStaticCoroutine(LerpCamView(1, new Rect(0, 0, 1, 1), 0.25f));
                    break;
                }

                break;

            case Phase.P3D:
                vcams[1].SetActive(true);
                vcams[2].SetActive(true);
                CoroutineHandler.StartStaticCoroutine(LerpCamView(0, new Rect(0, 0, 0.5f, 1), 0.25f));
                CoroutineHandler.StartStaticCoroutine(LerpCamView(1, new Rect(0.5f, 0, 0.5f, 1), 0.25f));
                break;
            }
        }
Exemple #4
0
    static public IEnumerator LoadDatabase(List <string> packages)
    {
        if (m_SkinsDict == null)
        {
            m_SkinsDict = new Dictionary <string, Skin>();

            foreach (string s in packages)
            {
                AssetBundleLoadAssetOperation op = AssetBundleManager.LoadAssetAsync(s, "skin", typeof(GameObject));
                yield return(CoroutineHandler.StartStaticCoroutine(op));

                Skin c = op.GetAsset <GameObject>().GetComponent <Skin>();
                if (c != null)
                {
                    m_SkinsDict.Add(c.skinName, c);
                    m_skinNameList.Add(c.skinName);
                    overlapCharNameList.Add(c.characterName);
                }
            }

            for (int i = 0; i < overlapCharNameList.Count; i++)
            {
                if (!m_charNameList.Contains(overlapCharNameList[i]))
                {
                    m_charNameList.Add(overlapCharNameList[i]);
                }
            }

            m_Loaded = true;
        }
    }
Exemple #5
0
    public override void Enter(AState from)
    {
        m_CountdownRectTransform = countdownText.GetComponent <RectTransform>();

        m_LifeHearts = new Image[k_MaxLives];

        for (int i = 0; i < k_MaxLives; ++i)
        {
            m_LifeHearts[i] = lifeRectTransform.GetChild(i).GetComponent <Image>();
        }


        if (MusicPlayer.instance.GetStem(0) != gameTheme)
        {
            MusicPlayer.instance.SetStem(0, gameTheme);
            CoroutineHandler.StartStaticCoroutine(MusicPlayer.instance.RestartAllStems());
        }


        m_AdsInitialised = false;

        m_GameoverSelectionDone = false;


        StartGame();
    }
Exemple #6
0
        public static void TweetWithImage(string gameId, string text, params string[] hashTags)
        {
            if (_currentCoroutine != null)
            {
                Debug.Log("画像アップロード中に多重呼び出しされました。");
                return;
            }

            var tweetData = new TweetData(gameId, text, hashTags);

            var title = tweetData.GameUrl;
            var desc  = text;

            _currentCoroutine = CoroutineHandler.StartStaticCoroutine(
                GyazoUploader.CaptureScreenshotAndUpload(
                    title
                    , desc
                    , (res, error) =>
            {
                if (string.IsNullOrEmpty(error))
                {
                    Debug.Log("画像アップロード成功 : " + res.permalink_url);
                    //エラーなし => ツイートする
                    tweetData.ImageUrl = res.permalink_url;
                    Tweet(tweetData);
                }
                else
                {
                    //エラーあり
                    Debug.LogError("画像アップロード失敗 : " + error);
                }

                _currentCoroutine = null;
            }));
        }
    // File management

    static public void Create()
    {
        if (m_Instance == null)
        {
            m_Instance = new PlayerData();

            //if we create the PlayerData, mean it's the very first call, so we use that to init the database
            //this allow to always init the database at the earlier we can, i.e. the start screen if started normally on device
            //or the Loadout screen if testing in editor
            CoroutineHandler.StartStaticCoroutine(CharacterDatabase.LoadDatabase());
            CoroutineHandler.StartStaticCoroutine(ThemeDatabase.LoadDatabase());
        }

        m_Instance.saveFile = Application.persistentDataPath + "/save.bin";

        if (File.Exists(m_Instance.saveFile))
        {
            // If we have a save, we read it.
            m_Instance.Read();
        }
        else
        {
            // If not we create one with default data.
            NewSave();
        }

        m_Instance.CheckMissionsCount();
    }
Exemple #8
0
        //Android用 TODO そのままCoroutineで返したほうがいい
        static void CopyFile(IObserver <Unit> observer, string fileName)
        {
            string baseFilePath   = string.Format("{0}/{1}.json", Application.streamingAssetsPath, fileName);
            string targetFilePath = string.Format("{0}/{1}.json", Application.persistentDataPath, fileName);

            CoroutineHandler.StartStaticCoroutine(CopyFileCoroutine(observer, baseFilePath, targetFilePath));
        }
Exemple #9
0
    // Use this for initialization
    void Start()
    {
        BehaviorTree tree = new BehaviorTree();

        tree.Prepare();
        tree.Awake();
        CoroutineHandler.StartStaticCoroutine(tree.Update());
    }
Exemple #10
0
 public static void Shake(this Camera camera, float duration)
 {
     if (_startingCoroutine != null)
     {
         CoroutineHandler.StopStaticCoroutine(_startingCoroutine);
     }
     _startingCoroutine = CoroutineHandler.StartStaticCoroutine(_Shake(camera.transform, duration));
 }
 public override void Use(Status status)
 {
     status.IsDefenseUpping = true;
     if (_coroutine != null)
     {
         CoroutineHandler.StopStaticCoroutine(_coroutine);
     }
     _coroutine = CoroutineHandler.StartStaticCoroutine(_DefenseUpOFF(status));
 }
    protected override void Show()
    {
        if (coroutine != null)
        {
            CoroutineHandler.StopStaticCoroutine(coroutine);
        }
        var color = colors[currentIndex].color;

        coroutine = CoroutineHandler.StartStaticCoroutine(ChangeColor(color));
    }
Exemple #13
0
        public void Start()
        {
            if (Application.isEditor)
            {
                reciever.Open(port);
                isActive = true;

                CoroutineHandler.StartStaticCoroutine(Update());
            }
        }
    // Use this for initialization
    void Start()
    {
        if (MusicPlayer.instance.GetStem(0) != gameTheme)
        {
            MusicPlayer.instance.SetStem(0, gameTheme);
            CoroutineHandler.StartStaticCoroutine(MusicPlayer.instance.RestartAllStems());
        }

        StartGame();
    }
Exemple #15
0
        // first parameter needs to be a fileName, not a pathName because fileName will be used for capturing
        public static void CaptureAndSaveToAlbum(string fileName, Action callback)
        {
            string pathToSave = Application.persistentDataPath + "/" + fileName;

            File.Delete(pathToSave);
            ScreenCapture.CaptureScreenshot(fileName);

            // cannot use StartCoroutine() because this static class does not inherit Monobehaviour
            CoroutineHandler.StartStaticCoroutine(SaveToCameraroll(pathToSave, callback));
        }
Exemple #16
0
 private void Next()
 {
     if (_tweenQueue.Count > 0 && _isReady)
     {
         _isReady      = false;
         _currentTween = _tweenQueue.Dequeue();
         _coroutine    = _currentTween.Execution();
         CoroutineHandler.StartStaticCoroutine(_coroutine);
     }
 }
Exemple #17
0
    static IEnumerator AsyncLoad()
    {
        // Android store streams assets in a compressed archive, so different file system.
#if !UNITY_EDITOR
#if UNITY_ANDROID
        AssetBundleManager.BaseDownloadingURL = Application.streamingAssetsPath + "/AssetBundles/" + Utility.GetPlatformName() + "/";
#else
        AssetBundleManager.BaseDownloadingURL = "file://" + Application.streamingAssetsPath + "/AssetBundles/" + Utility.GetPlatformName() + "/";
#endif
#else
        AssetBundleManager.BaseDownloadingURL = "file://" + Application.streamingAssetsPath + "/AssetBundles/" + Utility.GetPlatformName() + "/";
#endif

        var request = AssetBundleManager.Initialize();
        if (request != null)
        {
            yield return(CoroutineHandler.StartStaticCoroutine(request));
        }

        // In editor we can directly get all the bundles but in final build, we need to read them from the manifest.
#if UNITY_EDITOR
        string[] bundles;
        if (AssetBundleManager.SimulateAssetBundleInEditor)
        {
            bundles = AssetDatabase.GetAllAssetBundleNames();
        }
        else
        {
            bundles = AssetBundleManager.AssetBundleManifestObject.GetAllAssetBundles();
        }
#else
        string[] bundles = AssetBundleManager.AssetBundleManifestObject.GetAllAssetBundles();
#endif

        List <string> characterPackage = new List <string>();
        List <string> themePackage     = new List <string>();

        for (int i = 0; i < bundles.Length; ++i)
        {
            if (bundles[i].StartsWith("characters/"))
            {
                characterPackage.Add(bundles[i]);
            }
            else if (bundles[i].StartsWith("themes/"))
            {
                themePackage.Add(bundles[i]);
            }
        }

        yield return(CoroutineHandler.StartStaticCoroutine(CharacterDatabase.LoadDatabase(characterPackage)));

        yield return(CoroutineHandler.StartStaticCoroutine(ThemeDatabase.LoadDatabase(themePackage)));
    }
        /// <summary>
        /// リクエスト(オブジェクト)を JSON に変換して HTTP(POST)通信を行う
        /// </summary>
        /// <typeparam name="T">リクエスト型</typeparam>
        /// <param name="request">リクエストのオブジェクト</param>
        /// <param name="cb">コールバック</param>
        public void Send <T>(ref T request, Action <Result> cb)
        {
            // リクエストオブジェクトを JSON に変換(byte配列)
            string reqJson = JsonUtility.ToJson(request);

            byte[] postData = System.Text.Encoding.UTF8.GetBytes(reqJson);

            // HTTP(POST)通信
            var url = BaseUrl + EndPoint;

            CoroutineHandler.StartStaticCoroutine(onSend(url, postData, cb));
        }
Exemple #19
0
        public BrainSensor()
        {
            messages = new OSCMessage[datas.Length];

            reciever = new OSCReciever();
            if (!Application.isEditor)
            {
                reciever.Open(port);
                isActive = true;

                CoroutineHandler.StartStaticCoroutine(Update());
            }
        }
Exemple #20
0
        public override void Use(Status status)
        {
            status.SP.IsKeepMax = true;
            status.SP.Reset();

            if (_coroutine != null)
            {
                CoroutineHandler.StopStaticCoroutine(_coroutine);
            }
            else
            {
                _coroutine = CoroutineHandler.StartStaticCoroutine(_SPKeepMaxSwitch(effectTime, status));
            }
        }
        /// <summary>
        /// 古いデータを削除する
        /// </summary>
        /// <returns></returns>
        private IEnumerator DeleteOldData()
        {
            //指定条件に合致するデータを削除する
            LiplisStatus.Instance.NewTopic.DeleteOldData();

            //削除まで終わったらセーブする
            CoroutineHandler.StartStaticCoroutine(Save());

            //古いサムネイルを削除する
            LiplisCache.Instance.ImagePath.Clean();

            //繰越
            yield return(new WaitForSeconds(1f));
        }
Exemple #22
0
        private void connectPeer()
        {
            OnLogEvent.Invoke("new RTCPeerConnection", "");
            peer = new RTCPeerConnection(ref peerConfig);
            peer.OnConnectionStateChange = connectionState =>
            {
                OnLogEvent.Invoke("OnConnectionStateChange", connectionState.ToString());
            };
            peer.OnDataChannel = channel =>
            {
                dataChannel = channel;
                setupDataChannelEventHandler();
                OnLogEvent.Invoke("OnDataChannel", channel.Label);
            };
            peer.OnIceCandidate = candidate =>
            {
                OnLogEvent.Invoke("OnIceCandidate", "");
                OnLogEvent.Invoke("Send IceCandidate", "");
                signaling.SendIceCandidate(streamId, candidate.Candidate, candidate.SdpMLineIndex.Value, candidate.SdpMid);
            };
            peer.OnIceGatheringStateChange = state =>
            {
                OnLogEvent.Invoke("OnIceGatheringStateChange", state.ToString());
            };
            peer.OnNegotiationNeeded = () =>
            {
                OnLogEvent.Invoke("OnNegotiationNeeded", "");
            };
            peer.OnTrack = evt =>
            {
                OnLogEvent.Invoke("OnTrack", evt.Track.Kind.ToString());
                if (evt.Track is VideoStreamTrack track)
                {
                    var texture = track.InitializeReceiver(videoWidth, videoHeight);
                    OnVideoTrack.Invoke(texture);
                }
            };

            var dcOptions = new RTCDataChannelInit();

            OnLogEvent.Invoke("CreateDataChannel", "testDC");
            dataChannel = peer.CreateDataChannel("testDC", dcOptions);
            setupDataChannelEventHandler();
            if (clientType == ClientType.Publisher)
            {
                var videoTrack = new VideoStreamTrack("VideoTrack", renderTexture);
                peer.AddTrack(videoTrack);
                CoroutineHandler.StartStaticCoroutine(sendDesc(RTCSdpType.Offer));
            }
        }
Exemple #23
0
        public static void Stop(Dictionary <string, string> metadata)
        {
            isReady = false;

            m_EndTime = Time.realtimeSinceStartup;
            m_Promisess.Clear();
            for (var i = 0; i < m_Sensors.Count; i++)
            {
                m_Promisess.Add((m_Sensors[i].Stop()));
            }

            #if !UNITY_EDITOR
            CoroutineHandler.StartStaticCoroutine(UploadAll());
                #endif
        }
        //====================================================================
        //
        //                        天気情報収集
        //
        //====================================================================
        #region 天気情報収集

        /// <summary>
        /// 天気情報収集
        /// </summary>
        public IEnumerator DataCollectWether()
        {
            //トークインスタンス取得
            DatWether Wether = LiplisStatus.Instance.InfoWether;

            //指定時間経過していなければ抜ける
            if (LpsDatetimeUtil.dec(Wether.LastUpdateTime).AddMinutes(60) > DateTime.Now)
            {
                goto End;
            }

            //最新データをダウンロードする
            yield return(CoroutineHandler.StartStaticCoroutine(SetWether(Wether)));

            //終了ラベル
            End :;
        }
        /// <summary>
        /// 最新のニュースリストを取得する
        /// </summary>
        /// <returns></returns>
        public IEnumerator SetLastNewsList()
        {
            //トークインスタンス取得
            DatNewsList newsList = LiplisStatus.Instance.NewsList;

            //指定時間経過していなければ抜ける
            if (LpsDatetimeUtil.dec(newsList.LastUpdateTime).AddMinutes(60) > DateTime.Now)
            {
                goto End;
            }

            //最新データをダウンロードする
            yield return(CoroutineHandler.StartStaticCoroutine(SetLastNews()));

            //終了ラベル
            End :;
        }
        //====================================================================
        //
        //                        位置情報収集
        //
        //====================================================================
        #region 位置情報収集

        /// <summary>
        /// 位置情報収集
        /// </summary>
        public IEnumerator DataCollectLocation()
        {
            //トークインスタンス取得
            DatLocation Location = LiplisStatus.Instance.InfoLocation;

            //指定時間経過していなければ抜ける
            if (LpsDatetimeUtil.dec(Location.LastUpdateTime).AddMinutes(10) > DateTime.Now)
            {
                goto End;
            }

            //最新データをダウンロードする
            yield return(CoroutineHandler.StartStaticCoroutine(SetLocation(Location)));

            //終了ラベル
            End :;
        }
        /// <summary>
        /// データ収集処理
        /// </summary>
        //private void DataCollect()
        private IEnumerator DataCollect()
        {
            //地域データ取得
            yield return(CoroutineHandler.StartStaticCoroutine(cc.DataCollectLocation()));

            //本日情報データ取得
            yield return(CoroutineHandler.StartStaticCoroutine(cc.DataCollectAnniversaryDays()));

            //天気情報収集
            yield return(CoroutineHandler.StartStaticCoroutine(cc.DataCollectWether()));

            //ニュースリスト取得
            yield return(CoroutineHandler.StartStaticCoroutine(cc.SetLastNewsList()));

            //ニュースデータ取得
            if (LiplisStatus.Instance.NewTopic.TalkTopicList.Count <= 25)
            {
                yield return(CoroutineHandler.StartStaticCoroutine(cc.DataCollectNewTopic()));
            }
        }
    static public IEnumerator LoadDatabase(List <string> packages)
    {
        if (m_CharactersDict == null)
        {
            m_CharactersDict = new Dictionary <string, Character>();

            foreach (string s in packages)
            {
                AssetBundleLoadAssetOperation op = AssetBundleManager.LoadAssetAsync(s, "character", typeof(GameObject));
                yield return(CoroutineHandler.StartStaticCoroutine(op));

                Character c = op.GetAsset <GameObject>().GetComponent <Character>();
                if (c != null)
                {
                    m_CharactersDict.Add(c.characterName, c);
                }
            }

            m_Loaded = true;
        }
    }
Exemple #29
0
    static public IEnumerator LoadDatabase(List <string> packages)
    {
        // If not null the dictionary was already loaded.
        if (themeDataList == null)
        {
            themeDataList = new Dictionary <string, ThemeData>();

            foreach (string s in packages)
            {
                AssetBundleLoadAssetOperation op = AssetBundleManager.LoadAssetAsync(s, "themeData", typeof(ThemeData));
                yield return(CoroutineHandler.StartStaticCoroutine(op));

                ThemeData list = op.GetAsset <ThemeData>();
                if (list != null)
                {
                    themeDataList.Add(list.themeName, list);
                }
            }

            m_Loaded = true;
        }
    }
Exemple #30
0
        /// <summary>
        /// リクエスト(オブジェクト)を JSON に変換して HTTP(POST or GET)通信を行う
        /// </summary>
        /// <typeparam name="T">リクエスト型</typeparam>
        /// <param name="request">リクエストのオブジェクト</param>
        /// <param name="cb">コールバック</param>
        public void Send <T>(ref T request, Action <Result> cb)
        {
            // リクエストオブジェクトを JSON に変換(byte配列)
            string reqJson = JsonUtility.ToJson(request);

            Debug.Log("Send : " + reqJson);
            byte[] data = System.Text.Encoding.UTF8.GetBytes(reqJson);

            // url 生成
            var url = BaseUrl + ApiName;

            // GET のリクエストパラメータ設定
            if (HttpMethod == Method.GET)
            {
                string param = convGetParam(reqJson);
                url += param;
            }
            Debug.Log("url:" + url);

            // Http リクエスト
            CoroutineHandler.StartStaticCoroutine(onSend(url, data, cb));
        }