钓手PK
This commit is contained in:
parent
86c7ff0128
commit
b2c07eb511
File diff suppressed because it is too large
Load Diff
@ -90,7 +90,7 @@ public class SkillUp : Fun
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
description = "更新后的萌耀,:使用方法xxxxxxxx";
|
||||
//description = "更新后的萌耀,:使用方法xxxxxxxx";
|
||||
}
|
||||
|
||||
public void Up(string mengyao_id,string skill_id,string level)
|
||||
|
@ -0,0 +1,94 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using DG.Tweening;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public class PhotoMovement : MonoBehaviour
|
||||
{
|
||||
// 存储路径点的位置和旋转角度
|
||||
[System.Serializable]
|
||||
public class PathPoint
|
||||
{
|
||||
public Vector3 position; // 路径点的位置
|
||||
public Vector3 rotation; // 路径点的旋转角度(欧拉角)
|
||||
}
|
||||
public GameObject image;
|
||||
public PathPoint[] pathPoints; // 路径点数组
|
||||
public float moveDuration = 1f; // 每次移动的持续时间
|
||||
public int currentPathIndex = 0; // 当前路径点的索引
|
||||
public GameObject daiji;
|
||||
public GameObject shuaigan;
|
||||
public GameObject shougan;
|
||||
public bool type=false;
|
||||
private void Start()
|
||||
{
|
||||
image.gameObject.SetActive(false);
|
||||
}
|
||||
public void changetype()
|
||||
{
|
||||
while(type)
|
||||
{
|
||||
To1();
|
||||
}
|
||||
}
|
||||
public async void 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);
|
||||
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);
|
||||
await Task.Delay((int)time1);
|
||||
Del1();
|
||||
}
|
||||
public void Del1()
|
||||
{
|
||||
image.gameObject.SetActive(false);
|
||||
shuaigan.gameObject.SetActive(false);
|
||||
daiji.gameObject.SetActive(false) ;
|
||||
shougan.gameObject .SetActive(false) ;
|
||||
currentPathIndex = 0;
|
||||
}
|
||||
public async void 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);
|
||||
|
||||
|
||||
}
|
||||
private IEnumerator MoveAlongPath()
|
||||
{
|
||||
// 持续沿着路径点移动
|
||||
while (currentPathIndex < pathPoints.Length)
|
||||
{
|
||||
PathPoint currentPoint = pathPoints[currentPathIndex];
|
||||
|
||||
// 移动到当前路径点的位置,并旋转到对应的角度
|
||||
yield return image.transform.DOLocalMove(currentPoint.position, moveDuration)
|
||||
.OnStart(() => image.transform.DOLocalRotate(currentPoint.rotation, moveDuration))
|
||||
.WaitForCompletion(); // 等待移动和旋转完成
|
||||
|
||||
// 移动到下一个路径点
|
||||
currentPathIndex++;
|
||||
}
|
||||
image.gameObject.SetActive(false);
|
||||
shougan.gameObject.SetActive(false);
|
||||
|
||||
}
|
||||
public void change()
|
||||
{
|
||||
StartCoroutine(MoveAlongPath());
|
||||
currentPathIndex = 0;
|
||||
image.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7915ad4d1e5d5ec4aabe8badad5812b6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -30,19 +30,52 @@ public class WebFishingPK : MonoBehaviour
|
||||
/// </summary>
|
||||
public Text lefttext;
|
||||
public Text righttext;
|
||||
public Button TouruBtn;
|
||||
public Button selleftbtn;
|
||||
public Button selrightbtn;
|
||||
public Dropdown Dropdown;
|
||||
int pos = 0;
|
||||
private UnityEngine.Color normalColor = UnityEngine.Color.white; // 默认颜色
|
||||
private UnityEngine.Color selectedColor = UnityEngine.Color.blue; // 选中时的颜色
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 钓鱼
|
||||
/// </summary>
|
||||
///
|
||||
public PhotoMovement photoMovement;
|
||||
private async void Start()
|
||||
{
|
||||
TimeText.gameObject.SetActive(false);
|
||||
Debug.Log(PlayerPrefs.GetString("UserToken"));
|
||||
AuthorizationValue = PlayerPrefs.GetString("UserToken");
|
||||
await ConnectWebSocket();
|
||||
selleftbtn.onClick.AddListener(() =>
|
||||
{
|
||||
pos = 1;
|
||||
ChangeButtonColor(selleftbtn, selectedColor);
|
||||
ChangeButtonColor(selrightbtn, normalColor); // 恢复右侧按钮颜色
|
||||
});
|
||||
|
||||
|
||||
// 为右侧按钮添加点击监听器
|
||||
selrightbtn.onClick.AddListener(() =>
|
||||
{
|
||||
pos = 2;
|
||||
ChangeButtonColor(selrightbtn, selectedColor);
|
||||
ChangeButtonColor(selleftbtn, normalColor); // 恢复左侧按钮颜色
|
||||
});
|
||||
// 调用发送方法
|
||||
await SendJsonMessage("{ \"code\": \"FISHING_PK\", \"content\": \"{\\\"action\\\":\\\"INFO\\\"}\" }");
|
||||
//await SendJsonMessage(30, 1);
|
||||
}
|
||||
TouruBtn.onClick.AddListener(async() =>
|
||||
{
|
||||
await SendJsonMessage(int.Parse(Dropdown.options[Dropdown.value].text), pos);
|
||||
});
|
||||
|
||||
}
|
||||
private void ChangeButtonColor(Button btn, UnityEngine.Color color)
|
||||
{
|
||||
btn.gameObject.GetComponent<Image>().color = color;
|
||||
}
|
||||
private async Task ConnectWebSocket()
|
||||
{
|
||||
_webSocket = new ClientWebSocket();
|
||||
@ -86,7 +119,7 @@ public class WebFishingPK : MonoBehaviour
|
||||
Debug.Log($"接收到消息:{message}");
|
||||
|
||||
var baseResponse = JsonConvert.DeserializeObject<BaseResponse>(message);
|
||||
Promptmgr.Instance.PromptBubble(baseResponse.message);
|
||||
//Promptmgr.Instance.PromptBubble(baseResponse.message);
|
||||
if (baseResponse != null)
|
||||
{
|
||||
switch (baseResponse.code)
|
||||
@ -105,6 +138,17 @@ public class WebFishingPK : MonoBehaviour
|
||||
TimeText.gameObject.SetActive(true);
|
||||
remainingTime = (float)fishResponse.data.countdown;
|
||||
Debug.Log(fishResponse.data.countdown_type);
|
||||
if(fishResponse.data.countdown_type==0)
|
||||
{
|
||||
photoMovement.Del1();
|
||||
photoMovement.To1();
|
||||
}
|
||||
else
|
||||
{
|
||||
photoMovement.Del1();
|
||||
photoMovement.To2();
|
||||
|
||||
}
|
||||
Debug.Log(fishResponse.data.amount_left);
|
||||
lefttext.text= fishResponse.data.amount_left.ToString();
|
||||
Debug.Log(fishResponse.data.amount_right);
|
||||
@ -139,10 +183,19 @@ public class WebFishingPK : MonoBehaviour
|
||||
Debug.Log(fishResponse2.data.countdown);
|
||||
remainingTime = (float)fishResponse2.data.countdown;
|
||||
Debug.Log(fishResponse2.data.countdown_type);
|
||||
if (fishResponse2.data.countdown_type == 0)
|
||||
{
|
||||
photoMovement.Del1();
|
||||
photoMovement.To1();
|
||||
}
|
||||
else
|
||||
{
|
||||
photoMovement.Del1();
|
||||
photoMovement.To2();
|
||||
}
|
||||
Debug.Log(fishResponse2.data.amount_left);
|
||||
Debug.Log(fishResponse2.data.amount_right);
|
||||
lefttext.text = fishResponse2.data.amount_left.ToString();
|
||||
|
||||
righttext.text = fishResponse2.data.amount_right.ToString();
|
||||
}
|
||||
else
|
||||
|
@ -6,6 +6,8 @@ public class shougou : MonoBehaviour
|
||||
{
|
||||
public SpriteAniation SpriteAniation;
|
||||
public GameObject daiji;
|
||||
public int count;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
@ -15,10 +17,11 @@ public class shougou : MonoBehaviour
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if(SpriteAniation.index>=24)
|
||||
if(SpriteAniation.index>= count)
|
||||
{
|
||||
this.gameObject.SetActive(false);
|
||||
daiji.gameObject.SetActive(true);
|
||||
daiji.GetComponentInParent<PhotoMovement>().change();
|
||||
SpriteAniation.index = 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user