void Update() { bool bInit = false; bool bHitEvent = false; if (Input.GetMouseButtonDown(0)) { RaycastHit hit; // 床との当たり判定のみを取りたいのでマスクするレイヤーを設定する //int layerNo = LayerMask.NameToLayer ("Floor"); //int layerMask = 1 << layerNo; Ray ray = m_useCamera.ScreenPointToRay(Input.mousePosition); float fDistance = 100.0f; //レイを投射してオブジェクトを検出 if (Physics.Raycast(ray, out hit, fDistance)) { //Debug.LogError ( hit.collider.gameObject.name +":"+ hit.point.x); if (hit.collider.gameObject.name.Equals("bar")) { bHitEvent = true; m_goCursor.transform.position = new Vector3(hit.point.x, m_goCursor.transform.position.y, 0.0f); } } } if (m_eStepPre != m_eStep) { m_eStepPre = m_eStep; bInit = true; } switch (m_eStep) { case STEP.NONE: return; case STEP.LIMIT_CHECK: if (EveryStudioLibrary.CommonNetwork.Instance.IsConnected(m_iNetworkSerial) == true) { EveryStudioLibrary.TNetworkData network_data = EveryStudioLibrary.CommonNetwork.Instance.GetData(m_iNetworkSerial); if (network_data.IsError()) { m_strLimitTime = TimeManager.StrNow(); // 過去ならなんでもいい m_strLimitTime = "2015-10-10 10:10:10"; } else { string strRead = EveryStudioLibrary.CommonNetwork.Instance.GetString(m_iNetworkSerial); StringReader sr = new StringReader(strRead); m_strLimitTime = sr.ReadLine(); m_strTitle = sr.ReadLine(); m_lbTitle.text = m_strTitle; sr.Close(); } //m_strLimitTime = "2015-10-10 10:10:10"; m_bClose = false; //Debug.Log (TimeManager.Instance.GetDiffNow (m_strLimitTime).TotalSeconds); // 比較して過去だとマイナスになる m_eStep = STEP.MAX; if (TimeManager.Instance.GetDiffNow(m_strLimitTime).TotalSeconds < 0) { m_bClose = true; m_goLimit.SetActive(m_bClose); m_eStep = STEP.LOADING; } } else { } break; case STEP.LOADING: if (bInit) { m_AudioChannelData = SoundManager.Instance.PlayBGM("freakyf"); m_btnPause.gameObject.SetActive(false); m_btnPlay.gameObject.SetActive(true); } if (m_AudioChannelData.m_tAudioSource.isPlaying) { m_fTimer = m_AudioChannelData.m_tAudioSource.time; m_fTimerMax = m_AudioChannelData.m_tAudioSource.clip.length; m_AudioChannelData.m_tAudioSource.Stop(); m_eStep = STEP.PAUSE; } else { } break; case STEP.PAUSE: if (bInit) { m_bLoaded = true; m_btnPause.gameObject.SetActive(false); m_btnPlay.gameObject.SetActive(true); //m_AudioChannelData.m_tAudioSource.pitch = 0.0f; m_AudioChannelData.m_tAudioSource.Stop(); m_btnPlay.TriggerClear(); } if (m_btnPlay.ButtonPushed) { m_eStep = STEP.PLAYING; } break; case STEP.PLAYING: if (bInit) { m_btnPause.gameObject.SetActive(true); m_btnPlay.gameObject.SetActive(false); m_fPitch = 1.0f; m_AudioChannelData.m_tAudioSource.time = m_fTimer; m_AudioChannelData.m_tAudioSource.pitch = m_fPitch; m_AudioChannelData.m_tAudioSource.Play(); m_btnPause.TriggerClear(); } if (m_btnPause.ButtonPushed) { m_eStep = STEP.PAUSE; } m_fTimer = m_AudioChannelData.m_tAudioSource.time; break; case STEP.MAX: default: break; } float fRate = GetRate(m_fTimer, 0.0f, m_fTimerMax); if (bHitEvent == true) { fRate = GetRate(m_goCursor.transform.localPosition.x, -320.0f, 320.0f); m_fTimer = fRate * m_fTimerMax; m_AudioChannelData.m_tAudioSource.time = m_fTimer; } else { m_goCursor.transform.localPosition = new Vector3(Linear(fRate, -320.0f, 320.0f), 0.0f, 0.0f); } SetTime(m_fTimer, m_fTimerMax); if (m_btnUp.ButtonPushed) { m_btnUp.TriggerClear(); if (m_fPitch < 1.0f) { m_fPitch = 1.0f; } m_fPitch += 0.2f; m_AudioChannelData.m_tAudioSource.pitch = m_fPitch; } if (m_btnDown.ButtonPushed) { m_btnDown.TriggerClear(); if (-0.2 <= m_fPitch) { m_fPitch = 0.0f; } m_fPitch -= 0.2f; m_AudioChannelData.m_tAudioSource.pitch = m_fPitch; } }
// Update is called once per frame void Update() { bool bInit = false; if (m_eStepPre != m_eStep) { m_eStepPre = m_eStep; bInit = true; } switch (m_eStep) { case STEP.INITIALIZW: if (bInit) { m_iDownloadCount = 0; foreach (string filename in load_check) { StartCoroutine(initialData(filename)); } } if (m_iDownloadCount == load_check.Count) { m_eStep = STEP.CHECK_NEW_DATA; } break; case STEP.CHECK_NEW_DATA: if (bInit) { m_iNetworkSerial = EveryStudioLibrary.CommonNetwork.Instance.Recieve(string.Format("http://ad.xnosserver.com/apps/myzoo_data/ukiss/{0}/datacheck.txt", DataManagerAlarm.Instance.APP_VERSION)); } if (EveryStudioLibrary.CommonNetwork.Instance.IsConnected(m_iNetworkSerial) == true) { EveryStudioLibrary.TNetworkData network_data = EveryStudioLibrary.CommonNetwork.Instance.GetData(m_iNetworkSerial); if (network_data.IsError()) { m_eStep = STEP.START_MAIN; } else { string strRead = EveryStudioLibrary.CommonNetwork.Instance.GetString(m_iNetworkSerial); StringReader sr = new StringReader(strRead); strRead = sr.ReadLine(); m_strCsvDataVersion = m_kvs.Read("csv_data_version"); Debug.Log(m_strCsvDataVersion); Debug.Log(strRead); if (m_strCsvDataVersion.Equals(strRead) == true) { m_eStep = STEP.START_MAIN; Debug.Log("equal"); } else { Debug.Log("not equal"); m_eStep = STEP.COPY_PERMISSIVE; m_strCsvDataVersion = strRead; } /* * string strRead = EveryStudioLibrary.CommonNetwork.Instance.GetString (m_iNetworkSerial); * StringReader sr = new StringReader (strRead); * m_strLimitTime = sr.ReadLine (); * m_strTitle = sr.ReadLine (); * m_lbTitle.text = m_strTitle; * sr.Close (); */ } } else { } break; case STEP.COPY_PERMISSIVE: if (bInit) { m_iDownloadCount = 0; foreach (string filename in load_check) { StartCoroutine(LoadData(filename, string.Format("http://ad.xnosserver.com/apps/myzoo_data/ukiss/{0}", DataManagerAlarm.Instance.APP_VERSION))); } } if (m_iDownloadCount == load_check.Count) { m_eStep = STEP.START_MAIN; // データを更新した場合はアセットバンドルの更新があるかも知れないので // キャッシュクリアをする Caching.CleanCache(); m_kvs.Write("csv_data_version", m_strCsvDataVersion); m_kvs.Save(); } break; case STEP.START_MAIN: if (bInit) { SceneManager.LoadScene("main"); } break; case STEP.MAX: default: break; } }