This commit is contained in:
liuliang 2025-01-09 16:42:40 +08:00
commit ef40f78a41
15 changed files with 1895 additions and 84 deletions

View File

@ -397,7 +397,7 @@
"S_1": {
"1": {
"SkillList": [
"0"
"skill_7"
]
},
"2": {
@ -411,7 +411,9 @@
"DamageBuff": 0.35
},
"5": {
"DamageBuff": 0.3,
"SkillList": [
"skill_6"
],
"speedOfBullets": -0.1
}
},
@ -424,7 +426,7 @@
},
"3": {
"numberOfBullets": 1,
"speedOfBullets": -1
"speedOfBullets": -0.1
},
"4": {
"DamageBuff": 0.35

View File

@ -4853,6 +4853,7 @@ MonoBehaviour:
IsMove: 1
Collider2D: {fileID: 4606866971114100020}
effectPres: []
timer: 0
NumberOfBulletAttacks: 1
Target: {fileID: 0}
noLockEnemy: 0

View File

@ -396,7 +396,7 @@ MonoBehaviour:
- {fileID: 1680116210, guid: 1b13224ac6b7e4b4d931ed9097e795bf, type: 3}
- {fileID: -274749663, guid: 1b13224ac6b7e4b4d931ed9097e795bf, type: 3}
- {fileID: 1383633982, guid: 1b13224ac6b7e4b4d931ed9097e795bf, type: 3}
CharacterAnimationFrameInterval: 50
CharacterAnimationFrameInterval: 18
- value:
- {fileID: 1179033219, guid: 85cc96495bc9d00489f3b17142d7de66, type: 3}
- {fileID: -467593880, guid: 85cc96495bc9d00489f3b17142d7de66, type: 3}
@ -429,7 +429,7 @@ MonoBehaviour:
animationHighlight: 0
spriteRenderer: {fileID: 4703411402842800734}
image: {fileID: 0}
isAnimationPlay: 0
isAnimationPlay: 1
mycollider: {fileID: 5307107303863668509}
attackClass: {fileID: 0}
CurrentIndex: 33
@ -590,8 +590,8 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4703411402842800732}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1.25, z: 0}
m_LocalScale: {x: 0.26, y: 0.26, z: 0.26}
m_LocalPosition: {x: 0, y: 0.34, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 4703411402065954782}
@ -638,15 +638,15 @@ SpriteRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: 1657ff3f38d87b94586a400f5834025c, type: 3}
m_Sprite: {fileID: 433695028, guid: 1b13224ac6b7e4b4d931ed9097e795bf, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 21.605274, y: 19.199999}
m_Size: {x: 1.6, y: 1.6}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &6362446851701897971

View File

@ -419,7 +419,7 @@ GameObject:
- component: {fileID: 8433650274028726420}
- component: {fileID: -3836672401185760439}
- component: {fileID: 1608620729910401442}
- component: {fileID: 2427917370826210288}
- component: {fileID: 6754849144717393997}
m_Layer: 0
m_Name: jbf
m_TagString: Player
@ -514,7 +514,7 @@ MonoBehaviour:
normalIndex: 0
isHit: 0
myTags: 0
mySkillUp: {fileID: 2427917370826210288}
mySkillUp: {fileID: 6754849144717393997}
IsDead: 0
HaveDieTime: 0
enemyId:
@ -573,7 +573,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
tower: {fileID: 0}
Tag: tower
--- !u!114 &2427917370826210288
--- !u!114 &6754849144717393997
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@ -582,7 +582,7 @@ MonoBehaviour:
m_GameObject: {fileID: 8433650275485930554}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8264f0a4afc0aa347bf9dad42df2617a, type: 3}
m_Script: {fileID: 11500000, guid: 06f1271e2c91952498f98563968b9cae, type: 3}
m_Name:
m_EditorClassIdentifier:
description: "\u66F4\u65B0\u540E\u7684\u840C\u5996\uFF0C\uFF1A\u4F7F\u7528\u65B9\u6CD5xxxxxxxx"

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,7 @@ public class SkillUp : Fun
set
{
attackRange=value;
role.AttackRange +=attackRange;
role.AttackRange += value;
}
}
@ -33,7 +33,7 @@ public class SkillUp : Fun
set
{
attackCooldown = value;
role.AttackCD *= (1 + attackCooldown);
role.AttackCD *= (1 + value);
}
}
@ -46,7 +46,7 @@ public class SkillUp : Fun
set
{
attackDuration = value;
attack.AttackStayTime *= (1 + attackDuration);
attack.AttackStayTime *= (1 + value);
}
}
[HideInInspector][Header("攻击子弹数量加成")] public int numberOfBullets = 0;
@ -58,7 +58,11 @@ public class SkillUp : Fun
set
{
numberOfBullets = value;
attack.BulletNumber += numberOfBullets;
// Debug.Log("NumberOfBullets:"+ NumberOfBullets);
Debug.Log("value:" + value);
attack.BulletNumber += value;
// Debug.Log("attack.BulletNumber:" + attack.BulletNumber);
}
}
[HideInInspector][Header("攻击子弹速度加成")] public float speedOfBullets = 0f;
@ -70,7 +74,7 @@ public class SkillUp : Fun
set
{
speedOfBullets = value;
attack.roleBulletSpeedAdd *= (1+speedOfBullets);
attack.roleBulletSpeedAdd *= (1+ value);
}
}
@ -100,17 +104,27 @@ public class SkillUp : Fun
SkillLevelData info = Mengyao_Skill_Date.instance.parsedData[mengyao_id][skill_id][level];
//Debug.Log("mengyao_id:" + mengyao_id+ "skill_id:" + skill_id+ "level:" + level+ "info.numberOfBullets:" + info.numberOfBullets);
// Debug.Log("info.numberOfBullets:"+info.numberOfBullets);
//攻击范围加成
AttackRange += info.Range;
Debug.Log("¹¥»÷·¶Î§+"+ info.Range +"||"+ attackRange.ToString()+"=================================");
AttackRange = info.Range;
// Debug.Log("攻击范围+"+ info.Range +"||"+ attackRange.ToString()+"=================================");
//攻击冷却加成
AttackCooldown += info.AttackCooldown;
AttackCooldown = info.AttackCooldown;
//攻击持续时间加成
AttackDuration += info.AttackContinues;
AttackDuration = info.AttackContinues;
Debug.Log("攻击子弹数量加成+info.numberOfBullets:" + info.numberOfBullets);
//攻击子弹数量加成
NumberOfBullets += info.numberOfBullets;
NumberOfBullets = info.numberOfBullets;
//攻击子弹速度加成
SpeedOfBullets += info.speedOfBullets;
SpeedOfBullets = info.speedOfBullets;
// Debug.Log("攻击子弹数量加成:" + NumberOfBullets);
//攻击伤害加成
DamageUp += info.DamageBuff;

View File

@ -0,0 +1,91 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
public class jbf_SkillUp : SkillUp
{
/// <summary>
/// 射程提升1格位置
/// </summary>
///
public void Start()
{
}
public override void useskill(string str)
{
if (str == "skill_6") /// 每次攻击额外造成30%魔法伤害,刀的旋转速度减少10%
{
attack.haveAddDamage = true;
attack.AdddamageType = DamageType.magicDamage;
}
if (str == "skill_7") ///刀的长度延长1格
{
attack.bulletLengthAdd += 2;
}
}
/*public override void Skill_1_1()
{
base.AttackRange = 1;
attack.SetAttackRange();
}
/// <summary>
/// 攻击CD减少10%
/// </summary>
public override void Skill_1_3()
{
base.AttackCooldown -= 0.1f;
}
/// <summary>
/// 每次扇形喷出3个毒雾攻击CD增加5%
/// </summary>
public override void Skill_1_5()
{
attack.BulletNumber = 3;
}
/// <summary>
/// 敌人中毒后受到伤害提升20%
/// </summary>
public override void Skill_2_1()
{
poisonDamage *= 1.2f;
SetPoisonBuff();
}
/// <summary>
/// 敌人中毒后毒药生效时间减少30% 攻击CD增加5%
/// </summary>
public override void Skill_2_3()
{
base.AttackCooldown += 0.05f;
poisonInterval *= 0.7f;
SetPoisonBuff();
}
/// <summary>
/// 敌人中毒后受到伤害提升50%,攻击CD增加5%
/// </summary>
public override void Skill_2_5()
{
base.AttackCooldown += 0.05f;
poisonDamage *= 1.5f;
SetPoisonBuff();
}
*/
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 06f1271e2c91952498f98563968b9cae
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,6 +1,7 @@
using System.Collections.Generic;
using UnityEngine;
using System.Threading.Tasks;
using Unity.VisualScripting;
using UnityEngine.Rendering;
@ -99,13 +100,14 @@ public class SpawnMonster : Base
}
void Update()
void FixedUpdate()
{
UpdateNodeList();
//UpdateNodeList();
}
public async void StartSpawning()
{

View File

@ -140,10 +140,10 @@ public class FishingPK : MonoBehaviour
Debug.Log(fishResponse.data.countdown_type);
if(fishResponse.data.countdown_type==0)
{
photoMovement.type = true;
photoMovement.Del1();
photoMovement.To1();
photoMovement1.type = true;
photoMovement1.Del1();
photoMovement1.To1();
@ -151,11 +151,11 @@ public class FishingPK : MonoBehaviour
else
{
photoMovement.Del1();
photoMovement.type = false;
photoMovement.To2();
photoMovement1.Del1();
photoMovement1.type = false;
photoMovement1.To2();
@ -196,21 +196,21 @@ public class FishingPK : MonoBehaviour
Debug.Log(fishResponse2.data.countdown_type);
if (fishResponse2.data.countdown_type == 0)
{
photoMovement.type = true;
photoMovement.Del1();
photoMovement.To1();
photoMovement1.type = true;
photoMovement1.Del1();
photoMovement1.To1();
}
else
{
photoMovement.Del1();
photoMovement.type = false;
photoMovement.To2();
photoMovement1.Del1();
photoMovement1.type = false;
photoMovement1.To2();
}

View File

@ -23,6 +23,10 @@ public class PhotoMovement : MonoBehaviour
public bool type=false;
public Sprite[] sprites;
int count = 0;
// 控制 To1 和 To2 的执行
private bool isTo1Running = false; // 标识 To1 是否正在执行
private bool isTo2Running = false; // 标识 To2 是否正在执行
private void Start()
{
image.gameObject.SetActive(false);
@ -30,29 +34,49 @@ public class PhotoMovement : MonoBehaviour
public async void To1()
{
if (type == true)
{
To1();
}
// 如果 To1 已经在执行,则返回,不执行新的 To1
if (isTo1Running || isTo2Running)
return;
isTo1Running = true; // 设置 To1 为正在执行状态
// 执行 To1 的操作
shuaigan.gameObject.SetActive(true);
var time = shuaigan.GetComponent<SpriteAniation>().sprites.Count * shuaigan.GetComponent<SpriteAniation>().Aintime;
await Task.Delay((int)time);
daiji.gameObject.SetActive(true);
shuaigan.gameObject.SetActive(false);
//await Task.Delay(1000);
// 延迟 1000 毫秒(或者你可以自定义)
daiji.gameObject.SetActive(false);
shougan.gameObject.SetActive(true);
var time1 = shougan.GetComponent<SpriteAniation>().sprites.Count * shougan.GetComponent<SpriteAniation>().Aintime;
// 开始沿路径移动
StartCoroutine(MoveAlongPath());
currentPathIndex = 0;
image.gameObject.SetActive(true);
image.GetComponent<Image>().sprite = sprites[count% sprites.Length];
// 随机选择一个 sprite
int randomIndex = Random.Range(0, sprites.Length); // 获取随机索引
image.GetComponent<Image>().sprite = sprites[randomIndex]; // 使用随机的 sprite
count++;
await Task.Delay((int)time1-100);
Del1();
await Task.Delay((int)time1 - 100); // 延迟结束,准备执行下一个步骤
Del1(); // 结束当前操作
isTo1Running = false; // 执行完 To1恢复为未执行状态
// 如果没有正在执行 To2则继续执行 To1
if (!isTo2Running)
{
To1();
}
}
public void Del1()
{
image.gameObject.SetActive(false);
@ -61,16 +85,30 @@ public class PhotoMovement : MonoBehaviour
shougan.gameObject.SetActive(false);
currentPathIndex = 0;
}
public async void To2()
{
// 如果 To1 正在执行,打断 To1 的执行
isTo2Running = true; // 标记 To2 为正在执行
// 等待 To1 完成执行(如果 To1 正在执行)
while (isTo1Running)
{
await Task.Delay(100); // 检查 To1 的执行状态
}
// 执行 To2 的操作
shuaigan.gameObject.SetActive(true);
var time = shuaigan.GetComponent<SpriteAniation>().sprites.Count * shuaigan.GetComponent<SpriteAniation>().Aintime;
await Task.Delay((int)time);
daiji.gameObject.SetActive(true);
shuaigan.gameObject.SetActive(false);
// 执行完 To2 后,恢复 To2 的标志为 false
isTo2Running = false;
}
private IEnumerator MoveAlongPath()
{
// 持续沿着路径点移动
@ -86,17 +124,19 @@ public class PhotoMovement : MonoBehaviour
// 移动到下一个路径点
currentPathIndex++;
}
image.gameObject.SetActive(false);
shougan.gameObject.SetActive(false);
image.transform.localPosition = new Vector3(467, -144, 0);
}
public void change()
{
StartCoroutine(MoveAlongPath());
currentPathIndex = 0;
image.gameObject.SetActive(true);
}
public void Update()
{

View File

@ -30,6 +30,7 @@ public class WebFishingPK : MonoBehaviour
/// </summary>
public Text lefttext;
public Text righttext;
public Text balance;
public Button TouruBtn;
public Button selleftbtn;
public Button selrightbtn;
@ -44,6 +45,12 @@ public class WebFishingPK : MonoBehaviour
/// </summary>
///
public PhotoMovement photoMovement;
public PhotoMovement photoMovement1;
public Button returnbtn;
private async void Awake()
{
await ConnectWebSocket();
}
private async void Start()
{
TimeText.gameObject.SetActive(false);
@ -70,7 +77,10 @@ public class WebFishingPK : MonoBehaviour
{
await SendJsonMessage(int.Parse(Dropdown.options[Dropdown.value].text), pos);
});
returnbtn.onClick.AddListener(async () =>
{
await SendJsonMessage("{ \"code\": \"FISHING_PK\", \"content\": \"{\\\"action\\\":\\\"LEAVE\\\"}\" }");
});
}
private void ChangeButtonColor(Button btn, UnityEngine.Color color)
{
@ -132,6 +142,7 @@ public class WebFishingPK : MonoBehaviour
if (fishResponse?.data != null)
{
Debug.Log(fishResponse.data.balance);
balance.text= fishResponse.data.balance.ToString();
Debug.Log(fishResponse.data.intro_text);
introtext.text = fishResponse.data.intro_text;
Debug.Log(fishResponse.data.countdown);
@ -142,11 +153,16 @@ public class WebFishingPK : MonoBehaviour
{
photoMovement.Del1();
photoMovement.To1();
photoMovement1.Del1();
photoMovement1.To1();
}
else
{
photoMovement.Del1();
photoMovement.To2();
photoMovement1.Del1();
photoMovement1.To2();
}
Debug.Log(fishResponse.data.amount_left);
@ -165,6 +181,7 @@ public class WebFishingPK : MonoBehaviour
if (fishResponse1 != null && fishResponse1.data != null)
{
Debug.Log(fishResponse1.data.balance);
balance.text = fishResponse1.data.balance.ToString();
}
else
{
@ -187,11 +204,15 @@ public class WebFishingPK : MonoBehaviour
{
photoMovement.Del1();
photoMovement.To1();
photoMovement1.Del1();
photoMovement1.To1();
}
else
{
photoMovement.Del1();
photoMovement.To2();
photoMovement1.Del1();
photoMovement1.To2();
}
Debug.Log(fishResponse2.data.amount_left);
Debug.Log(fishResponse2.data.amount_right);
@ -210,6 +231,7 @@ public class WebFishingPK : MonoBehaviour
if (fishResponse3 != null && fishResponse3.data != null)
{
Debug.Log(fishResponse3.data.balance);
balance.text = fishResponse3.data.balance.ToString();
Debug.Log(fishResponse3.data.status);
Debug.Log(fishResponse3.data.amount);
Debug.Log(fishResponse3.data.reward);

View File

@ -38,6 +38,10 @@ public class WebJoinroom : MonoBehaviour
public GameObject yupanel;
public Image zhanshiyu;
public Button returnbtn;
private async void Awake()
{
await ConnectWebSocket();
}
private async void Start()
{
yupanel.SetActive(false);
@ -45,7 +49,6 @@ public class WebJoinroom : MonoBehaviour
Debug.Log(PlayerPrefs.GetString("UserToken"));
AuthorizationValue = PlayerPrefs.GetString("UserToken");
await ConnectWebSocket();
returnbtn.onClick.AddListener(async () =>
{
await SendJsonMessage("{ \"code\": \"FISHING\", \"content\": \"{\\\"action\\\":\\\"LEAVE\\\"}\" }");

View File

@ -0,0 +1,270 @@
using System;
using System.Collections.Generic;
using System.Net.WebSockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using UnityEngine;
using Newtonsoft.Json;
using System.Drawing;
using UnityEngine.UI;
using DG.Tweening;
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;
//界面元素
public Text balance;
public Text intro_text;
public Text surpluscount_text;
public Button Tourubtn;
private float lastCallTime = 0f;
float remainingTime = 0f;
public Text TimeText;
private float interval = 1f; // 每秒调用一次
public Button returnbtn;
private async void Awake()
{
await ConnectWebSocket();
}
private async void Start()
{
TimeText.gameObject.transform.parent.gameObject.SetActive(false);
Debug.Log(PlayerPrefs.GetString("UserToken"));
AuthorizationValue = PlayerPrefs.GetString("UserToken");
returnbtn.onClick.AddListener(async () =>
{
await SendJsonMessage("{ \"code\": \"WEST_COWBOY\", \"content\": \"{\\\"action\\\":\\\"LEAVE\\\"}\" }");
});
Tourubtn.onClick.AddListener(async () =>
{
await SendJsonMessage(10,1);
});
// 调用发送方法
await SendJsonMessage("{ \"code\": \"WEST_COWBOY\", \"content\": \"{\\\"action\\\":\\\"INFO\\\"}\" }");
}
private async Task ConnectWebSocket()
{
_webSocket = new ClientWebSocket();
// 添加 Authorization 头
_webSocket.Options.SetRequestHeader("Authorization", "Bearer " + AuthorizationValue);
// _webSocket.Options.SetRequestHeader("client-info",);
try
{
Debug.Log("正在连接到 WebSocket...");
await _webSocket.ConnectAsync(new Uri(WebSocketUri), CancellationToken.None);
Debug.Log("WebSocket 连接成功!");
// 开始接收消息
_ = ReceiveMessages();
}
catch (Exception e)
{
Debug.LogError($"WebSocket 连接失败:{e.Message}");
}
}
private async Task ReceiveMessages()
{
var buffer = new byte[1024];
try
{
while (_webSocket.State == WebSocketState.Open)
{
var result = await _webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
if (result.MessageType == WebSocketMessageType.Close)
{
Debug.Log("WebSocket 连接已被服务器关闭。");
await _webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, "关闭连接", CancellationToken.None);
}
else
{
var message = Encoding.UTF8.GetString(buffer, 0, result.Count);
Debug.Log($"接收到消息:{message}");
var baseResponse = JsonConvert.DeserializeObject<BaseResponse>(message);
Promptmgr.Instance.PromptBubble(baseResponse.message);
if (baseResponse != null)
{
switch (baseResponse.code)
{
// 解析消息为 Fishresponse 对象
case "FISHING_INFO":
// 解析为 FishJoinroomresponse 类型
FishJoinroomresponse fishResponse = JsonConvert.DeserializeObject<FishJoinroomresponse>(message);
if (fishResponse?.data != null)
{
}
break;
case "FISHING_BETTING":
// 解析消息为 Fishresponse 对象
FishBetonresponse fishResponse1 = JsonConvert.DeserializeObject<FishBetonresponse>(message);
Promptmgr.Instance.PromptBubble(fishResponse1.message);
// 检查是否成功反序列化
if (fishResponse1 != null && fishResponse1.data != null)
{
}
else
{
Debug.LogWarning("收到的消息无法解析为 Fishresponse 对象。");
}
break;
case "FISHING_FISHING":
// 解析消息为 Fishresponse 对象
Fishingresponse fishResponse2 = JsonConvert.DeserializeObject<Fishingresponse>(message);
//Promptmgr.Instance.PromptBubble(fishResponse2.message);
// 检查是否成功反序列化
if (fishResponse2 != null && fishResponse2.data != null)
{
}
else
{
Debug.LogWarning("收到的消息无法解析为 Fishresponse 对象。");
}
break;
case "BALANCE":
break;
}
}
}
}
}
catch (Exception e)
{
Debug.LogError($"接收消息时出错:{e.Message}");
}
}
public async Task SendJsonMessage(int count,int pos)
{
if (_webSocket == null || _webSocket.State != WebSocketState.Open)
{
Debug.LogError("WebSocket 未连接,无法发送消息。");
return;
}
try
{
var message = new
{
code = "WEST_COWBOY",
content = $"{{\"action\":\"BETTING\",\"amount\":{count},\"count\":{pos}}}"
};
// 将对象序列化为 JSON 字符串
string jsonMessage = JsonConvert.SerializeObject(message);
var encodedMessage = Encoding.UTF8.GetBytes(jsonMessage);
var buffer = new ArraySegment<byte>(encodedMessage);
await _webSocket.SendAsync(buffer, WebSocketMessageType.Text, true, CancellationToken.None);
Debug.Log($"已发送 JSON 消息:{jsonMessage}");
}
catch (Exception e)
{
Debug.LogError($"发送消息时出错:{e.Message}");
}
}
public async Task SendJsonMessage(string json)
{
if (_webSocket == null || _webSocket.State != WebSocketState.Open)
{
Debug.LogError("WebSocket 未连接,无法发送消息。");
return;
}
try
{
var encodedMessage = Encoding.UTF8.GetBytes(json);
var buffer = new ArraySegment<byte>(encodedMessage);
await _webSocket.SendAsync(buffer, WebSocketMessageType.Text, true, CancellationToken.None);
Debug.Log($"已发送 JSON 消息:{json}");
}
catch (Exception e)
{
Debug.LogError($"发送消息时出错:{e.Message}");
}
}
private async void OnApplicationQuit()
{
if (_webSocket != null && _webSocket.State == WebSocketState.Open)
{
await _webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, "应用程序退出", CancellationToken.None);
_webSocket.Dispose();
Debug.Log("WebSocket 连接已关闭。");
}
}
public void disbalance(float detail)
{
balance.text = detail.ToString();
}
public void dissurplus(float detail, int p)
{
surpluscount_text.text = (p * (int)detail).ToString() + "金币";
}
void UpdateCountdownText(float remainingTime)
{
// 将剩余时间转换为小时、分钟和秒
int hours = Mathf.FloorToInt(remainingTime / 3600);
int minutes = Mathf.FloorToInt((remainingTime % 3600) / 60);
int seconds = Mathf.FloorToInt(remainingTime % 60);
// 使用格式化字符串显示倒计时00:00:00
TimeText.text = string.Format("{0:D2}:{1:D2}:{2:D2}", hours, minutes, seconds);
}
private void Update()
{
if (Time.time - lastCallTime >= interval)
{
// 每秒调用一次的代码
if (remainingTime > 0)
{
remainingTime -= 1;
UpdateCountdownText(remainingTime);
Debug.Log("进入倒计时");
}
if (remainingTime <= 0)
{
TimeText.gameObject.transform.parent.gameObject.SetActive(false);
}
// 更新上次调用时间
lastCallTime = Time.time;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9163bcd1e1639854aae4695bd6c798d4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: