西部牛仔接口

This commit is contained in:
杨号敬 2025-01-09 18:02:24 +08:00
parent 606a317ddb
commit 38912171be
2 changed files with 266 additions and 37 deletions

View File

@ -20826,6 +20826,10 @@ PrefabInstance:
propertyPath: m_Name
value: qiang
objectReference: {fileID: 0}
- target: {fileID: 8655137400209790970, guid: 6f1399d2fd0d84b4da0685e73d1ae076, type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8655137400209790971, guid: 6f1399d2fd0d84b4da0685e73d1ae076, type: 3}
propertyPath: m_Pivot.x
value: 0.5
@ -28395,6 +28399,86 @@ SpriteRenderer:
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &315527584
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 315527585}
- component: {fileID: 315527587}
- component: {fileID: 315527586}
m_Layer: 5
m_Name: Prompttext
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &315527585
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 315527584}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1362358118}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 176.2191, y: 59.1941}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &315527586
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 315527584}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0, g: 0, b: 0, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 25
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 2
m_MaxSize: 40
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 1
m_VerticalOverflow: 1
m_LineSpacing: 1
m_Text: "\u64CD\u4F5C\u4E0D\u5F53\uFF01\uFF01\uFF01"
--- !u!222 &315527587
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 315527584}
m_CullTransparentMesh: 1
--- !u!1 &315580079
GameObject:
m_ObjectHideFlags: 0
@ -70094,11 +70178,11 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8266668363385741884, guid: c8cee8188671fe34d82f935dd7d24c2d, type: 3}
propertyPath: m_SizeDelta.x
value: -978
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8266668363385741884, guid: c8cee8188671fe34d82f935dd7d24c2d, type: 3}
propertyPath: m_SizeDelta.y
value: -1818
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8266668363385741884, guid: c8cee8188671fe34d82f935dd7d24c2d, type: 3}
propertyPath: m_LocalPosition.x
@ -70130,11 +70214,11 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8266668363385741884, guid: c8cee8188671fe34d82f935dd7d24c2d, type: 3}
propertyPath: m_AnchoredPosition.x
value: 448
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8266668363385741884, guid: c8cee8188671fe34d82f935dd7d24c2d, type: 3}
propertyPath: m_AnchoredPosition.y
value: 745
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8266668363385741884, guid: c8cee8188671fe34d82f935dd7d24c2d, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
@ -70152,6 +70236,10 @@ PrefabInstance:
propertyPath: m_Name
value: GameplayPlane
objectReference: {fileID: 0}
- target: {fileID: 8266668363385741885, guid: c8cee8188671fe34d82f935dd7d24c2d, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c8cee8188671fe34d82f935dd7d24c2d, type: 3}
--- !u!224 &725912346 stripped
@ -86218,6 +86306,7 @@ RectTransform:
- {fileID: 2026669773786081067}
- {fileID: 1553952862}
- {fileID: 1037047151}
- {fileID: 1362358118}
m_Father: {fileID: 0}
m_RootOrder: 16
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -127871,6 +127960,83 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1361833010}
m_CullTransparentMesh: 1
--- !u!1 &1362358117
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1362358118}
- component: {fileID: 1362358120}
- component: {fileID: 1362358119}
m_Layer: 5
m_Name: Prompt(Clone)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!224 &1362358118
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1362358117}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 315527585}
m_Father: {fileID: 914645750}
m_RootOrder: 27
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 33}
m_SizeDelta: {x: 294, y: 66}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1362358119
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1362358117}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: 6bc0ebd48ebefc74c883205a7d859531, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &1362358120
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1362358117}
m_CullTransparentMesh: 1
--- !u!1 &1363050881
GameObject:
m_ObjectHideFlags: 0

View File

@ -40,7 +40,6 @@ public class Westerncowboy : MonoBehaviour
private async void Start()
{
TimeText.gameObject.transform.parent.gameObject.SetActive(false);
Debug.Log(PlayerPrefs.GetString("UserToken"));
AuthorizationValue = PlayerPrefs.GetString("UserToken");
await ConnectWebSocket();
@ -51,7 +50,7 @@ public class Westerncowboy : MonoBehaviour
});
Tourubtn.onClick.AddListener(async () =>
{
await SendJsonMessage(10,1);
await SendJsonMessage(30,2);
});
// 调用发送方法
await SendJsonMessage("{ \"code\": \"WEST_COWBOY\", \"content\": \"{\\\"action\\\":\\\"INFO\\\"}\" }");
@ -116,21 +115,20 @@ public class Westerncowboy : MonoBehaviour
if (fishResponse?.data != null)
{
Debug.Log(fishResponse.data.balance);
balance.text= fishResponse.data.balance.ToString();
Debug.Log(fishResponse.data.intro_text);
Debug.Log(fishResponse.data.countdown);
intro_text.text = fishResponse.data.intro_text;
Debug.LogError(fishResponse.data.countdown);
remainingTime = (float)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);
}
Debug.Log("" + fishResponse.data.betting_data.pos_8);
Debug.Log("" + fishResponse.data.betting_data.pos_7);
Debug.Log("" + fishResponse.data.betting_data.pos_6);
Debug.Log("" + fishResponse.data.betting_data.pos_5);
Debug.Log("" + fishResponse.data.betting_data.pos_4);
Debug.Log("" + fishResponse.data.betting_data.pos_3);
Debug.Log("" + fishResponse.data.betting_data.pos_2);
Debug.Log("" + fishResponse.data.betting_data.pos_1);
}
break;
//西部牛仔离开房间
@ -148,6 +146,7 @@ public class Westerncowboy : MonoBehaviour
if (fishResponse2 != null && fishResponse2.data != null)
{
Debug.Log(fishResponse2.data.balance);
balance.text = fishResponse2.data.balance.ToString();
}
else
{
@ -155,24 +154,53 @@ public class Westerncowboy : MonoBehaviour
}
break;
case "WEST_COWBOY_COUNTDOWN":
WesternInforesponse fishResponse3 = JsonConvert.DeserializeObject<WesternInforesponse>(message);
WesternCDresponse fishResponse3 = JsonConvert.DeserializeObject<WesternCDresponse>(message);
if (fishResponse3?.data != null)
{
Debug.Log(fishResponse3.data.balance);
Debug.Log(fishResponse3.data.intro_text);
Debug.Log(fishResponse3.data.countdown);
Debug.LogError(fishResponse3.data.countdown);
remainingTime = (float)fishResponse3.data.countdown;
Debug.Log(fishResponse3.data.countdown_type);
foreach (var item in fishResponse3.data.betting_data)
Debug.Log("" + fishResponse3.data.betting_data.pos_8);
Debug.Log("" + fishResponse3.data.betting_data.pos_7);
Debug.Log("" + fishResponse3.data.betting_data.pos_6);
Debug.Log("" + fishResponse3.data.betting_data.pos_5);
Debug.Log("" + fishResponse3.data.betting_data.pos_4);
Debug.Log("" + fishResponse3.data.betting_data.pos_3);
Debug.Log("" + fishResponse3.data.betting_data.pos_2);
Debug.Log("" + fishResponse3.data.betting_data.pos_1);
}
break;
case "WEST_COWBOY_SHOOT":
WesternPOSresponse fishResponse4 = JsonConvert.DeserializeObject<WesternPOSresponse>(message);
if (fishResponse4?.data != null)
{
foreach (var item in fishResponse4.data.positions)
{
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);
Debug.Log("" + item);
}
}
break;
case "WEST_COWBOY_SETTLE":
WesternSETTLEresponse fishResponse5 = JsonConvert.DeserializeObject<WesternSETTLEresponse>(message);
if (fishResponse5?.data != null)
{
Debug.Log(fishResponse5.data.balance);
foreach (var item in fishResponse5.data.settle_data)
{
Debug.Log("" + item.position);
Debug.Log("" + item.amount);
Debug.Log("" + item.status);
Debug.Log("" + item.reward);
Debug.Log("" + item.retain);
}
}
@ -205,7 +233,7 @@ public class Westerncowboy : MonoBehaviour
var message = new
{
code = "WEST_COWBOY",
content = $"{{\"action\":\"BETTING\",\"amount\":{count},\"count\":{pos}}}"
content = $"{{\"action\":\"BETTING\",\"amount\":{count},\"position\":{pos}}}"
};
// 将对象序列化为 JSON 字符串
@ -286,7 +314,7 @@ public class Westerncowboy : MonoBehaviour
}
if (remainingTime <= 0)
{
TimeText.gameObject.transform.parent.gameObject.SetActive(false);
//TimeText.gameObject.transform.parent.gameObject.SetActive(false);
}
// 更新上次调用时间
lastCallTime = Time.time;
@ -307,7 +335,7 @@ public class FWesternInfoData
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 FWesternInfo betting_data { get; set; }
}
public class FWesternInfo
@ -336,14 +364,14 @@ public class WesternCDresponse
{
public string code { get; set; }
public string message { get; set; }
public FWesternInfoData data { get; set; }
public FWesternCDData 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 FWesternCD betting_data { get; set; }
}
public class FWesternCD
@ -358,3 +386,38 @@ public class FWesternCD
public float pos_7;
public float pos_8;
}
public class WesternPOSresponse
{
public string code { get; set; }
public string message { get; set; }
public FWesternPOSData data { get; set; }
}
public class FWesternPOSData
{
public int[] positions { get; set; }
}
public class WesternSETTLEresponse
{
public string code { get; set; }
public string message { get; set; }
public FWesternSETTLEData data { get; set; }
}
public class FWesternSETTLEData
{
public float balance { get; set; }
public List<FWesternSETTLE> settle_data { get; set; }
}
public class FWesternSETTLE
{
public int position { get; set; }
public float amount { get; set; }
public string status { get; set; }
public float reward { get; set; }
public float retain { get; set; }
}