金币岛完成90%,需要调整一下动画时间
This commit is contained in:
parent
c398da97f4
commit
99ff9cdfe1
File diff suppressed because it is too large
Load Diff
@ -89,4 +89,4 @@ public class JinBiDao_buy : mount
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -53,8 +53,10 @@ public class jishadao_buy :mount
|
||||
{
|
||||
if (!Generate1 && (PlayerManager.Instance.Coins - 200) > 0)
|
||||
{
|
||||
lands[0].GetComponent<jishadao_contorl>().OnClick();
|
||||
|
||||
lands[0].GetComponent<jishadao_contorl>().add_fish();
|
||||
PlayerManager.Instance.SetMoney(MoneyType.Coins, -200);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,8 +67,10 @@ public class jishadao_buy :mount
|
||||
{
|
||||
if (!Generate1 && (PlayerManager.Instance.Coins - 400) > 0)
|
||||
{
|
||||
lands[1].GetComponent<jishadao_contorl>().OnClick();
|
||||
|
||||
lands[1].GetComponent<jishadao_contorl>().add_fish();
|
||||
PlayerManager.Instance.SetMoney(MoneyType.Coins, -400);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,8 +81,9 @@ public class jishadao_buy :mount
|
||||
{
|
||||
if (!Generate1 && (PlayerManager.Instance.Coins - 600) > 0)
|
||||
{
|
||||
lands[2].GetComponent<jishadao_contorl>().OnClick();
|
||||
lands[2].GetComponent<jishadao_contorl>().add_fish();
|
||||
PlayerManager.Instance.SetMoney(MoneyType.Coins, -600);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ public class jishadao_contorl : MonoBehaviour
|
||||
[Header("购买的渔船数据")]
|
||||
public List<VoucherItem> listItem = new List<VoucherItem>();
|
||||
private GameObject fishMan;//生成的渔船
|
||||
private shipcontorl fishManShipContorl;//渔船的控制器
|
||||
private SpriteAniationpro fishManShipContorl;//渔船的控制器
|
||||
|
||||
[Header("渔船生成点")]
|
||||
public Transform startPos;
|
||||
@ -22,8 +22,6 @@ public class jishadao_contorl : MonoBehaviour
|
||||
[Header("岛屿类型编号")]
|
||||
public int type;
|
||||
|
||||
|
||||
|
||||
public float ActivateValue = 0;
|
||||
public int Num = 0;
|
||||
public int Type = 0;
|
||||
@ -75,7 +73,7 @@ public class jishadao_contorl : MonoBehaviour
|
||||
|
||||
HightLight.SetActive(false);
|
||||
|
||||
shopman.instance.OnType += addman;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -84,11 +82,8 @@ public class jishadao_contorl : MonoBehaviour
|
||||
goldNumerTextPro.text = ActivateValue.ToString();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
// if (!isGoldLand) return;
|
||||
shopman.instance.OnType -= addman;
|
||||
}
|
||||
|
||||
|
||||
|
||||
async void addman(int type, int number)
|
||||
{
|
||||
@ -134,33 +129,24 @@ public class jishadao_contorl : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void OnTouch()
|
||||
{
|
||||
//OnClick();
|
||||
}
|
||||
|
||||
public void OnClick()
|
||||
{
|
||||
{
|
||||
|
||||
Debug.Log("进入生成点击事件");
|
||||
if (!canClick)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ScaleAni(OnBtnAni);
|
||||
|
||||
|
||||
if (fishMan != null)
|
||||
if (fishMan == null)
|
||||
{
|
||||
Promptmgr.Instance.PromptBubble("已经有船了", Color.black, Color.red);
|
||||
|
||||
Promptmgr.Instance.PromptBubble("还没有买船了", Color.black, Color.red);
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.Log("进入买船");
|
||||
|
||||
|
||||
ScaleAni(OnBtnAni);
|
||||
add_fish();
|
||||
|
||||
}
|
||||
@ -169,39 +155,38 @@ public class jishadao_contorl : MonoBehaviour
|
||||
|
||||
if (fishMan != null)
|
||||
{
|
||||
fishManShipContorl.UpShowTimer(timerStr);
|
||||
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<shipcontorl>();
|
||||
fishManShipContorl = fishMan.GetComponent<SpriteAniationpro>();
|
||||
|
||||
fishManShipContorl.UpShowTimer(timerStr);
|
||||
StartCoroutine(Fishing());
|
||||
Debug.Log("更新船时间");
|
||||
|
||||
fish();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// UseShip();
|
||||
|
||||
|
||||
fishMan = GameObject.Instantiate(fishManPrefab, this.transform);
|
||||
fishMan.transform.position = startPos.position;
|
||||
fishManShipContorl = fishMan.GetComponent<shipcontorl>();
|
||||
fishManShipContorl = fishMan.GetComponent<SpriteAniationpro>();
|
||||
|
||||
|
||||
MoveToFishingPos();
|
||||
}
|
||||
void MoveToFishingPos()
|
||||
{
|
||||
void MoveToFishingPos() {
|
||||
|
||||
// 随机选择一条路径
|
||||
Path selectedPath = paths[Random.Range(0, paths.Count)];
|
||||
// 移动到捕鱼点
|
||||
StartCoroutine(MoveToFishingPoint(fishMan, selectedPath.pathPoints));
|
||||
StartCoroutine(MoveToFishingPoint(selectedPath.pathPoints));
|
||||
}
|
||||
|
||||
public void ScaleAni(Transform transform)
|
||||
@ -216,7 +201,7 @@ public class jishadao_contorl : MonoBehaviour
|
||||
|
||||
}
|
||||
|
||||
IEnumerator MoveToFishingPoint(GameObject man, List<Transform> path)
|
||||
IEnumerator MoveToFishingPoint(List<Transform> path)
|
||||
{
|
||||
// 将路径点转换为 Vector3 数组
|
||||
Vector3[] pathPoints = new Vector3[path.Count];
|
||||
@ -225,19 +210,20 @@ public class jishadao_contorl : MonoBehaviour
|
||||
pathPoints[i] = path[i].position;
|
||||
}
|
||||
|
||||
|
||||
//改变朝向
|
||||
ChangeShipLook(pathPoints[0], pathPoints[path.Count - 1]);
|
||||
|
||||
// 创建一个摆动效果的 Tween
|
||||
//注意 ,摆动动的是船,移动移动是根节点
|
||||
var swayTween = fishManShipContorl.Man.transform.DOLocalRotate(new Vector3(0, 0, 10), 1f, RotateMode.LocalAxisAdd) // 每次摆动角度
|
||||
var swayTween = fishMan.transform.DOLocalRotate(new Vector3(0, 0, 10), 1f, RotateMode.LocalAxisAdd) // 每次摆动角度
|
||||
.SetEase(Ease.InOutSine)
|
||||
.SetLoops(-1, LoopType.Yoyo); // 无限往复
|
||||
.SetLoops(-1, LoopType.Yoyo); //无限往复
|
||||
|
||||
man.GetComponent<shipcontorl>().SetState(ShipState.move);
|
||||
//动作变化,移动
|
||||
fishManShipContorl.SetAni(1);
|
||||
|
||||
// 使用 DOPath 沿着路径移动到捕鱼点,并禁用旋转变化
|
||||
yield return man.transform.DOPath(pathPoints, pathsNeedTimer, PathType.CatmullRom)
|
||||
yield return fishMan.transform.DOPath(pathPoints, pathsNeedTimer, PathType.CatmullRom)
|
||||
.SetOptions(false) // 禁用旋转
|
||||
.SetEase(Ease.InOutSine)
|
||||
.WaitForCompletion();
|
||||
@ -245,110 +231,45 @@ public class jishadao_contorl : MonoBehaviour
|
||||
// 停止摆动效果
|
||||
swayTween.Kill();
|
||||
|
||||
StartCoroutine(Fishing());
|
||||
|
||||
fish();
|
||||
}
|
||||
|
||||
IEnumerator Fishing()
|
||||
void fish()
|
||||
{
|
||||
// 创建一个摆动效果的 Tween
|
||||
//注意 ,摆动动的是船,移动移动是根节点
|
||||
var swayTween = fishManShipContorl.Man.transform.DOLocalRotate(new Vector3(0, 0, 10), 1f, RotateMode.LocalAxisAdd) // 每次摆动角度
|
||||
.SetEase(Ease.InOutSine)
|
||||
.SetLoops(-1, LoopType.Yoyo); // 无限往复
|
||||
|
||||
|
||||
fishMan.GetComponent<shipcontorl>().SetState(ShipState.shipthrow);
|
||||
|
||||
|
||||
|
||||
yield return new WaitForSeconds(1f);
|
||||
fishMan.GetComponent<shipcontorl>().SetState(ShipState.stand);
|
||||
// 等待捕鱼指定时间
|
||||
yield return new WaitForSeconds(fishingNeedTimer - 1f);
|
||||
|
||||
|
||||
// 停止摆动效果
|
||||
// swayTween.Kill();
|
||||
// 返回起点
|
||||
//MoveToStartPos();
|
||||
//动作变化,捕鱼
|
||||
fishManShipContorl.SetAni(2);
|
||||
InvokeRepeating("stateChange", 1f, 1f);
|
||||
}
|
||||
|
||||
|
||||
void MoveToStartPos()
|
||||
|
||||
void stateChange()
|
||||
{
|
||||
float i= Random.Range(0,1f);
|
||||
|
||||
|
||||
// 随机选择一条路径
|
||||
Path selectedPath = paths[Random.Range(0, paths.Count)];
|
||||
// 移动到点
|
||||
StartCoroutine(MoveToStartPos(fishMan, selectedPath.pathPoints));
|
||||
}
|
||||
|
||||
|
||||
|
||||
IEnumerator MoveToStartPos(GameObject man, List<Transform> path)
|
||||
{
|
||||
|
||||
// 创建路径点数组,长度为路径点数量 + 1
|
||||
Vector3[] pathPoints = new Vector3[path.Count + 1];
|
||||
|
||||
// 设置最后一个点为起始位置
|
||||
pathPoints[path.Count] = startPos.position;
|
||||
|
||||
// 反向赋值路径点
|
||||
for (int i = 0; i < path.Count; i++)
|
||||
if (i < 0.4f)
|
||||
{
|
||||
pathPoints[i] = path[path.Count - 1 - i].position; // 从最后一个点开始赋值
|
||||
//动作变化,捕鱼
|
||||
fishManShipContorl.SetAni(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
//动作变化,摸鱼
|
||||
fishManShipContorl.SetAni(3);
|
||||
}
|
||||
|
||||
|
||||
ChangeShipLook(pathPoints[0], pathPoints[path.Count]);
|
||||
|
||||
// 创建一个摆动效果的 Tween
|
||||
//注意 ,摆动动的是船,移动移动是根节点
|
||||
var swayTween = fishManShipContorl.Man.transform.DOLocalRotate(new Vector3(0, 0, 10), 1f, RotateMode.LocalAxisAdd) // 每次摆动角度
|
||||
.SetEase(Ease.InOutSine)
|
||||
.SetLoops(-1, LoopType.Yoyo); // 无限往复
|
||||
|
||||
|
||||
|
||||
|
||||
man.GetComponent<shipcontorl>().SetState(ShipState.move);
|
||||
|
||||
// 使用 DOPath 沿着路径移动到捕鱼点,并禁用旋转变化
|
||||
yield return man.transform.DOPath(pathPoints, pathsNeedTimer, PathType.CatmullRom)
|
||||
.SetOptions(false) // 禁用旋转
|
||||
.SetEase(Ease.InOutSine)
|
||||
.WaitForCompletion();
|
||||
|
||||
//加钱
|
||||
//AddGold();
|
||||
|
||||
// 等待捕鱼指定时间
|
||||
yield return new WaitForSeconds(restTimer);
|
||||
|
||||
|
||||
|
||||
// 停止摆动效果
|
||||
swayTween.Kill();
|
||||
|
||||
//循环
|
||||
MoveToFishingPos();
|
||||
}
|
||||
|
||||
|
||||
//根据前后位置改变朝向
|
||||
void ChangeShipLook(Vector3 startpos, Vector3 endpos)
|
||||
{
|
||||
if (startpos.x > endpos.x)
|
||||
{
|
||||
Debug.Log("朝向右边");
|
||||
fishMan.GetComponent<shipcontorl>().ChangeLookat(0f); // 朝向右边
|
||||
Debug.Log("朝向右边");
|
||||
fishMan.transform.Rotate(new Vector3(0,0,0));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("朝向右边");
|
||||
fishMan.GetComponent<shipcontorl>().ChangeLookat(180f); // 朝向左边
|
||||
Debug.Log("朝向右边");
|
||||
fishMan.transform.Rotate(new Vector3(0, 180, 0));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user