94 lines
2.4 KiB
C#
94 lines
2.4 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using DragonLi.Core;
|
|
using UnityEngine;
|
|
|
|
public class BubblesGemTask : Task
|
|
{
|
|
public override void Init()
|
|
{
|
|
base.Init();
|
|
}
|
|
|
|
public override void StartTask()
|
|
{
|
|
base.StartTask();
|
|
winTaskTime = Random.Range(60, 89);
|
|
endTaskTime = 90;
|
|
GameManager.Ins.playerRightHand._isOpenLine = false;
|
|
}
|
|
|
|
public override void EndTask()
|
|
{
|
|
base.EndTask();
|
|
GameManager.Ins.playerRightHand._isOpenLine = true;
|
|
if (GameManager.Ins.taskManager.isGetGem)
|
|
{
|
|
if (curGems.Count > 0)
|
|
{
|
|
MonoSingleton<CoroutineTaskManager>.Instance.WaitSecondTodo(() =>
|
|
{
|
|
if(GameManager.Ins.enemy.playerPre.gameObject.activeSelf)
|
|
return;
|
|
foreach (var item in curGems)
|
|
{
|
|
if (item != null)
|
|
{
|
|
Destroy(item);
|
|
}
|
|
}
|
|
curGems.Clear();
|
|
GameManager.Ins.enemy.Show();
|
|
GameManager.Ins.enemy.SetState(2);
|
|
}, 3f);
|
|
}
|
|
return;
|
|
}
|
|
foreach (var item in curGems)
|
|
{
|
|
if (item != null)
|
|
{
|
|
var bg = item.GetComponent<BubblesGem>();
|
|
|
|
// ✅ 打断 ShowGem 协程,避免冲突
|
|
bg.StopAllCoroutines();
|
|
|
|
// 强制拿到真实宝石
|
|
bg.gemType = SeekGemType.Real;
|
|
bg.GetGem(3);
|
|
|
|
// 标记已经拿到
|
|
GameManager.Ins.taskManager.isGetGem = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void CompleteTask()
|
|
{
|
|
base.CompleteTask();
|
|
MonoSingleton<CoroutineTaskManager>.Instance.WaitSecondTodo(() =>
|
|
{
|
|
if(curGems.Count<=0|| GameManager.Ins.enemy.playerPre.gameObject.activeSelf)
|
|
return;
|
|
foreach (var item in curGems)
|
|
{
|
|
if (item != null)
|
|
{
|
|
Destroy(item);
|
|
}
|
|
}
|
|
curGems.Clear();
|
|
GameManager.Ins.enemy.Show();
|
|
GameManager.Ins.enemy.SetState(2);
|
|
}, 3f);
|
|
|
|
}
|
|
|
|
public override void Update()
|
|
{
|
|
base.Update();
|
|
}
|
|
|
|
}
|