钓手动画

This commit is contained in:
杨号敬 2025-01-09 11:23:17 +08:00
parent 5b904e8bfa
commit acb4d90826
4 changed files with 1181 additions and 181 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,7 @@ using System.Collections;
using UnityEngine; using UnityEngine;
using DG.Tweening; using DG.Tweening;
using System.Threading.Tasks; using System.Threading.Tasks;
using UnityEngine.UI;
public class PhotoMovement : MonoBehaviour public class PhotoMovement : MonoBehaviour
{ {
@ -20,33 +21,37 @@ public class PhotoMovement : MonoBehaviour
public GameObject shuaigan; public GameObject shuaigan;
public GameObject shougan; public GameObject shougan;
public bool type=false; public bool type=false;
public Sprite[] sprites;
int count = 0;
private void Start() private void Start()
{ {
image.gameObject.SetActive(false); image.gameObject.SetActive(false);
} }
public void changetype()
public async void To1()
{ {
while(type) if (type == true)
{ {
To1(); To1();
} }
}
public async void 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); //await Task.Delay(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);
await Task.Delay((int)time1); image.GetComponent<Image>().sprite = sprites[count% sprites.Length];
count++;
await Task.Delay((int)time1-100);
Del1(); Del1();
} }
public void Del1() public void Del1()
{ {
@ -83,6 +88,7 @@ public class PhotoMovement : MonoBehaviour
} }
image.gameObject.SetActive(false); image.gameObject.SetActive(false);
shougan.gameObject.SetActive(false); shougan.gameObject.SetActive(false);
image.transform.localPosition=new Vector3 (467, -144, 0);
} }
public void change() public void change()
@ -91,4 +97,8 @@ public class PhotoMovement : MonoBehaviour
currentPathIndex = 0; currentPathIndex = 0;
image.gameObject.SetActive(true); image.gameObject.SetActive(true);
} }
public void Update()
{
}
} }

View File

@ -38,12 +38,13 @@ public class WebFishingPK : MonoBehaviour
private UnityEngine.Color normalColor = UnityEngine.Color.white; // 默认颜色 private UnityEngine.Color normalColor = UnityEngine.Color.white; // 默认颜色
private UnityEngine.Color selectedColor = UnityEngine.Color.blue; // 选中时的颜色 private UnityEngine.Color selectedColor = UnityEngine.Color.blue; // 选中时的颜色
public Button returnbtn;
/// <summary> /// <summary>
/// 钓鱼 /// 钓鱼
/// </summary> /// </summary>
/// ///
public PhotoMovement photoMovement; public PhotoMovement photoMovement;
public PhotoMovement photoMovement1;
private async void Start() private async void Start()
{ {
TimeText.gameObject.SetActive(false); TimeText.gameObject.SetActive(false);
@ -70,6 +71,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)
@ -140,13 +145,24 @@ public class WebFishingPK : 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.To1();
} }
else else
{ {
photoMovement.Del1(); photoMovement.Del1();
photoMovement.type = false;
photoMovement.To2(); photoMovement.To2();
photoMovement1.Del1();
photoMovement1.type = false;
photoMovement1.To2();
} }
Debug.Log(fishResponse.data.amount_left); Debug.Log(fishResponse.data.amount_left);
@ -185,13 +201,23 @@ public class WebFishingPK : 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.To1();
} }
else else
{ {
photoMovement.Del1(); photoMovement.Del1();
photoMovement.type = false;
photoMovement.To2(); photoMovement.To2();
photoMovement1.Del1();
photoMovement1.type = false;
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);

View File

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