1
This commit is contained in:
@@ -116,6 +116,9 @@ public class MonsterContral : MonoBehaviour
|
||||
|
||||
public List<Transform> colliderList;
|
||||
|
||||
/// <summary>是否存活(活跃且未被回收)</summary>
|
||||
public bool IsAlive => gameObject.activeInHierarchy;
|
||||
|
||||
|
||||
|
||||
// ================================================================
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Assets.MyGame.Scripts.Net.APIResponses.Enum;
|
||||
using Assets.MyGame.Scripts.Net.APIResponses.Enum;
|
||||
using Assets.MyGame.Scripts.Net.WebResponses;
|
||||
using DG.Tweening;
|
||||
using System;
|
||||
@@ -13,271 +13,215 @@ using Random = UnityEngine.Random;
|
||||
|
||||
public class MonsterControl_BossBase : MonsterContral
|
||||
{
|
||||
|
||||
// ==================== 基础 ====================
|
||||
public string bossName;
|
||||
|
||||
// ==================== 爆奖 ====================
|
||||
[Header("爆奖")]
|
||||
public bool isToUI = true; // 爆奖特效是 UI(RectTransform)还是 3D 场景物体
|
||||
public LayeredPool layeredPool;
|
||||
public TextMeshProUGUI tMP_CurrBossScore;//boss分数
|
||||
public long currBossScoreValue=0;//boss分数
|
||||
public long bossScoreValue=0;//boss分数
|
||||
public int poolNum;//奖池
|
||||
public int prizeCount;//奖励数量
|
||||
public Action<int> JiaFen;
|
||||
public TextMeshProUGUI tMP_CurrBossScore; // Boss 分数显示文本
|
||||
public long currBossScoreValue; // 当前滚动分数
|
||||
public long bossScoreValue; // 累计总分
|
||||
public int poolNum; // 奖池金币
|
||||
public int prizeCount = 8; // 爆奖红包数量
|
||||
public Action<int> JiaFen; // 加分回调
|
||||
public List<List<RedPacketRecord>> redPacketRecords = new List<List<RedPacketRecord>>();
|
||||
public bool isToUI = true;
|
||||
public Camera ZhuCam;
|
||||
|
||||
// ==================== 死亡 ====================
|
||||
public bool isDieFish;
|
||||
public float dieTime = 3f;
|
||||
public Vector3 v3; // 分数飞出目标位置(Inspector 设置)
|
||||
private long _turretNum;
|
||||
private bool _isJia;
|
||||
|
||||
// ==================== Unity 生命周期 ====================
|
||||
|
||||
public override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
isRotate = false;
|
||||
ZhuCam = GameManager.Instance.ZhuCam;
|
||||
action_effect_DieAward = (obj) =>
|
||||
action_effect_DieAward = obj =>
|
||||
{
|
||||
tMP_CurrBossScore = obj
|
||||
.transform.GetChild(0).GetComponent<TextMeshProUGUI>();
|
||||
tMP_CurrBossScore = obj.transform.GetChild(0).GetComponent<TextMeshProUGUI>();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
layeredPool = null;
|
||||
FishResourcesData fishResourcesData;
|
||||
currBossScoreValue = 0;
|
||||
bossScoreValue = 0;
|
||||
redPacketRecords.Clear();
|
||||
_isJia = false;
|
||||
isDieFish = false;
|
||||
|
||||
fishResourcesData = FishResourcesData.fishResourcesDatasDic[fishTypeID];
|
||||
if (fishResourcesData.showAudio != null && fishResourcesData.showAudio.Count > 0)
|
||||
{
|
||||
var v = fishResourcesData.showAudio;
|
||||
int index = Random.Range(0, v.Count);
|
||||
AudioManager.Instance.PlayerFX(v[index]);
|
||||
}
|
||||
|
||||
var res = FishResourcesData.fishResourcesDatasDic[fishTypeID];
|
||||
if (res.showAudio != null && res.showAudio.Count > 0)
|
||||
AudioManager.Instance.PlayerFX(res.showAudio[Random.Range(0, res.showAudio.Count)]);
|
||||
}
|
||||
public void BigPrizeNotFish(int num)
|
||||
{
|
||||
if (layeredPool == null)
|
||||
{
|
||||
layeredPool = new LayeredPool(poolNum, prizeCount); // 初始化LayeredPool,假设5个人,10000分
|
||||
}
|
||||
if (tMP_CurrBossScore == null)
|
||||
{
|
||||
tMP_CurrBossScore = Instantiate(CreateFishManager.Instance.dieFXPrefabAwardTmp, CreateFishManager.Instance.currGameType.subPanelParent).transform.GetChild(0).GetComponent<TextMeshProUGUI>();
|
||||
}
|
||||
|
||||
var v = layeredPool.BossGlodCoinNotFish(num);
|
||||
redPacketRecords.Add(v);
|
||||
foreach (var item in v)
|
||||
{
|
||||
bossScoreValue += item.Amount;
|
||||
}
|
||||
turretNum = CreateFishManager.Instance.currGameType.currSitData.consumeGoldNum;
|
||||
GameManager.Instance.StartCoroutine(ShowBigPrize());
|
||||
GameManager.Instance.StartCoroutine(jiafen());
|
||||
|
||||
}
|
||||
public void BigPrize(int min = 4, int max = 8)
|
||||
{
|
||||
if (layeredPool==null)
|
||||
{
|
||||
layeredPool = new LayeredPool(poolNum, prizeCount); // 初始化LayeredPool,假设5个人,10000分
|
||||
}
|
||||
if (tMP_CurrBossScore == null)
|
||||
{
|
||||
tMP_CurrBossScore = Instantiate(CreateFishManager.Instance.dieFXPrefabAwardTmp, CreateFishManager.Instance.currGameType.subPanelParent).transform.GetChild(0).GetComponent<TextMeshProUGUI>();
|
||||
}
|
||||
|
||||
var v = layeredPool.BossGlodCoinRandrom(tMP_CurrBossScore.transform.position,min,max);
|
||||
redPacketRecords.Add(v);
|
||||
foreach (var item in v)
|
||||
{
|
||||
bossScoreValue += item.Amount;
|
||||
}
|
||||
turretNum = CreateFishManager.Instance.currGameType.currSitData.consumeGoldNum;
|
||||
GameManager.Instance. StartCoroutine(ShowBigPrize());
|
||||
GameManager.Instance.StartCoroutine(jiafen());
|
||||
|
||||
}
|
||||
bool isJia = false;
|
||||
public void BigPrizeAll()
|
||||
{
|
||||
int sss = CreateFishManager.Instance.fishDatas_hashCodekey_Small.Count;
|
||||
prizeCount = 1;
|
||||
if (layeredPool == null)
|
||||
{
|
||||
layeredPool = new LayeredPool(poolNum, prizeCount); // 初始化LayeredPool,假设5个人,10000分
|
||||
|
||||
}
|
||||
if (tMP_CurrBossScore == null)
|
||||
{
|
||||
tMP_CurrBossScore = Instantiate(CreateFishManager.Instance.dieFXPrefabAwardTmp, CreateFishManager.Instance.currGameType.subPanelParent).transform.GetChild(0).GetComponent<TextMeshProUGUI>();
|
||||
}
|
||||
var v = layeredPool.BossGlodCoin(sss, tMP_CurrBossScore.transform.position);
|
||||
redPacketRecords.Add(v);
|
||||
foreach (var item in v)
|
||||
{
|
||||
bossScoreValue += item.Amount;
|
||||
}
|
||||
turretNum = CreateFishManager.Instance.currGameType.currSitData.consumeGoldNum;
|
||||
GameManager.Instance.StartCoroutine(ShowBigPrize());
|
||||
GameManager.Instance.StartCoroutine(jiafen());
|
||||
|
||||
}
|
||||
long turretNum;
|
||||
IEnumerator ShowBigPrize()
|
||||
{
|
||||
if (!isJia)
|
||||
{
|
||||
isJia=true;
|
||||
yield return new WaitForSeconds(1);
|
||||
turretNum = Random.Range((int)(turretNum / 2), (int)turretNum + 1);
|
||||
while (currBossScoreValue < bossScoreValue)
|
||||
{
|
||||
currBossScoreValue += 1 * turretNum; // 每次增加1000分
|
||||
if (currBossScoreValue > bossScoreValue)
|
||||
{
|
||||
currBossScoreValue = bossScoreValue; // 确保不超过总分数
|
||||
}
|
||||
tMP_CurrBossScore.text = currBossScoreValue.ToString(); // 更新UI显示
|
||||
//yield return new WaitForSeconds(0.05f); // 每0.1秒更新一次
|
||||
yield return null;
|
||||
}
|
||||
isJia = false;
|
||||
}
|
||||
|
||||
}
|
||||
public IEnumerator jiafen()
|
||||
{
|
||||
yield return new WaitForSeconds(1.5f);
|
||||
Transform tra = tMP_CurrBossScore.transform.parent;
|
||||
GameObject obj = CreateFishManager.Instance.dieFXPrefabAwardTmp_AddScore;
|
||||
|
||||
List<RedPacketRecord> redRecords = new List<RedPacketRecord>();
|
||||
redRecords = redPacketRecords[0];
|
||||
|
||||
redPacketRecords.RemoveAt(0);
|
||||
foreach (var item in redRecords)
|
||||
{
|
||||
yield return new WaitForSeconds(0.15f);
|
||||
Instantiate(obj, tra.position, Quaternion.identity, tra).transform.GetChild(0).GetComponent<TextMeshProUGUI>().text = CoinScript.NumAdd(item.Amount.ToString());
|
||||
AudioManager.Instance.PlayerFX(61009);
|
||||
|
||||
}
|
||||
}
|
||||
public bool isDieFish=false;
|
||||
public override void DieFish(RoomKillNotice obj = null)
|
||||
{
|
||||
isDieFish = true;
|
||||
//CreateFishManager.Instance.Id_DieFish_NotFX(guid);
|
||||
GameManager.Instance.cameraShake.ShakePresets.Explosion2D(3f, 4f, 1f);
|
||||
if (obj != null)
|
||||
{
|
||||
poolNum = obj.gold;
|
||||
|
||||
}
|
||||
FishResourcesData fishResourcesData;
|
||||
|
||||
fishResourcesData = FishResourcesData.fishResourcesDatasDic[fishTypeID];
|
||||
if (fishResourcesData.dieAudio!=null&& fishResourcesData.dieAudio.Count>0)
|
||||
{
|
||||
var v = fishResourcesData.dieAudio;
|
||||
int index = Random.Range(0, v.Count);
|
||||
AudioManager.Instance.PlayerFX(v[index]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void EndBigPrize()
|
||||
{
|
||||
|
||||
}
|
||||
public async override void Init(string pathId, float Time, bool isyuzhen = false, string yzID = "")
|
||||
{
|
||||
|
||||
|
||||
isyz = isyuzhen;
|
||||
this.yzID = yzID;
|
||||
|
||||
//播报
|
||||
switch (GameManager.Instance.gameData.currGameType)
|
||||
{
|
||||
case GameType.JQQD:
|
||||
break;
|
||||
case GameType.defaultPanel:
|
||||
break;
|
||||
case GameType.FLZY:
|
||||
//{
|
||||
// AsyncOperationHandle<Sprite> handle = Addressables.LoadAssetAsync<Sprite>("Assets/Art/XJMH/pw/pw_sprite/handbook/" + bossName + ".png");
|
||||
// await handle.Task;
|
||||
// Sprite sprite = handle.Result;
|
||||
// CreateFishManager.Instance. currGameType.subUIManager.ShowBoardBoss(sprite, bossName);
|
||||
|
||||
//}
|
||||
|
||||
break;
|
||||
case GameType.YYSC:
|
||||
//还没有写呢
|
||||
//{
|
||||
// AsyncOperationHandle<Sprite> handle = Addressables.LoadAssetAsync<Sprite>("Assets/Art/XJMH/pw/pw_sprite/handbook/" + bossName + ".png");
|
||||
// await handle.Task;
|
||||
// Sprite sprite = handle.Result;
|
||||
// CreateFishManager.Instance.currGameType.subUIManager.ShowBoardBoss(sprite, bossName);
|
||||
|
||||
//}
|
||||
break;
|
||||
case GameType.ZGXQ:
|
||||
|
||||
break;
|
||||
case GameType.XJMH:
|
||||
{
|
||||
AsyncOperationHandle<Sprite> handle = Addressables.LoadAssetAsync<Sprite>("Assets/Art/XJMH/pw/pw_sprite/handbook/" + bossName + ".png");
|
||||
await handle.Task;
|
||||
Sprite sprite = handle.Result;
|
||||
CreateFishManager.Instance.currGameType.subUIManager.ShowBoardBoss(sprite, bossName);
|
||||
|
||||
}
|
||||
break;
|
||||
case GameType.HHWK:
|
||||
//{
|
||||
// AsyncOperationHandle<Sprite> handle = Addressables.LoadAssetAsync<Sprite>("Assets/Art/XJMH/pw/pw_sprite/handbook/" + bossName + ".png");
|
||||
// await handle.Task;
|
||||
// Sprite sprite = handle.Result;
|
||||
// CreateFishManager.Instance.currGameType.subUIManager.ShowBoardBoss(sprite, bossName);
|
||||
|
||||
//}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
BezierCurveData bezierCurveData = MonsterMoveLine.dic_BezierCurveDatas[bossName + pathId];
|
||||
monsterData.moveLine.Init(bezierCurveData, Time);
|
||||
}
|
||||
public override void OnDisable()
|
||||
{
|
||||
base.OnDisable();
|
||||
if (isDieFish)
|
||||
{
|
||||
GameManager.Instance.StartCoroutine(yanchidie());
|
||||
|
||||
}
|
||||
|
||||
GameManager.Instance.StartCoroutine(YanChiDie());
|
||||
}
|
||||
public float dieTime = 3f;
|
||||
public Vector3 v3;//分数飞出位置
|
||||
IEnumerator yanchidie()
|
||||
|
||||
// ==================== 初始化 ====================
|
||||
|
||||
public async override void Init(string pathId, float time, bool isyuzhen = false, string yzID = "")
|
||||
{
|
||||
isyz = isyuzhen;
|
||||
this.yzID = yzID;
|
||||
|
||||
// Boss 进场播报
|
||||
if (GameManager.Instance.gameData.currGameType == GameType.XJMH)
|
||||
{
|
||||
var handle = Addressables.LoadAssetAsync<Sprite>($"Assets/Art/XJMH/pw/pw_sprite/handbook/{bossName}.png");
|
||||
await handle.Task;
|
||||
CreateFishManager.Instance.currGameType.subUIManager.ShowBoardBoss(handle.Result, bossName);
|
||||
}
|
||||
|
||||
var bezierData = MonsterMoveLine.dic_BezierCurveDatas[bossName + pathId];
|
||||
monsterData.moveLine.Init(bezierData, time);
|
||||
}
|
||||
|
||||
// ==================== 爆奖(公共) ====================
|
||||
|
||||
/// <summary>确保分数显示文本存在(自动创建)</summary>
|
||||
private void EnsureScorePanel()
|
||||
{
|
||||
if (tMP_CurrBossScore != null) return;
|
||||
var prefab = CreateFishManager.Instance.dieFXPrefabAwardTmp;
|
||||
if (prefab == null) return;
|
||||
var parent = CreateFishManager.Instance.currGameType.subPanelParent;
|
||||
if (parent == null) return;
|
||||
|
||||
tMP_CurrBossScore = Instantiate(prefab, parent)
|
||||
.transform.GetChild(0).GetComponent<TextMeshProUGUI>();
|
||||
}
|
||||
|
||||
/// <summary>初始化红包分层对象池</summary>
|
||||
private void EnsureLayeredPool()
|
||||
{
|
||||
if (layeredPool == null)
|
||||
layeredPool = new LayeredPool(poolNum, prizeCount);
|
||||
}
|
||||
|
||||
/// <summary>爆奖:随机红包(min~max 个)</summary>
|
||||
public void BigPrize(int min = 4, int max = 8)
|
||||
{
|
||||
EnsureScorePanel();
|
||||
EnsureLayeredPool();
|
||||
|
||||
var records = layeredPool.BossGlodCoinRandrom(tMP_CurrBossScore.transform.position, min, max);
|
||||
AddRedPacket(records);
|
||||
}
|
||||
|
||||
/// <summary>爆奖:固定数量红包</summary>
|
||||
public void BigPrizeNotFish(int count)
|
||||
{
|
||||
EnsureScorePanel();
|
||||
EnsureLayeredPool();
|
||||
|
||||
var records = layeredPool.BossGlodCoinNotFish(count);
|
||||
AddRedPacket(records);
|
||||
}
|
||||
|
||||
/// <summary>爆奖:全屏小鱼数量红包</summary>
|
||||
public void BigPrizeAll()
|
||||
{
|
||||
int smallFishCount = CreateFishManager.Instance.fishDatas_hashCodekey_Small.Count;
|
||||
prizeCount = 1;
|
||||
EnsureScorePanel();
|
||||
EnsureLayeredPool();
|
||||
|
||||
var records = layeredPool.BossGlodCoin(smallFishCount, tMP_CurrBossScore.transform.position);
|
||||
AddRedPacket(records);
|
||||
}
|
||||
|
||||
/// <summary>记录红包并开始分数滚动 + 加分</summary>
|
||||
private void AddRedPacket(List<RedPacketRecord> records)
|
||||
{
|
||||
redPacketRecords.Add(records);
|
||||
foreach (var r in records)
|
||||
bossScoreValue += r.Amount;
|
||||
|
||||
_turretNum = CreateFishManager.Instance.currGameType.currSitData.consumeGoldNum;
|
||||
GameManager.Instance.StartCoroutine(ShowBigPrize());
|
||||
GameManager.Instance.StartCoroutine(JiaFenRoutine());
|
||||
}
|
||||
|
||||
// ==================== 分数滚动 ====================
|
||||
|
||||
private IEnumerator ShowBigPrize()
|
||||
{
|
||||
if (_isJia) yield break;
|
||||
_isJia = true;
|
||||
|
||||
yield return new WaitForSeconds(1f);
|
||||
_turretNum = Random.Range((int)(_turretNum / 2), (int)_turretNum + 1);
|
||||
|
||||
while (currBossScoreValue < bossScoreValue)
|
||||
{
|
||||
currBossScoreValue += _turretNum;
|
||||
if (currBossScoreValue > bossScoreValue)
|
||||
currBossScoreValue = bossScoreValue;
|
||||
tMP_CurrBossScore.text = currBossScoreValue.ToString();
|
||||
yield return null;
|
||||
}
|
||||
_isJia = false;
|
||||
}
|
||||
|
||||
private IEnumerator JiaFenRoutine()
|
||||
{
|
||||
yield return new WaitForSeconds(1.5f);
|
||||
|
||||
Transform parent = tMP_CurrBossScore.transform.parent;
|
||||
GameObject addScorePrefab = CreateFishManager.Instance.dieFXPrefabAwardTmp_AddScore;
|
||||
|
||||
var records = redPacketRecords[0];
|
||||
redPacketRecords.RemoveAt(0);
|
||||
|
||||
foreach (var item in records)
|
||||
{
|
||||
yield return new WaitForSeconds(0.15f);
|
||||
var inst = Instantiate(addScorePrefab, parent.position, Quaternion.identity, parent);
|
||||
inst.transform.GetChild(0).GetComponent<TextMeshProUGUI>().text = CoinScript.NumAdd(item.Amount.ToString());
|
||||
AudioManager.Instance.PlayerFX(61009);
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 死亡 ====================
|
||||
|
||||
public override void DieFish(RoomKillNotice obj = null)
|
||||
{
|
||||
isDieFish = true;
|
||||
GameManager.Instance.cameraShake.ShakePresets.Explosion2D(3f, 4f, 1f);
|
||||
|
||||
if (obj != null)
|
||||
poolNum = obj.gold;
|
||||
|
||||
var res = FishResourcesData.fishResourcesDatasDic[fishTypeID];
|
||||
if (res.dieAudio != null && res.dieAudio.Count > 0)
|
||||
AudioManager.Instance.PlayerFX(res.dieAudio[Random.Range(0, res.dieAudio.Count)]);
|
||||
}
|
||||
|
||||
/// <summary>死亡后延迟飞分到座位</summary>
|
||||
private IEnumerator YanChiDie()
|
||||
{
|
||||
yield return new WaitForSeconds(dieTime);
|
||||
tMP_CurrBossScore.transform.parent.DOMove(v3, 0.5f).OnComplete(() =>
|
||||
{
|
||||
|
||||
|
||||
JiaFen?.Invoke(0);
|
||||
|
||||
Destroy(tMP_CurrBossScore.transform.parent.gameObject);
|
||||
});
|
||||
|
||||
|
||||
tMP_CurrBossScore.transform.parent
|
||||
.DOMove(v3, 0.5f)
|
||||
.OnComplete(() =>
|
||||
{
|
||||
JiaFen?.Invoke(0);
|
||||
Destroy(tMP_CurrBossScore.transform.parent.gameObject);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user