Commit 3e4b65bc authored by 王雪伟's avatar 王雪伟

合成音乐

parent 6d0dd035
...@@ -84,7 +84,6 @@ public class HttpTool : MonoBehaviour ...@@ -84,7 +84,6 @@ public class HttpTool : MonoBehaviour
private IEnumerator PostRequest<T>(string BaseURL, string methodName, string jsonString, Dictionary<string, object> postParas, Action<T> success, Action<string, string> failed) private IEnumerator PostRequest<T>(string BaseURL, string methodName, string jsonString, Dictionary<string, object> postParas, Action<T> success, Action<string, string> failed)
{ {
string url = BaseURL + methodName + "?" + addParams(postParas); string url = BaseURL + methodName + "?" + addParams(postParas);
Debug.unityLogger.Log(HttpLogTag, url);
using (UnityWebRequest webRequest = new UnityWebRequest(url, "POST")) using (UnityWebRequest webRequest = new UnityWebRequest(url, "POST"))
{ {
if (jsonString != null && jsonString.Length > 0) if (jsonString != null && jsonString.Length > 0)
......
using System.Collections; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.Events; using UnityEngine.Events;
...@@ -71,4 +72,9 @@ public class EventCenter : BaseMgr<EventCenter> ...@@ -71,4 +72,9 @@ public class EventCenter : BaseMgr<EventCenter>
{ {
eventdic = null; eventdic = null;
} }
internal void AddUpdateListener(string v1, object v2)
{
throw new NotImplementedException();
}
} }
...@@ -4,11 +4,10 @@ using UnityEngine; ...@@ -4,11 +4,10 @@ using UnityEngine;
public class AudioManager : MonoBaseMgr<AudioManager> public class AudioManager : MonoBaseMgr<AudioManager>
{ {
private GameObject PlayMusic;
private AudioSource mAudiSource; private AudioSource mAudiSource;
private void Awake() private void Awake()
{ {
mAudiSource = PlayMusic.AddComponent<AudioSource>(); mAudiSource = transform.gameObject.AddComponent<AudioSource>();
} }
public void PlayAudio(string MusicUrl) public void PlayAudio(string MusicUrl)
......
...@@ -59,7 +59,10 @@ public class GameController : MonoBehaviour ...@@ -59,7 +59,10 @@ public class GameController : MonoBehaviour
} }
/// <summary>
/// 合成歌曲上报
/// </summary>
/// <param name="song_id"></param>
public void GetNoteCompleted(int song_id) public void GetNoteCompleted(int song_id)
{ {
Dictionary<string, object> paras = new Dictionary<string, object>(); Dictionary<string, object> paras = new Dictionary<string, object>();
......
...@@ -6,19 +6,25 @@ using UnityEngine.UI; ...@@ -6,19 +6,25 @@ using UnityEngine.UI;
public class MainPanel : BasePanel public class MainPanel : BasePanel
{ {
private int nextSongId = 0;
private List<string> notesList = null;
private int playNoteIndex = 0;
private bool IsSuccess = false;
public override void OnHide(object data = null) public override void OnHide(object data = null)
{ {
} }
public override void OnInit(object data = null) public override void OnInit(object data = null)
{ {
EventCenter.Getinstance().AddUpdateListener("FlyNote", AddSongProgress);
GetHomeInfo(); GetHomeInfo();
GetNextNoteList(nextSongId);
} }
public override void OnRefresh(object data = null) public override void OnRefresh(object data = null)
{ {
} }
private void GetHomeInfo() private void GetHomeInfo()
{ {
...@@ -32,4 +38,54 @@ public class MainPanel : BasePanel ...@@ -32,4 +38,54 @@ public class MainPanel : BasePanel
Debug.unityLogger.Log("首页信息 " + code + " msg " + msg); Debug.unityLogger.Log("首页信息 " + code + " msg " + msg);
})); }));
} }
//监听碰撞时间增加音符
private void AddSongProgress()
{
if (IsSuccess)
{
return;
}
if (notesList != null && notesList.Count > 0)
{
if (notesList.Count > playNoteIndex)
{
AudioManager.Getinstance().PlayAudio(notesList[playNoteIndex]);
playNoteIndex++;
}
if (playNoteIndex == notesList.Count)
{
IsSuccess = true;
Debug.unityLogger.Log("合成音符红包");
}
GetControl<Text>("ProgressTv").text = playNoteIndex + "/" + notesList.Count;
GetControl<Image>("ProgressBar").fillAmount = playNoteIndex / (float)notesList.Count;
}
}
/// <summary>
/// 获取接下来将要掉落的音符组及所属歌曲
/// </summary>
public void GetNextNoteList(int song_id)
{
Dictionary<string, object> paras = new Dictionary<string, object>();
paras.Add("song_id", song_id);
HttpTool.Instance._Get("app/v1/watermelon/notes", paras, new Action<List<string>>((result) =>
{
IsSuccess = false;
playNoteIndex = 0;
notesList = result;
GetControl<Text>("ProgressTv").text = "0/" + result.Count;
GetControl<Image>("ProgressBar").fillAmount = 0 / (float)result.Count;
Debug.unityLogger.Log("");
}), new Action<string, string>((code, msg) =>
{
Debug.unityLogger.Log("获取下一组生成的球 " + code + " msg " + msg);
}));
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment