2024-11-16 01:53:21 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
2024-12-18 23:15:00 +08:00
|
|
|
|
using System.Threading.Tasks;
|
2024-11-16 01:53:21 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
using DG.Tweening;
|
|
|
|
|
public class BaoshiRoomcontroller : MonoBehaviour
|
|
|
|
|
{
|
2024-12-18 23:15:00 +08:00
|
|
|
|
[Header("<22><><EFBFBD><EFBFBD>id")]
|
|
|
|
|
public int RoomId;
|
2024-11-18 15:46:45 +08:00
|
|
|
|
|
2024-11-16 01:53:21 +08:00
|
|
|
|
[Header("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD>")]
|
|
|
|
|
public GameObject fishManPrefab;
|
|
|
|
|
[Header("<22><><EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD><C4BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")]
|
|
|
|
|
public List<VoucherItem> listItem = new List<VoucherItem>();
|
|
|
|
|
private GameObject fishMan;//<2F><><EFBFBD>ɵ<EFBFBD><C9B5>洬
|
2024-11-18 15:46:45 +08:00
|
|
|
|
private minerControl fishManShipContorl;//<2F>洬<EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD>
|
2024-11-16 01:53:21 +08:00
|
|
|
|
|
|
|
|
|
[Header("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD>")]
|
|
|
|
|
public Transform startPos;
|
|
|
|
|
[Header("<22><><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD>")]
|
|
|
|
|
public Transform endPos;
|
|
|
|
|
|
|
|
|
|
[Header("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD>")]
|
|
|
|
|
public int type;
|
|
|
|
|
|
|
|
|
|
public float ActivateValue = 0;
|
|
|
|
|
public int Num = 0;
|
|
|
|
|
public int Type = 0;
|
|
|
|
|
|
|
|
|
|
[Header("<22><><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD>㼯<EFBFBD><E3BCAF>")]
|
|
|
|
|
public List<Path> paths;
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|
|
|
|
[Header("<22><>·ʱ<C2B7><CAB1>")]
|
|
|
|
|
public float pathsNeedTimer = 30f;
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|
|
|
|
[Header("<22>ڿ<EFBFBD>ʱ<EFBFBD><CAB1>")]
|
|
|
|
|
public float fishingNeedTimer = 30f;
|
|
|
|
|
//<2F><>Ϣʱ<CFA2><CAB1>
|
|
|
|
|
[Header("<22><>Ϣʱ<CFA2><CAB1>")]
|
|
|
|
|
public float restTimer = 5f;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Header("<22><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")]
|
|
|
|
|
public Text shipNumberTextPro;
|
2024-12-20 15:56:43 +08:00
|
|
|
|
public int shipNumber;
|
|
|
|
|
public int MaxShipNumber=10;
|
2024-11-16 01:53:21 +08:00
|
|
|
|
|
2024-12-20 15:56:43 +08:00
|
|
|
|
public int ShipNumber
|
|
|
|
|
{
|
|
|
|
|
get=> shipNumber;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
shipNumber=value;
|
|
|
|
|
shipNumberTextPro.text = shipNumber.ToString()+"/"+MaxShipNumber.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-11-16 01:53:21 +08:00
|
|
|
|
|
|
|
|
|
[Header("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч")]
|
|
|
|
|
public GameObject effectPrefab;//<2F><>Ч
|
|
|
|
|
|
|
|
|
|
[Header("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť<EFBFBD><C5A5><EFBFBD>ֵĶ<D6B5><C4B6><EFBFBD>")]
|
|
|
|
|
public Transform OnBtnAni;
|
|
|
|
|
|
|
|
|
|
public float FishPrice;
|
|
|
|
|
|
|
|
|
|
public GameObject map;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static bool canClick = true;
|
|
|
|
|
|
|
|
|
|
public List<string> ids = new List<string>();
|
|
|
|
|
|
2024-12-20 15:56:43 +08:00
|
|
|
|
|
2024-11-16 01:53:21 +08:00
|
|
|
|
|
|
|
|
|
public GameObject musk;
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
listItem = new List<VoucherItem>();
|
2024-12-20 15:56:43 +08:00
|
|
|
|
// UpdateShipNumberTextPro(listItem.Count.ToString());
|
2024-11-16 01:53:21 +08:00
|
|
|
|
}
|
|
|
|
|
private void Start()
|
|
|
|
|
{
|
|
|
|
|
FishPrice = 10;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async void addman(int type, int number)
|
|
|
|
|
{
|
|
|
|
|
if (type == this.type)
|
|
|
|
|
{
|
|
|
|
|
GenerateForFisherElf generateForFisherElf = new GenerateForFisherElf(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
generateForFisherElf.Num = Num;
|
|
|
|
|
generateForFisherElf.Count = 1;
|
|
|
|
|
string userponse = await web.SendRequest(web.URL + "/Voucher/GenerateForFisherElf", "POST", JsonUtility.ToJson(generateForFisherElf));
|
|
|
|
|
ids itemList = JsonUtility.FromJson<ids>(userponse);
|
|
|
|
|
Debug.Log(itemList.Ids[0]);
|
|
|
|
|
if (itemList.ErrorCode == 0) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
Promptmgr.Instance.PromptBubble("<22><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>", Color.black, Color.blue);
|
|
|
|
|
|
|
|
|
|
/* foreach (string item in itemList.Ids)
|
|
|
|
|
{
|
|
|
|
|
Use use = new Use(); // ʹ<><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
use.Id = item;
|
|
|
|
|
string rect = await web.SendRequest(web.URL + "/Voucher/Use", "POST", JsonUtility.ToJson(use));
|
|
|
|
|
Res res = JsonUtility.FromJson<ids>(userponse);
|
|
|
|
|
if (res.ErrorCode == 0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Promptmgr.Instance.PromptBubble("<22><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>", Color.black, Color.blue);
|
|
|
|
|
//<2F><><EFBFBD>Ӵ<EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD>
|
|
|
|
|
//ChangeShipNumber(1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Promptmgr.Instance.PromptBubble(res.ErrorMessage, Color.black, Color.red);
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
|
|
|
|
|
{
|
|
|
|
|
Res res = JsonUtility.FromJson<ids>(userponse);
|
|
|
|
|
Promptmgr.Instance.PromptBubble(res.ErrorMessage, Color.black, Color.red);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-18 23:15:00 +08:00
|
|
|
|
public async void OnClick()
|
2024-11-16 01:53:21 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (!canClick)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-18 23:15:00 +08:00
|
|
|
|
if (await ActivationRoom())
|
|
|
|
|
{
|
|
|
|
|
add_fish();
|
|
|
|
|
}
|
2024-11-16 01:53:21 +08:00
|
|
|
|
}
|
2024-12-18 23:15:00 +08:00
|
|
|
|
|
2024-11-16 01:53:21 +08:00
|
|
|
|
public void add_fish(string timerStr = null)//<2F><><EFBFBD>ɴ<EFBFBD>ֻ
|
|
|
|
|
{
|
2024-12-18 23:15:00 +08:00
|
|
|
|
//ActivationRoom()
|
2024-11-16 01:53:21 +08:00
|
|
|
|
|
|
|
|
|
if (timerStr != null)
|
|
|
|
|
{
|
2024-12-20 11:33:06 +08:00
|
|
|
|
musk.gameObject.SetActive(false);
|
2024-11-16 01:53:21 +08:00
|
|
|
|
fishMan = GameObject.Instantiate(fishManPrefab, this.transform);
|
|
|
|
|
fishMan.transform.position = endPos.position;
|
2024-11-18 15:46:45 +08:00
|
|
|
|
fishManShipContorl = fishMan.GetComponent<minerControl>();
|
|
|
|
|
fishManShipContorl.init(this.paths, this.pathsNeedTimer, this.fishingNeedTimer, this.restTimer, this.startPos, this.endPos);
|
2024-11-16 01:53:21 +08:00
|
|
|
|
|
|
|
|
|
Debug.Log("<22><><EFBFBD>´<EFBFBD>ʱ<EFBFBD><CAB1>");
|
|
|
|
|
|
|
|
|
|
//dig();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
musk.gameObject.SetActive(false);
|
2024-12-20 15:56:43 +08:00
|
|
|
|
//number++;
|
|
|
|
|
//UpdateShipNumberTextPro(number + "/10");
|
2024-11-16 01:53:21 +08:00
|
|
|
|
fishMan = GameObject.Instantiate(fishManPrefab, this.transform);
|
|
|
|
|
fishMan.transform.position = startPos.position;
|
2024-11-18 15:46:45 +08:00
|
|
|
|
fishManShipContorl = fishMan.GetComponent<minerControl>();
|
|
|
|
|
fishManShipContorl.init(this.paths, this.pathsNeedTimer, this.fishingNeedTimer, this.restTimer, this.startPos, this.endPos);
|
2024-11-16 01:53:21 +08:00
|
|
|
|
}
|
|
|
|
|
//ʹ<>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
async void UseShip()
|
|
|
|
|
{
|
|
|
|
|
Use use = new Use(); // ʹ<><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
use.Id = listItem[0].Id;
|
|
|
|
|
string rect = await web.SendRequest(web.URL + "/Voucher/Use", "POST", JsonUtility.ToJson(use));
|
|
|
|
|
Res res = JsonUtility.FromJson<ids>(rect);
|
|
|
|
|
if (res.ErrorCode == 0)
|
|
|
|
|
{
|
|
|
|
|
Promptmgr.Instance.PromptBubble("ʹ<>óɹ<C3B3>", Color.black, Color.blue);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Promptmgr.Instance.PromptBubble(res.ErrorMessage, Color.black, Color.red);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-12-18 23:15:00 +08:00
|
|
|
|
public async Task<bool> ActivationRoom()
|
|
|
|
|
{
|
|
|
|
|
return await miner_jiekou.instance.MiningActivate(this.RoomId);
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-16 01:53:21 +08:00
|
|
|
|
}
|