西部牛仔
This commit is contained in:
parent
bd8fdbf593
commit
ba5ca1ff49
File diff suppressed because it is too large
Load Diff
@ -49,7 +49,7 @@ public class WebFishingPK : MonoBehaviour
|
||||
public Button returnbtn;
|
||||
private async void Awake()
|
||||
{
|
||||
await ConnectWebSocket();
|
||||
///await ConnectWebSocket();
|
||||
}
|
||||
private async void Start()
|
||||
{
|
||||
|
@ -40,7 +40,7 @@ public class WebJoinroom : MonoBehaviour
|
||||
public Button returnbtn;
|
||||
private async void Awake()
|
||||
{
|
||||
await ConnectWebSocket();
|
||||
// await ConnectWebSocket();
|
||||
}
|
||||
private async void Start()
|
||||
{
|
||||
@ -48,7 +48,7 @@ public class WebJoinroom : MonoBehaviour
|
||||
TimeText.gameObject.transform.parent.gameObject.SetActive(false);
|
||||
Debug.Log(PlayerPrefs.GetString("UserToken"));
|
||||
AuthorizationValue = PlayerPrefs.GetString("UserToken");
|
||||
|
||||
await ConnectWebSocket();
|
||||
returnbtn.onClick.AddListener(async () =>
|
||||
{
|
||||
await SendJsonMessage("{ \"code\": \"FISHING\", \"content\": \"{\\\"action\\\":\\\"LEAVE\\\"}\" }");
|
||||
|
@ -15,11 +15,13 @@ public class Westerncowboy : MonoBehaviour
|
||||
private ClientWebSocket _webSocket;
|
||||
private const string WebSocketUri = "ws://47.95.201.243:9527/api/ws";
|
||||
private string AuthorizationValue;
|
||||
public int count = 0;
|
||||
//界面元素
|
||||
|
||||
/// <summary>
|
||||
/// ½çÃæÔªËØ
|
||||
/// </summary>
|
||||
public Text balance;
|
||||
public Text intro_text;
|
||||
public Text surpluscount_text;
|
||||
public Text[] bettings;
|
||||
public Button Tourubtn;
|
||||
private float lastCallTime = 0f;
|
||||
float remainingTime = 0f;
|
||||
@ -33,7 +35,7 @@ public class Westerncowboy : MonoBehaviour
|
||||
public Button returnbtn;
|
||||
private async void Awake()
|
||||
{
|
||||
await ConnectWebSocket();
|
||||
//await ConnectWebSocket();
|
||||
}
|
||||
private async void Start()
|
||||
{
|
||||
@ -41,7 +43,7 @@ public class Westerncowboy : MonoBehaviour
|
||||
TimeText.gameObject.transform.parent.gameObject.SetActive(false);
|
||||
Debug.Log(PlayerPrefs.GetString("UserToken"));
|
||||
AuthorizationValue = PlayerPrefs.GetString("UserToken");
|
||||
|
||||
await ConnectWebSocket();
|
||||
|
||||
returnbtn.onClick.AddListener(async () =>
|
||||
{
|
||||
@ -107,47 +109,73 @@ public class Westerncowboy : MonoBehaviour
|
||||
switch (baseResponse.code)
|
||||
{
|
||||
// 解析消息为 Fishresponse 对象
|
||||
case "FISHING_INFO":
|
||||
case "WEST_COWBOY_INFO":
|
||||
// 解析为 FishJoinroomresponse 类型
|
||||
FishJoinroomresponse fishResponse = JsonConvert.DeserializeObject<FishJoinroomresponse>(message);
|
||||
WesternInforesponse fishResponse = JsonConvert.DeserializeObject<WesternInforesponse>(message);
|
||||
|
||||
if (fishResponse?.data != null)
|
||||
{
|
||||
|
||||
Debug.Log(fishResponse.data.balance);
|
||||
Debug.Log(fishResponse.data.intro_text);
|
||||
Debug.Log(fishResponse.data.countdown);
|
||||
Debug.Log(fishResponse.data.countdown_type);
|
||||
foreach (var item in fishResponse.data.betting_data)
|
||||
{
|
||||
Debug.Log(""+item.pos_8);
|
||||
Debug.Log("" + item.pos_7);
|
||||
Debug.Log("" + item.pos_6);
|
||||
Debug.Log("" + item.pos_5);
|
||||
Debug.Log("" + item.pos_4);
|
||||
Debug.Log("" + item.pos_3);
|
||||
Debug.Log("" + item.pos_2);
|
||||
Debug.Log("" + item.pos_1);
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case "FISHING_BETTING":
|
||||
// 解析消息为 Fishresponse 对象
|
||||
FishBetonresponse fishResponse1 = JsonConvert.DeserializeObject<FishBetonresponse>(message);
|
||||
Promptmgr.Instance.PromptBubble(fishResponse1.message);
|
||||
//Î÷²¿Å£×ÐÀ뿪·¿¼ä
|
||||
case "WEST_COWBOY_LEAVE":
|
||||
Promptmgr.Instance.PromptBubble(baseResponse.message);
|
||||
// 检查是否成功反序列化
|
||||
if (fishResponse1 != null && fishResponse1.data != null)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("收到的消息无法解析为 Fishresponse 对象。");
|
||||
}
|
||||
break;
|
||||
case "FISHING_FISHING":
|
||||
// Å£×ÐͶÈë
|
||||
case "WEST_COWBOY_BETTING":
|
||||
|
||||
// 解析消息为 Fishresponse 对象
|
||||
Fishingresponse fishResponse2 = JsonConvert.DeserializeObject<Fishingresponse>(message);
|
||||
|
||||
WesternBetesponse fishResponse2 = JsonConvert.DeserializeObject<WesternBetesponse>(message);
|
||||
//Promptmgr.Instance.PromptBubble(fishResponse2.message);
|
||||
// 检查是否成功反序列化
|
||||
if (fishResponse2 != null && fishResponse2.data != null)
|
||||
{
|
||||
|
||||
Debug.Log(fishResponse2.data.balance);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("收到的消息无法解析为 Fishresponse 对象。");
|
||||
}
|
||||
break;
|
||||
case "BALANCE":
|
||||
case "WEST_COWBOY_COUNTDOWN":
|
||||
WesternInforesponse fishResponse3 = JsonConvert.DeserializeObject<WesternInforesponse>(message);
|
||||
|
||||
if (fishResponse3?.data != null)
|
||||
{
|
||||
Debug.Log(fishResponse3.data.balance);
|
||||
Debug.Log(fishResponse3.data.intro_text);
|
||||
Debug.Log(fishResponse3.data.countdown);
|
||||
Debug.Log(fishResponse3.data.countdown_type);
|
||||
foreach (var item in fishResponse3.data.betting_data)
|
||||
{
|
||||
Debug.Log("" + item.pos_8);
|
||||
Debug.Log("" + item.pos_7);
|
||||
Debug.Log("" + item.pos_6);
|
||||
Debug.Log("" + item.pos_5);
|
||||
Debug.Log("" + item.pos_4);
|
||||
Debug.Log("" + item.pos_3);
|
||||
Debug.Log("" + item.pos_2);
|
||||
Debug.Log("" + item.pos_1);
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -229,10 +257,7 @@ public class Westerncowboy : MonoBehaviour
|
||||
{
|
||||
balance.text = detail.ToString();
|
||||
}
|
||||
public void dissurplus(float detail, int p)
|
||||
{
|
||||
surpluscount_text.text = (p * (int)detail).ToString() + "金币";
|
||||
}
|
||||
|
||||
void UpdateCountdownText(float remainingTime)
|
||||
{
|
||||
|
||||
@ -267,4 +292,69 @@ public class Westerncowboy : MonoBehaviour
|
||||
lastCallTime = Time.time;
|
||||
}
|
||||
}
|
||||
}
|
||||
public class WesternInforesponse
|
||||
{
|
||||
public string code { get; set; }
|
||||
public string message { get; set; }
|
||||
public FWesternInfoData data { get; set; }
|
||||
}
|
||||
|
||||
public class FWesternInfoData
|
||||
{
|
||||
public float balance { get; set; }
|
||||
|
||||
public string intro_text { get; set; }
|
||||
public int countdown { get; set; }
|
||||
public int countdown_type { get; set; }
|
||||
public List<FWesternInfo> betting_data { get; set; }
|
||||
}
|
||||
|
||||
public class FWesternInfo
|
||||
{
|
||||
public float pos_1;
|
||||
|
||||
public float pos_2;
|
||||
public float pos_3;
|
||||
public float pos_4;
|
||||
public float pos_5;
|
||||
public float pos_6;
|
||||
public float pos_7;
|
||||
public float pos_8;
|
||||
}
|
||||
public class WesternBetesponse
|
||||
{
|
||||
public string code { get; set; }
|
||||
public string message { get; set; }
|
||||
public WesternBetedata data { get; set; }
|
||||
}
|
||||
public class WesternBetedata
|
||||
{
|
||||
public float balance { get; set; }
|
||||
}
|
||||
public class WesternCDresponse
|
||||
{
|
||||
public string code { get; set; }
|
||||
public string message { get; set; }
|
||||
public FWesternInfoData data { get; set; }
|
||||
}
|
||||
|
||||
public class FWesternCDData
|
||||
{
|
||||
public int countdown { get; set; }
|
||||
public int countdown_type { get; set; }
|
||||
public List<FWesternInfo> betting_data { get; set; }
|
||||
}
|
||||
|
||||
public class FWesternCD
|
||||
{
|
||||
public float pos_1;
|
||||
|
||||
public float pos_2;
|
||||
public float pos_3;
|
||||
public float pos_4;
|
||||
public float pos_5;
|
||||
public float pos_6;
|
||||
public float pos_7;
|
||||
public float pos_8;
|
||||
}
|
Loading…
Reference in New Issue
Block a user