Merge branch 'main' of http://shu.sheziwanglo.cn:3000/shurongsen/Cute_demon_attacks
This commit is contained in:
commit
ef40f78a41
@ -397,7 +397,7 @@
|
|||||||
"S_1": {
|
"S_1": {
|
||||||
"1": {
|
"1": {
|
||||||
"SkillList": [
|
"SkillList": [
|
||||||
"0"
|
"skill_7"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"2": {
|
"2": {
|
||||||
@ -411,7 +411,9 @@
|
|||||||
"DamageBuff": 0.35
|
"DamageBuff": 0.35
|
||||||
},
|
},
|
||||||
"5": {
|
"5": {
|
||||||
"DamageBuff": 0.3,
|
"SkillList": [
|
||||||
|
"skill_6"
|
||||||
|
],
|
||||||
"speedOfBullets": -0.1
|
"speedOfBullets": -0.1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -424,7 +426,7 @@
|
|||||||
},
|
},
|
||||||
"3": {
|
"3": {
|
||||||
"numberOfBullets": 1,
|
"numberOfBullets": 1,
|
||||||
"speedOfBullets": -1
|
"speedOfBullets": -0.1
|
||||||
},
|
},
|
||||||
"4": {
|
"4": {
|
||||||
"DamageBuff": 0.35
|
"DamageBuff": 0.35
|
||||||
|
@ -4853,6 +4853,7 @@ MonoBehaviour:
|
|||||||
IsMove: 1
|
IsMove: 1
|
||||||
Collider2D: {fileID: 4606866971114100020}
|
Collider2D: {fileID: 4606866971114100020}
|
||||||
effectPres: []
|
effectPres: []
|
||||||
|
timer: 0
|
||||||
NumberOfBulletAttacks: 1
|
NumberOfBulletAttacks: 1
|
||||||
Target: {fileID: 0}
|
Target: {fileID: 0}
|
||||||
noLockEnemy: 0
|
noLockEnemy: 0
|
||||||
|
@ -396,7 +396,7 @@ MonoBehaviour:
|
|||||||
- {fileID: 1680116210, guid: 1b13224ac6b7e4b4d931ed9097e795bf, type: 3}
|
- {fileID: 1680116210, guid: 1b13224ac6b7e4b4d931ed9097e795bf, type: 3}
|
||||||
- {fileID: -274749663, guid: 1b13224ac6b7e4b4d931ed9097e795bf, type: 3}
|
- {fileID: -274749663, guid: 1b13224ac6b7e4b4d931ed9097e795bf, type: 3}
|
||||||
- {fileID: 1383633982, guid: 1b13224ac6b7e4b4d931ed9097e795bf, type: 3}
|
- {fileID: 1383633982, guid: 1b13224ac6b7e4b4d931ed9097e795bf, type: 3}
|
||||||
CharacterAnimationFrameInterval: 50
|
CharacterAnimationFrameInterval: 18
|
||||||
- value:
|
- value:
|
||||||
- {fileID: 1179033219, guid: 85cc96495bc9d00489f3b17142d7de66, type: 3}
|
- {fileID: 1179033219, guid: 85cc96495bc9d00489f3b17142d7de66, type: 3}
|
||||||
- {fileID: -467593880, guid: 85cc96495bc9d00489f3b17142d7de66, type: 3}
|
- {fileID: -467593880, guid: 85cc96495bc9d00489f3b17142d7de66, type: 3}
|
||||||
@ -429,7 +429,7 @@ MonoBehaviour:
|
|||||||
animationHighlight: 0
|
animationHighlight: 0
|
||||||
spriteRenderer: {fileID: 4703411402842800734}
|
spriteRenderer: {fileID: 4703411402842800734}
|
||||||
image: {fileID: 0}
|
image: {fileID: 0}
|
||||||
isAnimationPlay: 0
|
isAnimationPlay: 1
|
||||||
mycollider: {fileID: 5307107303863668509}
|
mycollider: {fileID: 5307107303863668509}
|
||||||
attackClass: {fileID: 0}
|
attackClass: {fileID: 0}
|
||||||
CurrentIndex: 33
|
CurrentIndex: 33
|
||||||
@ -590,8 +590,8 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 4703411402842800732}
|
m_GameObject: {fileID: 4703411402842800732}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 1.25, z: 0}
|
m_LocalPosition: {x: 0, y: 0.34, z: 0}
|
||||||
m_LocalScale: {x: 0.26, y: 0.26, z: 0.26}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 1
|
m_ConstrainProportionsScale: 1
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 4703411402065954782}
|
m_Father: {fileID: 4703411402065954782}
|
||||||
@ -638,15 +638,15 @@ SpriteRenderer:
|
|||||||
m_SortingLayerID: 0
|
m_SortingLayerID: 0
|
||||||
m_SortingLayer: 0
|
m_SortingLayer: 0
|
||||||
m_SortingOrder: 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_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
m_FlipX: 0
|
m_FlipX: 0
|
||||||
m_FlipY: 0
|
m_FlipY: 0
|
||||||
m_DrawMode: 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_AdaptiveModeThreshold: 0.5
|
||||||
m_SpriteTileMode: 0
|
m_SpriteTileMode: 0
|
||||||
m_WasSpriteAssigned: 0
|
m_WasSpriteAssigned: 1
|
||||||
m_MaskInteraction: 0
|
m_MaskInteraction: 0
|
||||||
m_SpriteSortPoint: 0
|
m_SpriteSortPoint: 0
|
||||||
--- !u!1 &6362446851701897971
|
--- !u!1 &6362446851701897971
|
||||||
|
@ -419,7 +419,7 @@ GameObject:
|
|||||||
- component: {fileID: 8433650274028726420}
|
- component: {fileID: 8433650274028726420}
|
||||||
- component: {fileID: -3836672401185760439}
|
- component: {fileID: -3836672401185760439}
|
||||||
- component: {fileID: 1608620729910401442}
|
- component: {fileID: 1608620729910401442}
|
||||||
- component: {fileID: 2427917370826210288}
|
- component: {fileID: 6754849144717393997}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: jbf
|
m_Name: jbf
|
||||||
m_TagString: Player
|
m_TagString: Player
|
||||||
@ -514,7 +514,7 @@ MonoBehaviour:
|
|||||||
normalIndex: 0
|
normalIndex: 0
|
||||||
isHit: 0
|
isHit: 0
|
||||||
myTags: 0
|
myTags: 0
|
||||||
mySkillUp: {fileID: 2427917370826210288}
|
mySkillUp: {fileID: 6754849144717393997}
|
||||||
IsDead: 0
|
IsDead: 0
|
||||||
HaveDieTime: 0
|
HaveDieTime: 0
|
||||||
enemyId:
|
enemyId:
|
||||||
@ -573,7 +573,7 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
tower: {fileID: 0}
|
tower: {fileID: 0}
|
||||||
Tag: tower
|
Tag: tower
|
||||||
--- !u!114 &2427917370826210288
|
--- !u!114 &6754849144717393997
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
@ -582,7 +582,7 @@ MonoBehaviour:
|
|||||||
m_GameObject: {fileID: 8433650275485930554}
|
m_GameObject: {fileID: 8433650275485930554}
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: 8264f0a4afc0aa347bf9dad42df2617a, type: 3}
|
m_Script: {fileID: 11500000, guid: 06f1271e2c91952498f98563968b9cae, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
description: "\u66F4\u65B0\u540E\u7684\u840C\u5996\uFF0C\uFF1A\u4F7F\u7528\u65B9\u6CD5xxxxxxxx"
|
description: "\u66F4\u65B0\u540E\u7684\u840C\u5996\uFF0C\uFF1A\u4F7F\u7528\u65B9\u6CD5xxxxxxxx"
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -21,7 +21,7 @@ public class SkillUp : Fun
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
attackRange=value;
|
attackRange=value;
|
||||||
role.AttackRange +=attackRange;
|
role.AttackRange += value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ public class SkillUp : Fun
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
attackCooldown = value;
|
attackCooldown = value;
|
||||||
role.AttackCD *= (1 + attackCooldown);
|
role.AttackCD *= (1 + value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ public class SkillUp : Fun
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
attackDuration = value;
|
attackDuration = value;
|
||||||
attack.AttackStayTime *= (1 + attackDuration);
|
attack.AttackStayTime *= (1 + value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[HideInInspector][Header("攻击子弹数量加成")] public int numberOfBullets = 0;
|
[HideInInspector][Header("攻击子弹数量加成")] public int numberOfBullets = 0;
|
||||||
@ -58,7 +58,11 @@ public class SkillUp : Fun
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
numberOfBullets = value;
|
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;
|
[HideInInspector][Header("攻击子弹速度加成")] public float speedOfBullets = 0f;
|
||||||
@ -70,7 +74,7 @@ public class SkillUp : Fun
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
speedOfBullets = value;
|
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];
|
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;
|
AttackRange = info.Range;
|
||||||
Debug.Log("¹¥»÷·¶Î§+"+ info.Range +"||"+ attackRange.ToString()+"=================================");
|
// 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;
|
DamageUp += info.DamageBuff;
|
||||||
|
91
meng_yao/Assets/script/A_Fight/SkillUp/jbf_SkillUp.cs
Normal file
91
meng_yao/Assets/script/A_Fight/SkillUp/jbf_SkillUp.cs
Normal 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();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
11
meng_yao/Assets/script/A_Fight/SkillUp/jbf_SkillUp.cs.meta
Normal file
11
meng_yao/Assets/script/A_Fight/SkillUp/jbf_SkillUp.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 06f1271e2c91952498f98563968b9cae
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -1,6 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Unity.VisualScripting;
|
||||||
using UnityEngine.Rendering;
|
using UnityEngine.Rendering;
|
||||||
|
|
||||||
|
|
||||||
@ -99,12 +100,13 @@ public class SpawnMonster : Base
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FixedUpdate()
|
||||||
void Update()
|
|
||||||
{
|
{
|
||||||
UpdateNodeList();
|
//UpdateNodeList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public async void StartSpawning()
|
public async void StartSpawning()
|
||||||
{
|
{
|
||||||
|
@ -140,10 +140,10 @@ public class FishingPK : MonoBehaviour
|
|||||||
Debug.Log(fishResponse.data.countdown_type);
|
Debug.Log(fishResponse.data.countdown_type);
|
||||||
if(fishResponse.data.countdown_type==0)
|
if(fishResponse.data.countdown_type==0)
|
||||||
{
|
{
|
||||||
photoMovement.type = true;
|
|
||||||
photoMovement.Del1();
|
photoMovement.Del1();
|
||||||
photoMovement.To1();
|
photoMovement.To1();
|
||||||
photoMovement1.type = true;
|
|
||||||
photoMovement1.Del1();
|
photoMovement1.Del1();
|
||||||
photoMovement1.To1();
|
photoMovement1.To1();
|
||||||
|
|
||||||
@ -151,11 +151,11 @@ public class FishingPK : MonoBehaviour
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
photoMovement.Del1();
|
photoMovement.Del1();
|
||||||
photoMovement.type = false;
|
|
||||||
|
|
||||||
photoMovement.To2();
|
photoMovement.To2();
|
||||||
photoMovement1.Del1();
|
photoMovement1.Del1();
|
||||||
photoMovement1.type = false;
|
|
||||||
|
|
||||||
photoMovement1.To2();
|
photoMovement1.To2();
|
||||||
|
|
||||||
@ -196,21 +196,21 @@ public class FishingPK : MonoBehaviour
|
|||||||
Debug.Log(fishResponse2.data.countdown_type);
|
Debug.Log(fishResponse2.data.countdown_type);
|
||||||
if (fishResponse2.data.countdown_type == 0)
|
if (fishResponse2.data.countdown_type == 0)
|
||||||
{
|
{
|
||||||
photoMovement.type = true;
|
|
||||||
photoMovement.Del1();
|
photoMovement.Del1();
|
||||||
photoMovement.To1();
|
photoMovement.To1();
|
||||||
photoMovement1.type = true;
|
|
||||||
photoMovement1.Del1();
|
photoMovement1.Del1();
|
||||||
photoMovement1.To1();
|
photoMovement1.To1();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
photoMovement.Del1();
|
photoMovement.Del1();
|
||||||
photoMovement.type = false;
|
|
||||||
|
|
||||||
photoMovement.To2();
|
photoMovement.To2();
|
||||||
photoMovement1.Del1();
|
photoMovement1.Del1();
|
||||||
photoMovement1.type = false;
|
|
||||||
|
|
||||||
photoMovement1.To2();
|
photoMovement1.To2();
|
||||||
}
|
}
|
||||||
|
@ -23,54 +23,92 @@ public class PhotoMovement : MonoBehaviour
|
|||||||
public bool type=false;
|
public bool type=false;
|
||||||
public Sprite[] sprites;
|
public Sprite[] sprites;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
// 控制 To1 和 To2 的执行
|
||||||
|
private bool isTo1Running = false; // 标识 To1 是否正在执行
|
||||||
|
private bool isTo2Running = false; // 标识 To2 是否正在执行
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
image.gameObject.SetActive(false);
|
image.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void To1()
|
public async void To1()
|
||||||
{
|
{
|
||||||
if (type == true)
|
// 如果 To1 已经在执行,则返回,不执行新的 To1
|
||||||
{
|
if (isTo1Running || isTo2Running)
|
||||||
To1();
|
return;
|
||||||
}
|
|
||||||
|
isTo1Running = true; // 设置 To1 为正在执行状态
|
||||||
|
|
||||||
|
// 执行 To1 的操作
|
||||||
shuaigan.gameObject.SetActive(true);
|
shuaigan.gameObject.SetActive(true);
|
||||||
var time=shuaigan.GetComponent<SpriteAniation>().sprites.Count * shuaigan.GetComponent<SpriteAniation>().Aintime;
|
var time = shuaigan.GetComponent<SpriteAniation>().sprites.Count * shuaigan.GetComponent<SpriteAniation>().Aintime;
|
||||||
await Task.Delay((int)time);
|
await Task.Delay((int)time);
|
||||||
|
|
||||||
daiji.gameObject.SetActive(true);
|
daiji.gameObject.SetActive(true);
|
||||||
shuaigan.gameObject.SetActive(false);
|
shuaigan.gameObject.SetActive(false);
|
||||||
//await Task.Delay(1000);
|
|
||||||
|
// 延迟 1000 毫秒(或者你可以自定义)
|
||||||
daiji.gameObject.SetActive(false);
|
daiji.gameObject.SetActive(false);
|
||||||
shougan.gameObject.SetActive(true);
|
shougan.gameObject.SetActive(true);
|
||||||
|
|
||||||
var time1 = shougan.GetComponent<SpriteAniation>().sprites.Count * shougan.GetComponent<SpriteAniation>().Aintime;
|
var time1 = shougan.GetComponent<SpriteAniation>().sprites.Count * shougan.GetComponent<SpriteAniation>().Aintime;
|
||||||
|
|
||||||
|
// 开始沿路径移动
|
||||||
StartCoroutine(MoveAlongPath());
|
StartCoroutine(MoveAlongPath());
|
||||||
currentPathIndex = 0;
|
currentPathIndex = 0;
|
||||||
image.gameObject.SetActive(true);
|
image.gameObject.SetActive(true);
|
||||||
image.GetComponent<Image>().sprite = sprites[count% sprites.Length];
|
|
||||||
count++;
|
|
||||||
await Task.Delay((int)time1-100);
|
|
||||||
Del1();
|
|
||||||
|
|
||||||
|
|
||||||
|
// 随机选择一个 sprite
|
||||||
|
int randomIndex = Random.Range(0, sprites.Length); // 获取随机索引
|
||||||
|
image.GetComponent<Image>().sprite = sprites[randomIndex]; // 使用随机的 sprite
|
||||||
|
count++;
|
||||||
|
|
||||||
|
await Task.Delay((int)time1 - 100); // 延迟结束,准备执行下一个步骤
|
||||||
|
|
||||||
|
Del1(); // 结束当前操作
|
||||||
|
isTo1Running = false; // 执行完 To1,恢复为未执行状态
|
||||||
|
|
||||||
|
// 如果没有正在执行 To2,则继续执行 To1
|
||||||
|
if (!isTo2Running)
|
||||||
|
{
|
||||||
|
To1();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Del1()
|
public void Del1()
|
||||||
{
|
{
|
||||||
image.gameObject.SetActive(false);
|
image.gameObject.SetActive(false);
|
||||||
shuaigan.gameObject.SetActive(false);
|
shuaigan.gameObject.SetActive(false);
|
||||||
daiji.gameObject.SetActive(false) ;
|
daiji.gameObject.SetActive(false);
|
||||||
shougan.gameObject .SetActive(false) ;
|
shougan.gameObject.SetActive(false);
|
||||||
currentPathIndex = 0;
|
currentPathIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void To2()
|
public async void To2()
|
||||||
{
|
{
|
||||||
|
// 如果 To1 正在执行,打断 To1 的执行
|
||||||
|
isTo2Running = true; // 标记 To2 为正在执行
|
||||||
|
|
||||||
|
// 等待 To1 完成执行(如果 To1 正在执行)
|
||||||
|
while (isTo1Running)
|
||||||
|
{
|
||||||
|
await Task.Delay(100); // 检查 To1 的执行状态
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行 To2 的操作
|
||||||
shuaigan.gameObject.SetActive(true);
|
shuaigan.gameObject.SetActive(true);
|
||||||
var time = shuaigan.GetComponent<SpriteAniation>().sprites.Count * shuaigan.GetComponent<SpriteAniation>().Aintime;
|
var time = shuaigan.GetComponent<SpriteAniation>().sprites.Count * shuaigan.GetComponent<SpriteAniation>().Aintime;
|
||||||
await Task.Delay((int)time);
|
await Task.Delay((int)time);
|
||||||
|
|
||||||
daiji.gameObject.SetActive(true);
|
daiji.gameObject.SetActive(true);
|
||||||
shuaigan.gameObject.SetActive(false);
|
shuaigan.gameObject.SetActive(false);
|
||||||
|
|
||||||
|
// 执行完 To2 后,恢复 To2 的标志为 false
|
||||||
|
isTo2Running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerator MoveAlongPath()
|
private IEnumerator MoveAlongPath()
|
||||||
{
|
{
|
||||||
// 持续沿着路径点移动
|
// 持续沿着路径点移动
|
||||||
@ -86,19 +124,21 @@ public class PhotoMovement : MonoBehaviour
|
|||||||
// 移动到下一个路径点
|
// 移动到下一个路径点
|
||||||
currentPathIndex++;
|
currentPathIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
image.gameObject.SetActive(false);
|
image.gameObject.SetActive(false);
|
||||||
shougan.gameObject.SetActive(false);
|
shougan.gameObject.SetActive(false);
|
||||||
image.transform.localPosition=new Vector3 (467, -144, 0);
|
image.transform.localPosition = new Vector3(467, -144, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void change()
|
public void change()
|
||||||
{
|
{
|
||||||
StartCoroutine(MoveAlongPath());
|
StartCoroutine(MoveAlongPath());
|
||||||
currentPathIndex = 0;
|
currentPathIndex = 0;
|
||||||
image.gameObject.SetActive(true);
|
image.gameObject.SetActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ public class WebFishingPK : MonoBehaviour
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Text lefttext;
|
public Text lefttext;
|
||||||
public Text righttext;
|
public Text righttext;
|
||||||
|
public Text balance;
|
||||||
public Button TouruBtn;
|
public Button TouruBtn;
|
||||||
public Button selleftbtn;
|
public Button selleftbtn;
|
||||||
public Button selrightbtn;
|
public Button selrightbtn;
|
||||||
@ -44,6 +45,12 @@ public class WebFishingPK : MonoBehaviour
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
///
|
///
|
||||||
public PhotoMovement photoMovement;
|
public PhotoMovement photoMovement;
|
||||||
|
public PhotoMovement photoMovement1;
|
||||||
|
public Button returnbtn;
|
||||||
|
private async void Awake()
|
||||||
|
{
|
||||||
|
await ConnectWebSocket();
|
||||||
|
}
|
||||||
private async void Start()
|
private async void Start()
|
||||||
{
|
{
|
||||||
TimeText.gameObject.SetActive(false);
|
TimeText.gameObject.SetActive(false);
|
||||||
@ -70,7 +77,10 @@ public class WebFishingPK : MonoBehaviour
|
|||||||
{
|
{
|
||||||
await SendJsonMessage(int.Parse(Dropdown.options[Dropdown.value].text), pos);
|
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)
|
private void ChangeButtonColor(Button btn, UnityEngine.Color color)
|
||||||
{
|
{
|
||||||
@ -132,6 +142,7 @@ public class WebFishingPK : MonoBehaviour
|
|||||||
if (fishResponse?.data != null)
|
if (fishResponse?.data != null)
|
||||||
{
|
{
|
||||||
Debug.Log(fishResponse.data.balance);
|
Debug.Log(fishResponse.data.balance);
|
||||||
|
balance.text= fishResponse.data.balance.ToString();
|
||||||
Debug.Log(fishResponse.data.intro_text);
|
Debug.Log(fishResponse.data.intro_text);
|
||||||
introtext.text = fishResponse.data.intro_text;
|
introtext.text = fishResponse.data.intro_text;
|
||||||
Debug.Log(fishResponse.data.countdown);
|
Debug.Log(fishResponse.data.countdown);
|
||||||
@ -142,11 +153,16 @@ public class WebFishingPK : MonoBehaviour
|
|||||||
{
|
{
|
||||||
photoMovement.Del1();
|
photoMovement.Del1();
|
||||||
photoMovement.To1();
|
photoMovement.To1();
|
||||||
|
photoMovement1.Del1();
|
||||||
|
photoMovement1.To1();
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
photoMovement.Del1();
|
photoMovement.Del1();
|
||||||
photoMovement.To2();
|
photoMovement.To2();
|
||||||
|
photoMovement1.Del1();
|
||||||
|
photoMovement1.To2();
|
||||||
|
|
||||||
}
|
}
|
||||||
Debug.Log(fishResponse.data.amount_left);
|
Debug.Log(fishResponse.data.amount_left);
|
||||||
@ -165,6 +181,7 @@ public class WebFishingPK : MonoBehaviour
|
|||||||
if (fishResponse1 != null && fishResponse1.data != null)
|
if (fishResponse1 != null && fishResponse1.data != null)
|
||||||
{
|
{
|
||||||
Debug.Log(fishResponse1.data.balance);
|
Debug.Log(fishResponse1.data.balance);
|
||||||
|
balance.text = fishResponse1.data.balance.ToString();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -187,11 +204,15 @@ public class WebFishingPK : MonoBehaviour
|
|||||||
{
|
{
|
||||||
photoMovement.Del1();
|
photoMovement.Del1();
|
||||||
photoMovement.To1();
|
photoMovement.To1();
|
||||||
|
photoMovement1.Del1();
|
||||||
|
photoMovement1.To1();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
photoMovement.Del1();
|
photoMovement.Del1();
|
||||||
photoMovement.To2();
|
photoMovement.To2();
|
||||||
|
photoMovement1.Del1();
|
||||||
|
photoMovement1.To2();
|
||||||
}
|
}
|
||||||
Debug.Log(fishResponse2.data.amount_left);
|
Debug.Log(fishResponse2.data.amount_left);
|
||||||
Debug.Log(fishResponse2.data.amount_right);
|
Debug.Log(fishResponse2.data.amount_right);
|
||||||
@ -210,6 +231,7 @@ public class WebFishingPK : MonoBehaviour
|
|||||||
if (fishResponse3 != null && fishResponse3.data != null)
|
if (fishResponse3 != null && fishResponse3.data != null)
|
||||||
{
|
{
|
||||||
Debug.Log(fishResponse3.data.balance);
|
Debug.Log(fishResponse3.data.balance);
|
||||||
|
balance.text = fishResponse3.data.balance.ToString();
|
||||||
Debug.Log(fishResponse3.data.status);
|
Debug.Log(fishResponse3.data.status);
|
||||||
Debug.Log(fishResponse3.data.amount);
|
Debug.Log(fishResponse3.data.amount);
|
||||||
Debug.Log(fishResponse3.data.reward);
|
Debug.Log(fishResponse3.data.reward);
|
||||||
|
@ -38,6 +38,10 @@ public class WebJoinroom : MonoBehaviour
|
|||||||
public GameObject yupanel;
|
public GameObject yupanel;
|
||||||
public Image zhanshiyu;
|
public Image zhanshiyu;
|
||||||
public Button returnbtn;
|
public Button returnbtn;
|
||||||
|
private async void Awake()
|
||||||
|
{
|
||||||
|
await ConnectWebSocket();
|
||||||
|
}
|
||||||
private async void Start()
|
private async void Start()
|
||||||
{
|
{
|
||||||
yupanel.SetActive(false);
|
yupanel.SetActive(false);
|
||||||
@ -45,7 +49,6 @@ public class WebJoinroom : MonoBehaviour
|
|||||||
Debug.Log(PlayerPrefs.GetString("UserToken"));
|
Debug.Log(PlayerPrefs.GetString("UserToken"));
|
||||||
AuthorizationValue = PlayerPrefs.GetString("UserToken");
|
AuthorizationValue = PlayerPrefs.GetString("UserToken");
|
||||||
|
|
||||||
await ConnectWebSocket();
|
|
||||||
returnbtn.onClick.AddListener(async () =>
|
returnbtn.onClick.AddListener(async () =>
|
||||||
{
|
{
|
||||||
await SendJsonMessage("{ \"code\": \"FISHING\", \"content\": \"{\\\"action\\\":\\\"LEAVE\\\"}\" }");
|
await SendJsonMessage("{ \"code\": \"FISHING\", \"content\": \"{\\\"action\\\":\\\"LEAVE\\\"}\" }");
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9163bcd1e1639854aae4695bd6c798d4
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user