宝石岛更新了一点点
This commit is contained in:
parent
5ab04bf75b
commit
f0cc3ac44a
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25abcfbeee1dda44a81962ec1431e216
|
||||
guid: 19d0800f014f1bd498d2f2e97288a8a1
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 32268af376f99ab4eb44703a9ab837bf
|
||||
guid: 484f51087bee54448b381384ccf5820d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
18
meng_yao/Assets/script/scene_baoshidao/baoshidao_buy.cs
Normal file
18
meng_yao/Assets/script/scene_baoshidao/baoshidao_buy.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class baoshidao_buy : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
11
meng_yao/Assets/script/scene_baoshidao/baoshidao_buy.cs.meta
Normal file
11
meng_yao/Assets/script/scene_baoshidao/baoshidao_buy.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5de5e293e3f15bf46a11cc3e5081f0d2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
307
meng_yao/Assets/script/scene_baoshidao/baoshidao_contorl.cs
Normal file
307
meng_yao/Assets/script/scene_baoshidao/baoshidao_contorl.cs
Normal file
@ -0,0 +1,307 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using DG.Tweening;
|
||||
using TMPro;
|
||||
|
||||
public class baoshidao_contorl : MonoBehaviour
|
||||
{
|
||||
[Header("渔船的预制体")]
|
||||
public GameObject fishManPrefab;
|
||||
[Header("购买的渔船数据")]
|
||||
public List<VoucherItem> listItem = new List<VoucherItem>();
|
||||
private GameObject fishMan;//生成的渔船
|
||||
private SpriteAniationpro fishManShipContorl;//渔船的控制器
|
||||
|
||||
[Header("渔船生成点")]
|
||||
public Transform startPos;
|
||||
[Header("渔船终点")]
|
||||
public Transform endPos;
|
||||
|
||||
[Header("岛屿类型编号")]
|
||||
public int type;
|
||||
|
||||
public float ActivateValue = 0;
|
||||
public int Num = 0;
|
||||
public int Type = 0;
|
||||
|
||||
[Header("渔船航行路径点集合")]
|
||||
public List<Path> paths;
|
||||
//航行时间
|
||||
[Header("航行时间")]
|
||||
public float pathsNeedTimer = 30f;
|
||||
//捕鱼时间
|
||||
[Header("捕鱼时间")]
|
||||
public float fishingNeedTimer = 30f;
|
||||
//休息时间
|
||||
[Header("休息时间")]
|
||||
public float restTimer = 5f;
|
||||
|
||||
|
||||
[Header("显示金币数量")]
|
||||
public Text goldNumerTextPro;
|
||||
[Header("显示船只数量")]
|
||||
public Text shipNumberTextPro;
|
||||
|
||||
|
||||
[Header("点击的高亮图层")]
|
||||
public GameObject HightLight;//高亮图层
|
||||
|
||||
[Header("点击按钮出现的动画")]
|
||||
public Transform OnBtnAni;
|
||||
|
||||
public float FishPrice;
|
||||
|
||||
public GameObject map;
|
||||
|
||||
|
||||
public static bool canClick = true;
|
||||
|
||||
public List<string> ids = new List<string>();
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Awake()
|
||||
{
|
||||
listItem = new List<VoucherItem>();
|
||||
UpdateShipNumberTextPro(listItem.Count.ToString());
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
FishPrice = 10;
|
||||
|
||||
|
||||
HightLight.SetActive(false);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
goldNumerTextPro.text = ActivateValue.ToString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
async void addman(int type, int number)
|
||||
{
|
||||
if (type == this.type)
|
||||
{
|
||||
GenerateForFisherElf generateForFisherElf = new GenerateForFisherElf(); // 购买渔夫
|
||||
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) // 如果购买成功
|
||||
{
|
||||
Promptmgr.Instance.PromptBubble("购买成功", Color.black, Color.blue);
|
||||
|
||||
/* foreach (string item in itemList.Ids)
|
||||
{
|
||||
Use use = new Use(); // 使用渔夫
|
||||
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("购买成功", Color.black, Color.blue);
|
||||
//增加船只数量
|
||||
//ChangeShipNumber(1);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Promptmgr.Instance.PromptBubble(res.ErrorMessage, Color.black, Color.red);
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
else// 如果购买失败
|
||||
{
|
||||
Res res = JsonUtility.FromJson<ids>(userponse);
|
||||
Promptmgr.Instance.PromptBubble(res.ErrorMessage, Color.black, Color.red);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnClick()
|
||||
{
|
||||
|
||||
if (!canClick)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ScaleAni(OnBtnAni);
|
||||
|
||||
|
||||
/*if (fishMan == null)
|
||||
{
|
||||
Promptmgr.Instance.PromptBubble("还没有买船了", Color.black, Color.red);
|
||||
return;
|
||||
}*/
|
||||
|
||||
add_fish();
|
||||
|
||||
}
|
||||
public void add_fish(string timerStr = null)//生成船只
|
||||
{
|
||||
|
||||
if (fishMan != null)
|
||||
{
|
||||
Promptmgr.Instance.PromptBubble("已经有船了", Color.black, Color.red);
|
||||
Debug.Log("更新船");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (timerStr != null)
|
||||
{
|
||||
fishMan = GameObject.Instantiate(fishManPrefab, this.transform);
|
||||
fishMan.transform.position = endPos.position;
|
||||
fishManShipContorl = fishMan.GetComponent<SpriteAniationpro>();
|
||||
|
||||
Debug.Log("更新船时间");
|
||||
|
||||
fish();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
fishMan = GameObject.Instantiate(fishManPrefab, this.transform);
|
||||
fishMan.transform.position = startPos.position;
|
||||
fishManShipContorl = fishMan.GetComponent<SpriteAniationpro>();
|
||||
|
||||
|
||||
MoveToFishingPos();
|
||||
}
|
||||
void MoveToFishingPos()
|
||||
{
|
||||
|
||||
// 随机选择一条路径
|
||||
Path selectedPath = paths[Random.Range(0, paths.Count)];
|
||||
// 移动到捕鱼点
|
||||
StartCoroutine(MoveToFishingPoint(selectedPath.pathPoints));
|
||||
}
|
||||
|
||||
public void ScaleAni(Transform transform)
|
||||
{
|
||||
HightLight.SetActive(true);
|
||||
transform.DOScale(1.1f, 0.2f)
|
||||
.SetEase(Ease.InOutSine)
|
||||
.OnComplete(() => {
|
||||
transform.DOScale(1f, 0.2f).SetEase(Ease.InOutSine);
|
||||
HightLight.SetActive(false);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
IEnumerator MoveToFishingPoint(List<Transform> path)
|
||||
{
|
||||
// 将路径点转换为 Vector3 数组
|
||||
Vector3[] pathPoints = new Vector3[path.Count];
|
||||
for (int i = 0; i < path.Count; i++)
|
||||
{
|
||||
pathPoints[i] = path[i].position;
|
||||
}
|
||||
|
||||
//改变朝向
|
||||
ChangeShipLook(pathPoints[0], pathPoints[path.Count - 1]);
|
||||
|
||||
// 创建一个摆动效果的 Tween
|
||||
//注意 ,摆动动的是船,移动移动是根节点
|
||||
var swayTween = fishMan.transform.DOLocalRotate(new Vector3(0, 0, 10), 1f, RotateMode.LocalAxisAdd) // 每次摆动角度
|
||||
.SetEase(Ease.InOutSine)
|
||||
.SetLoops(-1, LoopType.Yoyo); //无限往复
|
||||
|
||||
//动作变化,移动
|
||||
fishManShipContorl.SetAni(1);
|
||||
|
||||
// 使用 DOPath 沿着路径移动到捕鱼点,并禁用旋转变化
|
||||
yield return fishMan.transform.DOPath(pathPoints, pathsNeedTimer, PathType.CatmullRom)
|
||||
.SetOptions(false) // 禁用旋转
|
||||
.SetEase(Ease.InOutSine)
|
||||
.WaitForCompletion();
|
||||
|
||||
// 停止摆动效果
|
||||
swayTween.Kill();
|
||||
|
||||
fish();
|
||||
}
|
||||
|
||||
void fish()
|
||||
{
|
||||
//动作变化,捕鱼
|
||||
fishManShipContorl.SetAni(2);
|
||||
InvokeRepeating("stateChange", 1f, 1f);
|
||||
}
|
||||
|
||||
void stateChange()
|
||||
{
|
||||
float i = Random.Range(0, 1f);
|
||||
|
||||
if (i < 0.4f)
|
||||
{
|
||||
//动作变化,捕鱼
|
||||
fishManShipContorl.SetAni(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
//动作变化,摸鱼
|
||||
fishManShipContorl.SetAni(3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//根据前后位置改变朝向
|
||||
void ChangeShipLook(Vector3 startpos, Vector3 endpos)
|
||||
{
|
||||
if (startpos.x > endpos.x)
|
||||
{
|
||||
Debug.Log("朝向右边");
|
||||
fishMan.transform.Rotate(new Vector3(0, 0, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("朝向右边");
|
||||
fishMan.transform.Rotate(new Vector3(0, 180, 0));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//更新船只数量显示
|
||||
public void UpdateShipNumberTextPro(string str)
|
||||
{
|
||||
if (shipNumberTextPro.text == str)
|
||||
{
|
||||
return;
|
||||
}
|
||||
shipNumberTextPro.text = str;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//使用代金卷
|
||||
async void UseShip()
|
||||
{
|
||||
Use use = new Use(); // 使用渔夫
|
||||
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("使用成功", Color.black, Color.blue);
|
||||
}
|
||||
else
|
||||
{
|
||||
Promptmgr.Instance.PromptBubble(res.ErrorMessage, Color.black, Color.red);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e0115c4b9804b6f47bbd58bd358c5aeb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user