1
This commit is contained in:
@@ -621,7 +621,7 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
|
||||
}
|
||||
}
|
||||
|
||||
StartCoroutine(buchongfu(bossList, bossCount));
|
||||
StartCoroutine(buchongfu(bossList, bossCount, fishDatas_hashCodekey_Boss));
|
||||
|
||||
|
||||
}
|
||||
@@ -646,7 +646,7 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
|
||||
// item.isCreate = 2;
|
||||
// }
|
||||
//}
|
||||
StartCoroutine(buchongfu(tsbossList, tsbossCount));
|
||||
StartCoroutine(buchongfu(tsbossList, tsbossCount, fishDatas_hashCodekey_TS_Boss));
|
||||
|
||||
|
||||
}
|
||||
@@ -707,13 +707,13 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
|
||||
return result;
|
||||
}
|
||||
|
||||
IEnumerator buchongfu(List<RoomFishDetailConfig> bossList, int count)
|
||||
IEnumerator buchongfu(List<RoomFishDetailConfig> bossList, int count, Dictionary<string, MonsterContral> targetDict)
|
||||
{
|
||||
for (int j = 0; j < count; j++)
|
||||
{
|
||||
// 1. 先筛选出未重复的候选集合
|
||||
// 1. 先筛选出未重复的候选集合(排除场上已存在的同 fishNumber 的鱼)
|
||||
var candidates = bossList
|
||||
.Where(b => !fishDatas_hashCodekey_Boss.Values
|
||||
.Where(b => !targetDict.Values
|
||||
.Any(existing => existing.fishTypeID.ToString() == b.fishNumber))
|
||||
.ToList();
|
||||
|
||||
@@ -727,6 +727,8 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
|
||||
|
||||
// 3. 标记激活
|
||||
chosen.isCreate = 2;
|
||||
|
||||
yield return null; // 每帧只激活一条,避免同帧生成过多
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using CameraShake;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.Rendering;
|
||||
@@ -48,11 +49,12 @@ public class GameManager : MonoSingleton<GameManager>
|
||||
}
|
||||
|
||||
}
|
||||
protected override async void Awake()
|
||||
protected override void Awake()
|
||||
{
|
||||
|
||||
AudioResourcesData audioResourcesData=new AudioResourcesData();
|
||||
|
||||
InItLoad();
|
||||
//TurretResourcesData turretResourcesData = new TurretResourcesData();
|
||||
Application.runInBackground = true;
|
||||
|
||||
base.Awake();
|
||||
@@ -68,6 +70,10 @@ public class GameManager : MonoSingleton<GameManager>
|
||||
});
|
||||
|
||||
}
|
||||
public async Task InItLoad()
|
||||
{
|
||||
await TurretResourcesData.LoadTurretAssetsData();
|
||||
}
|
||||
public void StartGame(Action action)
|
||||
{
|
||||
|
||||
|
||||
@@ -1,140 +1,140 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace Assets.MyGame.Scripts.Net.APIRequest.Params
|
||||
{
|
||||
/// <summary>
|
||||
/// 存入保险箱请求参数
|
||||
/// 存入保险箱请求参数
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class SaveSafeBoxParam : RequestParamBase
|
||||
{
|
||||
|
||||
public int amount; // 存入金额
|
||||
public int amount; // 存入金额
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置保险箱密码请求参数
|
||||
/// 设置保险箱密码请求参数
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class SetSafeBoxPasswordParam : RequestParamBase
|
||||
{
|
||||
public string newPwd; // 新密码
|
||||
public string newPwd; // 新密码
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置保险箱密码请求参数
|
||||
/// 重置保险箱密码请求参数
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class ResetSafeBoxPasswordParam : RequestParamBase
|
||||
{
|
||||
public string code; // 验证码
|
||||
public string code; // 验证码
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 合成碎片请求参数
|
||||
/// 合成碎片请求参数
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class SynthesisFragmentParam : RequestParamBase
|
||||
{
|
||||
public int fragmentId; // 碎片ID
|
||||
public int count; // 数量
|
||||
public int fragmentId; // 碎片ID
|
||||
public int count; // 数量
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 购买月卡请求参数(GET)
|
||||
/// 购买月卡请求参数(GET)
|
||||
/// Swagger: GET /api/Hall/BuyMonthCard
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class BuyMonthCardParam : RequestParamBase
|
||||
{
|
||||
/// <summary>月卡类型 1=周卡 2=月卡 3=年卡</summary>
|
||||
/// <summary>月卡类型 1=周卡 2=月卡 3=年卡</summary>
|
||||
public int type;
|
||||
|
||||
/// <summary>金币价格(用于校验)</summary>
|
||||
/// <summary>金币价格(用于校验)</summary>
|
||||
public int gold;
|
||||
|
||||
/// <summary>现金价格</summary>
|
||||
/// <summary>现金价格</summary>
|
||||
public double money;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 购买道具请求参数(GET)
|
||||
/// 购买道具请求参数(GET)
|
||||
/// Swagger: GET /api/Hall/BuyProp
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class BuyPropParam : RequestParamBase
|
||||
{
|
||||
/// <summary>道具编号</summary>
|
||||
/// <summary>道具编号</summary>
|
||||
public string propNumber;
|
||||
|
||||
/// <summary>购买数量</summary>
|
||||
/// <summary>购买数量</summary>
|
||||
public int count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 购买金币请求参数(GET)
|
||||
/// 购买金币请求参数(GET)
|
||||
/// Swagger: GET /api/Hall/BuyGold
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class BuyGoldParam : RequestParamBase
|
||||
{
|
||||
/// <summary>商品编号(GoldShopConfig.number)</summary>
|
||||
/// <summary>商品编号(GoldShopConfig.number)</summary>
|
||||
public string number;
|
||||
|
||||
/// <summary>购买数量</summary>
|
||||
/// <summary>购买数量</summary>
|
||||
public int count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 购买钻石请求参数(GET)
|
||||
/// 购买钻石请求参数(GET)
|
||||
/// Swagger: GET /api/Hall/BuyDiamond
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class BuyDiamondParam : RequestParamBase
|
||||
{
|
||||
/// <summary>商品编号(DiamondShopConfig.number)</summary>
|
||||
/// <summary>商品编号(DiamondShopConfig.number)</summary>
|
||||
public string number;
|
||||
|
||||
/// <summary>购买数量</summary>
|
||||
/// <summary>购买数量</summary>
|
||||
public int count;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 切换炮台请求参数
|
||||
/// 切换炮台请求参数
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class ChangeCannonParam : RequestParamBase
|
||||
{
|
||||
public int cannonId; // 炮台ID
|
||||
public string number; // 炮台编号
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 切换翅膀请求参数
|
||||
/// 切换翅膀请求参数
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class ChangeWingParam : RequestParamBase
|
||||
{
|
||||
public int wingId; // 翅膀ID
|
||||
public string number; // 翅膀编号
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 切换战神请求参数
|
||||
/// 切换战神请求参数
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class ChangeGodWarParam : RequestParamBase
|
||||
{
|
||||
public int godWarId; // 战神ID
|
||||
public string number; // 战神编号
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发放奖励请求参数
|
||||
/// 发放奖励请求参数
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class DistributeRewardsParam : RequestParamBase
|
||||
{
|
||||
public int rewardId; // 奖励ID
|
||||
public int rewardId; // 奖励ID
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace Assets.MyGame.Scripts.Net.API
|
||||
/// </summary>
|
||||
public string token;
|
||||
}
|
||||
[Serializable]
|
||||
public class UserData
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -1,275 +1,15 @@
|
||||
////using Assets.MyGame.Scripts.Net.API;
|
||||
////using Spine.Unity;
|
||||
////using System;
|
||||
////using System.Collections;
|
||||
////using System.Collections.Generic;
|
||||
////using System.Linq;
|
||||
////using TMPro;
|
||||
////using Unity.VisualScripting;
|
||||
////using UnityEngine;
|
||||
////using UnityEngine.UI;
|
||||
|
||||
////public class SitPosData : MonoBehaviour
|
||||
////{
|
||||
//// [Header("用户id")]
|
||||
//// public string user;
|
||||
//// [Header("座位id")]
|
||||
//// public int posID;
|
||||
//// [Header("金币")]
|
||||
//// public TextMeshProUGUI tMP_TurretConsumeNum;
|
||||
//// public TextMeshProUGUI tMP_GoldNum;
|
||||
|
||||
//// public Button btn_TurretAdd;
|
||||
//// public Button btn_TurretMinus;
|
||||
|
||||
//// public long goldNum;
|
||||
//// public long consumeGoldNum;
|
||||
//// [Header("炮台")]
|
||||
//// public Dictionary<string, TurretData> dic_Turrets=new Dictionary<string, TurretData>();
|
||||
//// public List<TurretData> list_Turrets=new List<TurretData>();
|
||||
//// public int currentTurretIndex = 0;
|
||||
//// public string currentTurretID = "";
|
||||
//// public TurretData currentTurret;
|
||||
//// [Header("锁定")]
|
||||
//// public MonsterContral monCotl_Lock;
|
||||
//// public Transform monCotl_Lock_Position;
|
||||
//// public bool isLock=false;
|
||||
//// public GameObject lockFX;
|
||||
|
||||
//// [Header("当前炮塔")]
|
||||
//// public Transform tra_CurrTurret;
|
||||
//// public Transform tra_CurrFly; //星际迷航特有
|
||||
|
||||
//// public GameObject changeTurretList;
|
||||
|
||||
|
||||
//// public Action<TurretState> OnStateChange;
|
||||
|
||||
//// public void ChangeState(TurretState state)
|
||||
//// {
|
||||
//// OnStateChange?.Invoke(state);
|
||||
//// }
|
||||
|
||||
//// public void Awake()
|
||||
//// {
|
||||
//// //list_Turrets.Sort((td1,td2) =>
|
||||
//// //{
|
||||
//// // return td1.turretID.CompareTo(td2.turretLevel);
|
||||
//// //});
|
||||
//// dic_Turrets = list_Turrets.ToDictionary(td => td.turretID);
|
||||
//// btn_TurretAdd.onClick.AddListener(() =>
|
||||
//// {
|
||||
//// ChangeTurretAddConsumeNum(1000);
|
||||
//// });
|
||||
//// btn_TurretMinus.onClick.AddListener(() =>
|
||||
//// {
|
||||
//// ChangeTurretMinusConsumeNum(1000);
|
||||
|
||||
//// });
|
||||
//// }
|
||||
//// public void Update()
|
||||
//// {
|
||||
|
||||
//// }
|
||||
//// public void ChangeTurret(int n=0)
|
||||
//// {
|
||||
|
||||
//// if (currentTurretIndex>list_Turrets.Count|| currentTurretIndex<0)
|
||||
//// {
|
||||
//// //currentTurretIndex = currentTurretIndex;
|
||||
//// }
|
||||
//// else
|
||||
//// {
|
||||
//// currentTurretIndex = n;
|
||||
//// }
|
||||
//// if (currentTurret != null)
|
||||
//// {
|
||||
//// currentTurret.gameObject.SetActive(false);
|
||||
//// }
|
||||
|
||||
//// currentTurretID = list_Turrets[currentTurretIndex].turretID; //dic_Turrets[currentTurretID];
|
||||
//// currentTurret=dic_Turrets[currentTurretID];
|
||||
//// currentTurret.gameObject.SetActive(true);
|
||||
//// // ⭐ 关键:把状态机入口绑定到当前炮台
|
||||
//// OnStateChange = currentTurret.ChangeState;
|
||||
|
||||
//// gameObject.SetActive(true);
|
||||
//// tra_CurrTurret =currentTurret.transform.GetChild(0);
|
||||
//// tra_CurrFly = currentTurret.transform.GetChild(1);
|
||||
|
||||
//// }
|
||||
//// public void ChangeTurretConsumeNum(int n = 0)
|
||||
//// {
|
||||
//// consumeGoldNum = n;
|
||||
//// tMP_TurretConsumeNum.text = consumeGoldNum.ToString();
|
||||
|
||||
//// }
|
||||
//// public void ChangeTurretAddConsumeNum(int n = 0)
|
||||
//// {
|
||||
//// consumeGoldNum += n;
|
||||
//// tMP_TurretConsumeNum.text = consumeGoldNum.ToString();
|
||||
|
||||
//// }
|
||||
//// public void ChangeTurretMinusConsumeNum(int n = 0)
|
||||
//// {
|
||||
//// consumeGoldNum -= n;
|
||||
//// tMP_TurretConsumeNum.text = consumeGoldNum.ToString();
|
||||
|
||||
//// }
|
||||
//// public bool ConsumeGold(int bl=1)
|
||||
//// {
|
||||
//// long temp = goldNum - consumeGoldNum*bl;
|
||||
//// if (temp > 0)
|
||||
//// {
|
||||
//// goldNum = temp;
|
||||
//// tMP_GoldNum.text = goldNum.ToString();
|
||||
//// return true;
|
||||
//// }
|
||||
//// return false;
|
||||
//// }
|
||||
////}
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using TMPro;
|
||||
//using UnityEngine;
|
||||
//using UnityEngine.UI;
|
||||
|
||||
//public class SitPosData : MonoBehaviour
|
||||
//{
|
||||
// // -------------------------
|
||||
// // 玩家信息
|
||||
// // -------------------------
|
||||
// public string user;
|
||||
// public int posID;
|
||||
|
||||
// [Header("金币")]
|
||||
// public long goldNum;
|
||||
// public long consumeGoldNum;
|
||||
// public TextMeshProUGUI tMP_TurretConsumeNum;
|
||||
// public TextMeshProUGUI tMP_GoldNum;
|
||||
|
||||
// // -------------------------
|
||||
// // 炮台管理
|
||||
// // -------------------------
|
||||
// public List<TurretData> list_Turrets = new List<TurretData>();
|
||||
// public Dictionary<string, TurretData> dic_Turrets = new Dictionary<string, TurretData>();
|
||||
// public int currentTurretIndex = 0;
|
||||
// public TurretData currentTurret;
|
||||
|
||||
// // 状态机入口(GameMainPanel 调用)
|
||||
// public Action<TurretState> OnStateChange;
|
||||
|
||||
// // -------------------------
|
||||
// // 炮台旋转
|
||||
// // -------------------------
|
||||
// public Transform tra_CurrTurret;
|
||||
// public float currentAngle;
|
||||
|
||||
// // -------------------------
|
||||
// // 锁定系统
|
||||
// // -------------------------
|
||||
// public MonsterContral monCotl_Lock;
|
||||
// public Transform monCotl_Lock_Position;
|
||||
// public bool isLock;
|
||||
// public GameObject lockFX;
|
||||
|
||||
// // -------------------------
|
||||
// // UI
|
||||
// // -------------------------
|
||||
// public Button btn_TurretAdd;
|
||||
// public Button btn_TurretMinus;
|
||||
// public GameObject changeTurretList;
|
||||
|
||||
// private void Awake()
|
||||
// {
|
||||
// dic_Turrets = list_Turrets.ToDictionary(t => t.turretID);
|
||||
|
||||
// btn_TurretAdd.onClick.AddListener(() => ChangeTurretAddConsumeNum(1000));
|
||||
// btn_TurretMinus.onClick.AddListener(() => ChangeTurretMinusConsumeNum(1000));
|
||||
// }
|
||||
|
||||
// // -------------------------
|
||||
// // 切换炮台
|
||||
// // -------------------------
|
||||
// public void ChangeTurret(int index)
|
||||
// {
|
||||
// if (currentTurret != null)
|
||||
// currentTurret.gameObject.SetActive(false);
|
||||
|
||||
// currentTurretIndex = Mathf.Clamp(index, 0, list_Turrets.Count - 1);
|
||||
// currentTurret = list_Turrets[currentTurretIndex];
|
||||
// currentTurret.gameObject.SetActive(true);
|
||||
|
||||
// // 绑定状态机入口
|
||||
// OnStateChange = currentTurret.ChangeState;
|
||||
|
||||
// // 缓存旋转点
|
||||
// tra_CurrTurret = currentTurret.transform.GetChild(0);
|
||||
// }
|
||||
|
||||
// // -------------------------
|
||||
// // 切换状态(GameMainPanel 调用)
|
||||
// // -------------------------
|
||||
// public void ChangeState(TurretState state)
|
||||
// {
|
||||
// OnStateChange?.Invoke(state);
|
||||
// }
|
||||
|
||||
// // -------------------------
|
||||
// // 炮台旋转
|
||||
// // -------------------------
|
||||
// public void SetRotation(float angle)
|
||||
// {
|
||||
// currentAngle = angle;
|
||||
// tra_CurrTurret.rotation = Quaternion.Euler(0, 0, angle);
|
||||
// }
|
||||
|
||||
// // -------------------------
|
||||
// // 获取发射点(给 GameMainPanel)
|
||||
// // -------------------------
|
||||
// public Vector2 GetBulletStartPos()
|
||||
// {
|
||||
// return currentTurret.GetBulletStartWorldPos();
|
||||
// }
|
||||
|
||||
// // -------------------------
|
||||
// // 金币消耗
|
||||
// // -------------------------
|
||||
// public bool ConsumeGold(int mul = 1)
|
||||
// {
|
||||
// long temp = goldNum - consumeGoldNum * mul;
|
||||
// if (temp < 0) return false;
|
||||
|
||||
// goldNum = temp;
|
||||
// tMP_GoldNum.text = goldNum.ToString();
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// public void ChangeTurretAddConsumeNum(int n)
|
||||
// {
|
||||
// consumeGoldNum += n;
|
||||
// tMP_TurretConsumeNum.text = consumeGoldNum.ToString();
|
||||
// }
|
||||
|
||||
// public void ChangeTurretMinusConsumeNum(int n)
|
||||
// {
|
||||
// consumeGoldNum -= n;
|
||||
// tMP_TurretConsumeNum.text = consumeGoldNum.ToString();
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SitPosData : MonoBehaviour
|
||||
{
|
||||
/// <summary>本地玩家的座位引用(由游戏面板初始化时设置)</summary>
|
||||
public static SitPosData localPlayerSit;
|
||||
|
||||
// -------------------------
|
||||
// 玩家基础信息
|
||||
// -------------------------
|
||||
@@ -284,14 +24,19 @@ public class SitPosData : MonoBehaviour
|
||||
public TextMeshProUGUI tMP_TurretConsumeNum;
|
||||
|
||||
// -------------------------
|
||||
// 炮台管理
|
||||
// 炮台管理(动态克隆)
|
||||
// -------------------------
|
||||
[Header("炮台")]
|
||||
public List<TurretData> list_Turrets = new List<TurretData>();
|
||||
public Dictionary<string, TurretData> dic_Turrets = new Dictionary<string, TurretData>();
|
||||
[Tooltip("炮台实例化的父节点")]
|
||||
public Transform turretParent;
|
||||
|
||||
public int currentTurretIndex = 0;
|
||||
public string currentTurretID = "";
|
||||
[Tooltip("炮台锚点位置(相对 turretParent)")]
|
||||
public Vector2 turretAnchoredPos = Vector2.zero;
|
||||
|
||||
[Tooltip("当前装备的炮台编号")]
|
||||
public int currentTurretNumber;
|
||||
|
||||
/// <summary>当前运行中的炮台实例</summary>
|
||||
public TurretData currentTurret;
|
||||
|
||||
// 状态机入口(GameMainPanel 调用)
|
||||
@@ -319,48 +64,90 @@ public class SitPosData : MonoBehaviour
|
||||
[Header("UI")]
|
||||
public Button btn_TurretAdd;
|
||||
public Button btn_TurretMinus;
|
||||
public GameObject changeTurretList;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
btn_TurretAdd.onClick.AddListener(() => ChangeTurretAddConsumeNum());
|
||||
btn_TurretMinus.onClick.AddListener(() => ChangeTurretMinusConsumeNum());
|
||||
// 构建字典
|
||||
dic_Turrets = list_Turrets.ToDictionary(t => t.turretID);
|
||||
|
||||
// 炮台倍率按钮
|
||||
|
||||
}
|
||||
// -------------------------
|
||||
// 切换炮台
|
||||
// -------------------------
|
||||
public void ChangeTurret(int index)
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
// 如果是本地玩家的座位,自动注册为 localPlayerSit
|
||||
if (user == GameManager.Instance?.user?.id)
|
||||
{
|
||||
localPlayerSit = this;
|
||||
|
||||
// 加载玩家当前装备的炮台
|
||||
var cannonUsing = GameManager.Instance.user.cannonUsing;
|
||||
if (cannonUsing != null && int.TryParse(cannonUsing.number, out int num))
|
||||
LoadTurret(num);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (localPlayerSit == this)
|
||||
localPlayerSit = null;
|
||||
}
|
||||
|
||||
// ==================== 炮台加载(动态克隆) ====================
|
||||
|
||||
/// <summary>
|
||||
/// 根据炮台编号,从 Addressables 加载预制体并克隆到 turretParent。
|
||||
/// 位置/旋转/缩放保持预制体原始值,不动。
|
||||
/// </summary>
|
||||
public void LoadTurret(int turretNumber)
|
||||
{
|
||||
// 关闭旧炮台
|
||||
if (currentTurret != null)
|
||||
currentTurret.gameObject.SetActive(false);
|
||||
{
|
||||
Destroy(currentTurret.gameObject);
|
||||
currentTurret = null;
|
||||
}
|
||||
|
||||
// 计算新索引
|
||||
currentTurretIndex = Mathf.Clamp(index, 0, list_Turrets.Count - 1);
|
||||
currentTurretNumber = turretNumber;
|
||||
|
||||
// 获取新炮台
|
||||
currentTurret = list_Turrets[currentTurretIndex];
|
||||
currentTurretID = currentTurret.turretID;
|
||||
currentTurret.gameObject.SetActive(true);
|
||||
// 从 TurretResourcesData 拿预制体
|
||||
GameObject prefab = TurretResourcesData.GetTurretPrefab(turretNumber);
|
||||
if (prefab == null)
|
||||
{
|
||||
Debug.LogWarning($"[SitPosData] 炮台预制体未加载: #{turretNumber}");
|
||||
return;
|
||||
}
|
||||
|
||||
// 绑定状态机入口
|
||||
// 克隆到父节点
|
||||
GameObject instance = Instantiate(prefab, turretParent, false);
|
||||
instance.SetActive(true);
|
||||
|
||||
// 固定位置归零,由外部父节点定位
|
||||
var rt = instance.GetComponent<RectTransform>();
|
||||
if (rt != null)
|
||||
rt.anchoredPosition = turretAnchoredPos;
|
||||
|
||||
currentTurret = instance.GetComponent<TurretData>();
|
||||
if (currentTurret == null)
|
||||
{
|
||||
Debug.LogError($"[SitPosData] 预制体上未找到 TurretData 组件: #{turretNumber}");
|
||||
Destroy(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
currentTurret.turretNumber = turretNumber;
|
||||
|
||||
// 缓存旋转节点
|
||||
tra_CurrTurret = currentTurret.transform.GetChild(0);
|
||||
|
||||
// 绑定状态机入口
|
||||
OnStateChange = currentTurret.ChangeState;
|
||||
|
||||
// 缓存旋转点
|
||||
tra_CurrTurret = currentTurret.transform.GetChild(0);
|
||||
if (CreateFishManager.Instance.currGameType != null)
|
||||
{
|
||||
// 如果当前处于狂暴状态,切换炮台后也要继续倍速
|
||||
bool frenzy = CreateFishManager.Instance.currGameType.isFrenzy;
|
||||
currentTurret.SetFrenzy(frenzy);
|
||||
}
|
||||
|
||||
Debug.Log($"[SitPosData] 炮台已加载: #{turretNumber}");
|
||||
}
|
||||
|
||||
/// <summary>根据炮台编号字符串加载。</summary>
|
||||
public void LoadTurret(string turretNumberStr)
|
||||
{
|
||||
if (int.TryParse(turretNumberStr, out int num))
|
||||
LoadTurret(num);
|
||||
}
|
||||
|
||||
// -------------------------
|
||||
@@ -386,61 +173,53 @@ public class SitPosData : MonoBehaviour
|
||||
// -------------------------
|
||||
public Vector2 GetBulletStartPos()
|
||||
{
|
||||
return currentTurret.GetBulletStartWorldPos();
|
||||
return currentTurret != null
|
||||
? currentTurret.GetBulletStartWorldPos()
|
||||
: Vector2.zero;
|
||||
}
|
||||
|
||||
// -------------------------
|
||||
// 金币消耗
|
||||
// -------------------------
|
||||
// ==================== 金币消耗 ====================
|
||||
|
||||
public bool ConsumeGold(int mul = 1)
|
||||
{
|
||||
long temp = goldNum - consumeGoldNum * mul;
|
||||
if (temp < 0) return false;
|
||||
|
||||
goldNum = temp;
|
||||
tMP_GoldNum.text = goldNum.ToString();
|
||||
return true;
|
||||
}
|
||||
int indexConsume=0;
|
||||
|
||||
int indexConsume = 0;
|
||||
|
||||
public void ChangeTurretAddConsumeNum()
|
||||
{
|
||||
if (CreateFishManager.Instance.currGameType.paoBeiList.Count-1> indexConsume)
|
||||
{
|
||||
if (CreateFishManager.Instance.currGameType.paoBeiList.Count - 1 > indexConsume)
|
||||
indexConsume++;
|
||||
}
|
||||
else
|
||||
{
|
||||
indexConsume = 0;
|
||||
}
|
||||
|
||||
|
||||
consumeGoldNum = CreateFishManager.Instance.currGameType.paoBeiList[indexConsume];
|
||||
tMP_TurretConsumeNum.text = consumeGoldNum.ToString();
|
||||
}
|
||||
|
||||
public void ChangeTurretMinusConsumeNum()
|
||||
{
|
||||
|
||||
if (indexConsume>0)
|
||||
{
|
||||
if (indexConsume > 0)
|
||||
indexConsume--;
|
||||
}
|
||||
else
|
||||
{
|
||||
indexConsume = CreateFishManager.Instance.currGameType.paoBeiList.Count - 1;
|
||||
}
|
||||
|
||||
consumeGoldNum = CreateFishManager.Instance.currGameType.paoBeiList[indexConsume];
|
||||
tMP_TurretConsumeNum.text = consumeGoldNum.ToString();
|
||||
}
|
||||
|
||||
// -------------------------
|
||||
// 锁定系统(本地)
|
||||
// -------------------------
|
||||
// ==================== 锁定系统 ====================
|
||||
|
||||
public void SetLockTarget(MonsterContral monster, Transform hitPos)
|
||||
{
|
||||
monCotl_Lock = monster;
|
||||
monCotl_Lock_Position = hitPos;
|
||||
isLock = monster != null;
|
||||
|
||||
lockFX.SetActive(isLock);
|
||||
}
|
||||
|
||||
@@ -449,9 +228,7 @@ public class SitPosData : MonoBehaviour
|
||||
monCotl_Lock = null;
|
||||
monCotl_Lock_Position = null;
|
||||
isLock = false;
|
||||
|
||||
lockFX.SetActive(false);
|
||||
ChangeState(TurretState.Idle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Spine.Unity;
|
||||
using Spine.Unity;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public enum TurretAnimType
|
||||
@@ -31,6 +32,29 @@ public class TurretData : MonoBehaviour
|
||||
public GameObject bulletPrefab_Two;
|
||||
public GameObject bulletPrefab;
|
||||
|
||||
[Header("UI面板属性")]
|
||||
[Tooltip("炮台编号,对应 TurretResourcesData.turretNumber")]
|
||||
public int turretNumber;
|
||||
[Tooltip("1=普通炮台 2=战神 3=翅膀")]
|
||||
public int turretType = 1;
|
||||
[Tooltip("UI 展示名称")]
|
||||
public string displayName;
|
||||
[Tooltip("品质 1=普通 2=稀有 3=史诗 4=传说")]
|
||||
[Range(1, 5)]
|
||||
public int quality = 1;
|
||||
[Tooltip("解锁所需等级(0=默认拥有)")]
|
||||
public int unlockLevel;
|
||||
[Tooltip("UI 列表/详情用的缩略图")]
|
||||
public Sprite uiIconSprite;
|
||||
[TextArea(2, 4)]
|
||||
[Tooltip("描述文字")]
|
||||
public string description;
|
||||
|
||||
// ---- 运行时状态(由服务器/UI面板读写) ----
|
||||
[System.NonSerialized] public bool isUnlocked;
|
||||
[System.NonSerialized] public bool isEquipped;
|
||||
[System.NonSerialized] public int ownStarLevel;
|
||||
|
||||
[Header("动画组件")]
|
||||
public SkeletonGraphic skeletonAnimation;
|
||||
public Animation old_CurrAnimation;
|
||||
@@ -51,6 +75,35 @@ public class TurretData : MonoBehaviour
|
||||
|
||||
private TurretState currState;
|
||||
|
||||
/// <summary>
|
||||
/// 从资源表查询 TurretResourcesData。表里没有则返回 null,调用方应使用 TurretData 自身的 Inspector 默认值。
|
||||
/// </summary>
|
||||
public TurretResourcesData GetResourcesData()
|
||||
{
|
||||
return TurretResourcesData.GetTurretData(turretNumber);
|
||||
}
|
||||
|
||||
/// <summary>安全获取攻击音效 ID:表里有就用,没有则返回 0(静音)。</summary>
|
||||
public int GetAttackAudioID()
|
||||
{
|
||||
var res = GetResourcesData();
|
||||
return res != null ? res.attackAudioID : 0;
|
||||
}
|
||||
|
||||
/// <summary>安全获取子弹 ID 列表:表里有就用,没有则返回空列表。</summary>
|
||||
public List<int> GetBulletIDs()
|
||||
{
|
||||
var res = GetResourcesData();
|
||||
return res?.bulletID ?? new List<int>();
|
||||
}
|
||||
|
||||
/// <summary>安全获取动画类型:表里有就用,没有则用 Inspector 配置的 currTurretType。</summary>
|
||||
public TurretAnimType GetAnimationType()
|
||||
{
|
||||
var res = GetResourcesData();
|
||||
return res != null ? (TurretAnimType)res.animationType : currTurretType;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
//if (setPosData != null)
|
||||
@@ -213,4 +266,4 @@ public class TurretData : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,830 @@
|
||||
[
|
||||
{
|
||||
"turretNumber": 11001,
|
||||
"turretName": "深海之眼",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11001",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11002,
|
||||
"turretName": "祥龙九天",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11002",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11003,
|
||||
"turretName": "星际战舰",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11003",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11004,
|
||||
"turretName": "星际穿梭",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11004",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11005,
|
||||
"turretName": "洛神萌仙",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11005",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11006,
|
||||
"turretName": "脉冲音波",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11006",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11007,
|
||||
"turretName": "萌娃驾到",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11007",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11008,
|
||||
"turretName": "创世之心",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11008",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11009,
|
||||
"turretName": "龙舟先锋",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11009",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11010,
|
||||
"turretName": "金福满堂",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11010",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11011,
|
||||
"turretName": "福狮之心",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11011",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11012,
|
||||
"turretName": "舞兔映月",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11012",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11013,
|
||||
"turretName": "森林秘宝",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11013",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11014,
|
||||
"turretName": "心心相印",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11014",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11015,
|
||||
"turretName": "冰火回响",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11015",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11016,
|
||||
"turretName": "梦华水晶",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11016",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11017,
|
||||
"turretName": "苍刃出鞘",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11017",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11018,
|
||||
"turretName": "梦魇鬼魅",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11018",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11019,
|
||||
"turretName": "救赎圣域",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11019",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11020,
|
||||
"turretName": "武装斗神",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11020",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11021,
|
||||
"turretName": "诸葛神弩",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11021",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11022,
|
||||
"turretName": "春华锦簇",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11022",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11023,
|
||||
"turretName": "神龙大侠",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11023",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11024,
|
||||
"turretName": "醒狮纳吉1",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11024",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11025,
|
||||
"turretName": "鸿兔先锋",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11025",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11026,
|
||||
"turretName": "刑天魔斧",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11026",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11027,
|
||||
"turretName": "冰霜巨龙",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11027",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11028,
|
||||
"turretName": "剑气如虹",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11028",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11029,
|
||||
"turretName": "万圣通灵",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11029",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11030,
|
||||
"turretName": "八卦神炉",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11030",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11031,
|
||||
"turretName": "暗域侵扰",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11031",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11032,
|
||||
"turretName": "天下无极",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11032",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11033,
|
||||
"turretName": "金秋之心",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11033",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11034,
|
||||
"turretName": "沙滩明珠",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11034",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11035,
|
||||
"turretName": "甜心教主",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11035",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11036,
|
||||
"turretName": "荧光之星",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11036",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11037,
|
||||
"turretName": "雷神之怒",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11037",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11038,
|
||||
"turretName": "麒麟瑞兽",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11038",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11039,
|
||||
"turretName": "黑龙吐息",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11039",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11040,
|
||||
"turretName": "圣光之剑",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11040",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11041,
|
||||
"turretName": "能量核心",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11041",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11042,
|
||||
"turretName": "战魂之刃",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11042",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11043,
|
||||
"turretName": "战神之怒",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11043",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11044,
|
||||
"turretName": "醒狮纳吉",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11044",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 11045,
|
||||
"turretName": "裂魂之刃",
|
||||
"turretType": 1,
|
||||
"prefabTurretResourcesPath": "paotai11045",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17001,
|
||||
"turretName": "自由之翼",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17001",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17002,
|
||||
"turretName": "紫晶龙翼",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17002",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17003,
|
||||
"turretName": "祥麟瑞凤",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17003",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17004,
|
||||
"turretName": "雷霆万钧",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17004",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17005,
|
||||
"turretName": "梦幻之翼",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17005",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17006,
|
||||
"turretName": "风暴之心",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17006",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17007,
|
||||
"turretName": "堕天使之翼",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17007",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17008,
|
||||
"turretName": "飞鱼双翅",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17008",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17009,
|
||||
"turretName": "极度深寒",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17009",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17010,
|
||||
"turretName": "如虎添翼",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17010",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17011,
|
||||
"turretName": "战魂之翼",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17011",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17012,
|
||||
"turretName": "傲游太虚",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17012",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17013,
|
||||
"turretName": "珍珠之翼",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17013",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17014,
|
||||
"turretName": "金秋之翼",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17014",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17015,
|
||||
"turretName": "血翼狂潮",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17015",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17016,
|
||||
"turretName": "幽冥飞刃",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17016",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17017,
|
||||
"turretName": "战旗之翼",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17017",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17018,
|
||||
"turretName": "三昧真火",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17018",
|
||||
"animationType": 2,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17019,
|
||||
"turretName": "永冻领域",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17019",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17020,
|
||||
"turretName": "蚩尤虎魄",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17020",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17021,
|
||||
"turretName": "鸿福展翅",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17021",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17022,
|
||||
"turretName": "流光祥翼",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17022",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17023,
|
||||
"turretName": "武林至尊",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17023",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17024,
|
||||
"turretName": "流光华彩",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17024",
|
||||
"animationType": 2,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17025,
|
||||
"turretName": "焰翎之翼",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17025",
|
||||
"animationType": 2,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17026,
|
||||
"turretName": "天机神鹰",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17026",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17027,
|
||||
"turretName": "圣洁之心",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17027",
|
||||
"animationType": 2,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17028,
|
||||
"turretName": "刀光剑影",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17028",
|
||||
"animationType": 2,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17029,
|
||||
"turretName": "流火之焰",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17029",
|
||||
"animationType": 2,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17030,
|
||||
"turretName": "玄冰烈焰",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17030",
|
||||
"animationType": 2,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17031,
|
||||
"turretName": "巨蟹之翼",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17031",
|
||||
"animationType": 2,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17032,
|
||||
"turretName": "飞龙在天",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17032",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17033,
|
||||
"turretName": "金色童年",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17033",
|
||||
"animationType": 2,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17034,
|
||||
"turretName": "虚空之光",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17034",
|
||||
"animationType": 2,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17035,
|
||||
"turretName": "蜻蜓之夏",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17035",
|
||||
"animationType": 2,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17036,
|
||||
"turretName": "幻蝶彩翼",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17036",
|
||||
"animationType": 2,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17037,
|
||||
"turretName": "福狮之翼",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17037",
|
||||
"animationType": 2,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17038,
|
||||
"turretName": "炽核振羽",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17038",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17039,
|
||||
"turretName": "树影轻舞",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17039",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17040,
|
||||
"turretName": "创世幻翼",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17040",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17041,
|
||||
"turretName": "环游世界",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17041",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17042,
|
||||
"turretName": "音律幻羽",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17042",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17043,
|
||||
"turretName": "洛神云翼",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17043",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17044,
|
||||
"turretName": "五谷丰登",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17044",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17045,
|
||||
"turretName": "次元光翼",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17045",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17046,
|
||||
"turretName": "时空穿梭",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17046",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
},
|
||||
{
|
||||
"turretNumber": 17047,
|
||||
"turretName": "玄武灵蛇",
|
||||
"turretType": 3,
|
||||
"prefabTurretResourcesPath": "chibang17047",
|
||||
"animationType": 1,
|
||||
"attackAudioID": 0,
|
||||
"bulletID": []
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 348202e883366e74b8f4c2004d85283a
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,115 +1,213 @@
|
||||
using Newtonsoft.Json;
|
||||
using Spine.Unity;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
using static UnityEngine.AddressableAssets.Addressables;
|
||||
|
||||
[Serializable]
|
||||
public class TurretResourcesData
|
||||
{
|
||||
public int turretNumber;
|
||||
public int turretType; // 1普通炮台 2战神 3翅膀
|
||||
public string prefabTurretResourcesPath;
|
||||
public int animationType; // 1spine 2animator 3animation
|
||||
public int attackAudio;
|
||||
public string turretName; // 中文名称(如"深海之眼")
|
||||
public int turretType; // 1=普通炮台 2=战神 3=翅膀
|
||||
public string prefabTurretResourcesPath; // 资源路径(prefab/spine/sprite 共用名)
|
||||
public int animationType; // 1=spine 2=animator 3=animation
|
||||
public int attackAudioID; // 攻击音效 ID
|
||||
public List<int> bulletID; // 子弹 ID 列表
|
||||
|
||||
const string prefabTurret_AALabel = "TurretPrefab";
|
||||
const string turretSpine_AALabel = "TurretSpine";
|
||||
const string turretSprite_AALabel = "TurretSprite";
|
||||
// ---- Addressables 标签 ----
|
||||
const string turret_AALabel = "PT"; // 炮台统一标签
|
||||
const string defaultSubLabel = "Default"; // 默认子标签
|
||||
|
||||
private static Dictionary<string, int> TurretPrefabsDic; // prefabPath -> id
|
||||
private static Dictionary<string, int> TurretSpineDic; // spinePath -> id
|
||||
private static Dictionary<string, int> TurretSpriteDic; // spritePath -> id
|
||||
// ---- 路径→ID 映射(用于 Addressables 加载时反查) ----
|
||||
private static Dictionary<string, int> turretPrefabPathDic; // prefabPath → turretNumber
|
||||
private static Dictionary<string, int> turretSpritePathDic; // spritePath → turretNumber
|
||||
|
||||
public static Dictionary<int, TurretResourcesData> turretResourcesDatasDic; // id -> data
|
||||
private static Dictionary<int, GameObject> turretPrefabDic; // id -> prefab
|
||||
private static Dictionary<int, Sprite> turretSpriteDic; // id -> sprite
|
||||
// ---- ID→数据/资源 映射 ----
|
||||
public static Dictionary<int, TurretResourcesData> turretDataDic; // id → data
|
||||
private static Dictionary<int, GameObject> turretPrefabDic; // id → prefab
|
||||
private static Dictionary<int, Sprite> turretSpriteDic; // id → sprite
|
||||
|
||||
static TurretResourcesData()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从 Resources/tbturretresources.json 加载炮台元数据。
|
||||
/// 表里没有的 turretNumber,调用方用 TurretData 自身的 Inspector 默认值,不报错。
|
||||
/// </summary>
|
||||
async static void Init()
|
||||
{
|
||||
string turretPath = Resources.Load<TextAsset>("tbTurretResources").text;
|
||||
var list = JsonConvert.DeserializeObject<List<TurretResourcesData>>(turretPath);
|
||||
turretPrefabPathDic = new Dictionary<string, int>();
|
||||
turretSpritePathDic = new Dictionary<string, int>();
|
||||
turretDataDic = new Dictionary<int, TurretResourcesData>();
|
||||
|
||||
TurretPrefabsDic = new Dictionary<string, int>();
|
||||
TurretSpineDic = new Dictionary<string, int>();
|
||||
TurretSpriteDic = new Dictionary<string, int>();
|
||||
turretResourcesDatasDic = new Dictionary<int, TurretResourcesData>();
|
||||
|
||||
foreach (var item in list)
|
||||
TextAsset jsonAsset = Resources.Load<TextAsset>("tbturretresources");
|
||||
if (jsonAsset == null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item.prefabTurretResourcesPath))
|
||||
Debug.LogWarning("[TurretResourcesData] 资源表 tbturretresources.json 未找到,炮台数据字典为空,将使用 TurretData 默认值");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var list = JsonConvert.DeserializeObject<List<TurretResourcesData>>(jsonAsset.text);
|
||||
if (list == null)
|
||||
{
|
||||
TurretPrefabsDic[item.prefabTurretResourcesPath] = item.turretNumber;
|
||||
TurretSpriteDic[item.prefabTurretResourcesPath] = item.turretNumber;
|
||||
turretResourcesDatasDic[item.turretNumber] = item;
|
||||
Debug.LogWarning("[TurretResourcesData] 资源表解析为空,将使用 TurretData 默认值");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var item in list)
|
||||
{
|
||||
if (string.IsNullOrEmpty(item.prefabTurretResourcesPath))
|
||||
continue;
|
||||
|
||||
turretPrefabPathDic[item.prefabTurretResourcesPath] = item.turretNumber;
|
||||
turretSpritePathDic[item.prefabTurretResourcesPath] = item.turretNumber;
|
||||
turretDataDic[item.turretNumber] = item;
|
||||
|
||||
Debug.Log($"[TurretResourcesData] 加载炮台: ID={item.turretNumber}, Path={item.prefabTurretResourcesPath}, Type={item.turretType}, BulletIDs=[{string.Join(",", item.bulletID)}]");
|
||||
}
|
||||
|
||||
Debug.Log($"[TurretResourcesData] 初始化完成,共 {turretDataDic.Count} 个炮台配置");
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Debug.LogError($"[TurretResourcesData] JSON 解析失败: {ex.Message},炮台数据字典为空,将使用 TurretData 默认值");
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 资源加载 ====================
|
||||
|
||||
/// <summary>
|
||||
/// 加载炮台相关 Addressables 资源(PT + Default 标签交集)。
|
||||
/// </summary>
|
||||
public static async Task LoadTurretAssetsData()
|
||||
{
|
||||
turretPrefabDic = new Dictionary<int, GameObject>();
|
||||
turretSpriteDic = new Dictionary<int, Sprite>();
|
||||
|
||||
var labels = new List<string>
|
||||
{
|
||||
prefabTurret_AALabel,
|
||||
turretSpine_AALabel,
|
||||
turretSprite_AALabel,
|
||||
GameManager.Instance.gameData.currGameType.ToString()
|
||||
};
|
||||
var labels = new List<string> { turret_AALabel, defaultSubLabel };
|
||||
|
||||
Debug.Log("开始预下载炮台资源依赖...");
|
||||
Debug.Log("[TurretResourcesData] 开始预下载炮台资源依赖 (PT + Default)...");
|
||||
var depHandle = Addressables.DownloadDependenciesAsync(labels, MergeMode.Intersection);
|
||||
await depHandle.Task;
|
||||
Addressables.Release(depHandle);
|
||||
Debug.Log("炮台依赖资源预下载完成!");
|
||||
Debug.Log("[TurretResourcesData] 炮台依赖资源预下载完成!");
|
||||
|
||||
// ---------------- 1. 加载炮台 Prefab ----------------
|
||||
var prefabKeys = new List<string> { prefabTurret_AALabel, GameManager.Instance.gameData.currGameType.ToString() };
|
||||
var prefabHandle = Addressables.LoadAssetsAsync<GameObject>(prefabKeys, prefab =>
|
||||
// ---- 加载炮台 Prefab ----
|
||||
var prefabHandle = Addressables.LoadAssetsAsync<GameObject>(labels, prefab =>
|
||||
{
|
||||
if (TurretPrefabsDic.TryGetValue(prefab.name, out int id))
|
||||
if (turretPrefabPathDic.TryGetValue(prefab.name, out int id))
|
||||
{
|
||||
turretPrefabDic[id] = prefab;
|
||||
Debug.Log($"[TurretResourcesData] 加载 Prefab: {prefab.name} (ID={id})");
|
||||
}
|
||||
}, MergeMode.Intersection);
|
||||
|
||||
await prefabHandle.Task;
|
||||
Addressables.Release(prefabHandle);
|
||||
Debug.Log($"炮台 Prefab 加载完成,共 {turretPrefabDic.Count} 个");
|
||||
// ---------------- 3. 加载炮台 Sprite ----------------
|
||||
var spriteKeys = new List<string> { turretSprite_AALabel, GameManager.Instance.gameData.currGameType.ToString() };
|
||||
var spriteHandle = Addressables.LoadAssetsAsync<Sprite>(spriteKeys, data =>
|
||||
Debug.Log($"[TurretResourcesData] 炮台 Prefab 加载完成,共 {turretPrefabDic.Count} 个");
|
||||
|
||||
// ---- 加载炮台 Sprite ----
|
||||
var spriteHandle = Addressables.LoadAssetsAsync<Sprite>(labels, data =>
|
||||
{
|
||||
if (TurretSpriteDic.TryGetValue(data.name, out int id))
|
||||
if (turretSpritePathDic.TryGetValue(data.name, out int id))
|
||||
{
|
||||
turretSpriteDic[id] = data;
|
||||
Debug.Log($"[TurretResourcesData] 加载 Sprite: {data.name} (ID={id})");
|
||||
}
|
||||
}, MergeMode.Intersection);
|
||||
|
||||
await spriteHandle.Task;
|
||||
Addressables.Release(spriteHandle);
|
||||
Debug.Log($"炮台 Sprite 加载完成,共 {turretSpriteDic.Count} 个");
|
||||
Debug.Log($"[TurretResourcesData] 炮台 Sprite 加载完成,共 {turretSpriteDic.Count} 个");
|
||||
|
||||
Debug.Log("所有炮台资源加载完毕!");
|
||||
Debug.Log("[TurretResourcesData] 所有炮台资源加载完毕!");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 卸载炮台 Addressables 资源。
|
||||
/// </summary>
|
||||
public static async Task UnLoadTurretAssetsData()
|
||||
{
|
||||
var labels = new List<string> { turret_AALabel, defaultSubLabel };
|
||||
|
||||
// 卸载 Prefab
|
||||
var prefabHandle = Addressables.LoadAssetsAsync<GameObject>(labels, null, MergeMode.Intersection);
|
||||
await prefabHandle.Task;
|
||||
if (prefabHandle.Result != null)
|
||||
{
|
||||
foreach (var prefab in prefabHandle.Result)
|
||||
{
|
||||
if (turretPrefabPathDic.TryGetValue(prefab.name, out int id))
|
||||
{
|
||||
if (turretPrefabDic != null && turretPrefabDic.Remove(id))
|
||||
Debug.Log($"[TurretResourcesData] 卸载 Prefab: {prefab.name} (ID={id})");
|
||||
}
|
||||
}
|
||||
}
|
||||
Addressables.Release(prefabHandle);
|
||||
|
||||
// 卸载 Sprite
|
||||
var spriteHandle = Addressables.LoadAssetsAsync<Sprite>(labels, null, MergeMode.Intersection);
|
||||
await spriteHandle.Task;
|
||||
if (spriteHandle.Result != null)
|
||||
{
|
||||
foreach (var sprite in spriteHandle.Result)
|
||||
{
|
||||
if (turretSpritePathDic.TryGetValue(sprite.name, out int id))
|
||||
{
|
||||
if (turretSpriteDic != null && turretSpriteDic.Remove(id))
|
||||
Debug.Log($"[TurretResourcesData] 卸载 Sprite: {sprite.name} (ID={id})");
|
||||
}
|
||||
}
|
||||
}
|
||||
Addressables.Release(spriteHandle);
|
||||
|
||||
Debug.Log($"[TurretResourcesData] 卸载完成,剩余 Prefab: {turretPrefabDic?.Count ?? 0}, Sprite: {turretSpriteDic?.Count ?? 0}");
|
||||
}
|
||||
|
||||
// ==================== 查询接口 ====================
|
||||
|
||||
/// <summary>根据 ID 获取炮台数据。</summary>
|
||||
public static TurretResourcesData GetTurretData(int turretNumber)
|
||||
{
|
||||
return turretDataDic != null && turretDataDic.TryGetValue(turretNumber, out var data) ? data : null;
|
||||
}
|
||||
|
||||
/// <summary>根据 ID 获取炮台 Prefab。</summary>
|
||||
public static GameObject GetTurretPrefab(int turretNumber)
|
||||
{
|
||||
return turretPrefabDic.TryGetValue(turretNumber, out var prefab) ? prefab : null;
|
||||
return turretPrefabDic != null && turretPrefabDic.TryGetValue(turretNumber, out var prefab) ? prefab : null;
|
||||
}
|
||||
|
||||
/// <summary>根据 ID 获取炮台 Sprite。</summary>
|
||||
public static Sprite GetTurretSprite(int turretNumber)
|
||||
{
|
||||
return turretSpriteDic.TryGetValue(turretNumber, out var sprite) ? sprite : null;
|
||||
return turretSpriteDic != null && turretSpriteDic.TryGetValue(turretNumber, out var sprite) ? sprite : null;
|
||||
}
|
||||
|
||||
/// <summary>获取所有炮台数据列表。</summary>
|
||||
public static List<TurretResourcesData> GetAllTurretData()
|
||||
{
|
||||
return turretDataDic != null ? new List<TurretResourcesData>(turretDataDic.Values) : new List<TurretResourcesData>();
|
||||
}
|
||||
|
||||
/// <summary>根据类型获取炮台数据(1=普通炮台, 2=战神, 3=翅膀)。</summary>
|
||||
public static List<TurretResourcesData> GetTurretDataByType(int turretType)
|
||||
{
|
||||
var result = new List<TurretResourcesData>();
|
||||
if (turretDataDic == null) return result;
|
||||
foreach (var kv in turretDataDic)
|
||||
{
|
||||
if (kv.Value.turretType == turretType)
|
||||
result.Add(kv.Value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user